summaryrefslogtreecommitdiff
path: root/src/json.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/json.h')
-rw-r--r--src/json.h22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/json.h b/src/json.h
index d1d7938..efde542 100644
--- a/src/json.h
+++ b/src/json.h
@@ -1,7 +1,12 @@
+#pragma once
+
+#include "tokenizer.h"
+
#include <cstddef>
#include <map>
#include <memory>
#include <string>
+#include <vector>
namespace TehJSON
{
@@ -12,14 +17,19 @@ namespace TehJSON
JSON(const JSON& other) = default;
~JSON();
+ // Writing methods
+ std::string getSerialized();
+ std::string _getSerialized(int currIndent);
+
+ // Reading methods
+ void readFromString(std::string s);
+
// 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);
@@ -30,6 +40,14 @@ namespace TehJSON
private:
bool isLeaf = false;
+ // Reading data fields
+ std::vector<Token> tokens;
+ int tokenPos = 0;
+ Token consume();
+ Token consume(TokenType type);
+ TokenType nextTokenType();
+ int readFromTokens(std::vector<Token> tokens, int pos);
+
// Leaf data fields
std::shared_ptr<void> data;
std::string (*dataSerializer)(std::shared_ptr<void>);