Util: Add parse() and dump() to Json::Value
This commit is contained in:
+12
-2
@@ -7,6 +7,8 @@
|
||||
#ifndef JSON_VALUE_H
|
||||
#define JSON_VALUE_H
|
||||
|
||||
#include <cstdint> // uint32_t
|
||||
#include <iostream> // istream, ostream
|
||||
#include <string>
|
||||
|
||||
namespace Json {
|
||||
@@ -25,7 +27,7 @@ public:
|
||||
Object, // {}
|
||||
};
|
||||
|
||||
Value() {}
|
||||
Value(std::nullptr_t = nullptr) {}
|
||||
virtual ~Value() { clear(); }
|
||||
|
||||
// Copy constructor
|
||||
@@ -40,6 +42,11 @@ public:
|
||||
Value(const Array& value);
|
||||
Value(const Object& value);
|
||||
|
||||
// ------------------------------------------
|
||||
|
||||
static Value parse(const std::string& input);
|
||||
std::string dump(const uint32_t indent = 0, const char indentCharacter = ' ') const;
|
||||
|
||||
// Array index operator
|
||||
Value operator[](size_t index);
|
||||
Value operator[](const std::string& key);
|
||||
@@ -64,9 +71,12 @@ private:
|
||||
std::string* asString;
|
||||
Array* asArray;
|
||||
Object* asObject;
|
||||
} m_value;
|
||||
} m_value {};
|
||||
};
|
||||
|
||||
std::istream& operator>>(std::istream& input, Value& value);
|
||||
std::ostream& operator<<(std::ostream& output, const Value& value);
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#endif // JSON_VALUE_H
|
||||
|
||||
Reference in New Issue
Block a user