diff options
Diffstat (limited to 'src/json.h')
| -rw-r--r-- | src/json.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/json.h b/src/json.h new file mode 100644 index 0000000..d1d7938 --- /dev/null +++ b/src/json.h @@ -0,0 +1,40 @@ +#include <cstddef> +#include <map> +#include <memory> +#include <string> + +namespace TehJSON +{ + class JSON + { + public: + JSON(); + JSON(const JSON& other) = default; + ~JSON(); + + // Leaf methods + template <typename T> + T& get(); + template <typename T> + void set(T value); + std::string leafType(); + std::string getSerialized(); + std::string _getSerialized(int currIndent); + template <typename T> + static std::string serializeData(std::shared_ptr<void> data); + + // Non leaf methods + JSON& operator[](std::string name); + size_t childCount(); + // std::vector<std::string> childNames(); + private: + bool isLeaf = false; + + // Leaf data fields + std::shared_ptr<void> data; + std::string (*dataSerializer)(std::shared_ptr<void>); + + // Not leaf data fields + std::map<std::string, JSON> children; + }; +} |
