Maze Builder Docs 7.5.6
Loading...
Searching...
No Matches
json_helper.h
Go to the documentation of this file.
1#ifndef JSON_HELPER_H
2#define JSON_HELPER_H
3
4#include <string>
5#include <memory>
6#include <unordered_map>
7#include <vector>
8
9namespace mazes
10{
16 {
17 public:
19 explicit json_helper();
20
23
24 // Copy constructor
25 json_helper(const json_helper &other);
26
27 // Copy assignment operator
28 json_helper &operator=(const json_helper &other);
29
30 // Move constructor
31 json_helper(json_helper &&other) noexcept = default;
32
33 // Move assignment operator
34 json_helper &operator=(json_helper &&other) noexcept = default;
35
40 std::string from(const std::unordered_map<std::string, std::string> &map, int pretty_print = 4) const noexcept;
41
46 std::string from(const std::vector<std::unordered_map<std::string, std::string>> &arr, int pretty_print = 4) const noexcept;
47
52 bool from(const std::string &s, std::unordered_map<std::string, std::string> &m) const noexcept;
53
58 bool load(const std::string &filename, std::unordered_map<std::string, std::string> &m) const noexcept;
59
64 bool from_array(const std::string &s, std::vector<std::unordered_map<std::string, std::string>> &vm) const noexcept;
65
70 bool load_array(const std::string &filename, std::vector<std::unordered_map<std::string, std::string>> &vm) const noexcept;
71
72 private:
74 class json_helper_impl;
75 std::unique_ptr<json_helper_impl> impl;
76 };
77
78} // namespace mazes
79
80#endif // JSON_HELPER_H
JSON helper class.
Definition json_helper.h:16
json_helper()
Default constructor.
bool load(const std::string &filename, std::unordered_map< std::string, std::string > &m) const noexcept
Parse a JSON file into a C++ map from a file on disk.
bool from_array(const std::string &s, std::vector< std::unordered_map< std::string, std::string > > &vm) const noexcept
Parse a JSON array string into a vector of maps.
bool load_array(const std::string &filename, std::vector< std::unordered_map< std::string, std::string > > &vm) const noexcept
Load a JSON array file into a vector of maps.
std::string from(const std::unordered_map< std::string, std::string > &map, int pretty_print=4) const noexcept
Get the contents of a map as a string in JSON format.
~json_helper()
Destructor.
Namespace for the maze builder.
Definition algo_interface.h:6