2024-02-05 22:25:30 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ehs/EHS.h"
|
|
|
|
#include "ehs/Str.h"
|
|
|
|
#include "JsonBase.h"
|
|
|
|
#include "JsonObj.h"
|
|
|
|
#include "JsonArray.h"
|
|
|
|
#include "JsonBool.h"
|
|
|
|
#include "JsonNum.h"
|
|
|
|
#include "JsonStr.h"
|
|
|
|
#include "JsonVar.h"
|
|
|
|
|
|
|
|
namespace ehs
|
|
|
|
{
|
2024-08-15 19:28:30 -07:00
|
|
|
class EHS_LIB_IO Json final
|
2024-02-05 22:25:30 -08:00
|
|
|
{
|
|
|
|
private:
|
2024-08-15 19:28:30 -07:00
|
|
|
JsonBase *value;
|
2024-02-05 22:25:30 -08:00
|
|
|
|
|
|
|
public:
|
2024-08-15 19:28:30 -07:00
|
|
|
~Json();
|
2024-02-05 22:25:30 -08:00
|
|
|
|
|
|
|
Json();
|
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
Json(const JsonBase &value);
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
Json(const JsonObj &value);
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
Json(const JsonArray &value);
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
Json(const JsonBool &value);
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
Json(const JsonNum &value);
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
Json(const JsonStr &value);
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
Json(const char *data, UInt_64 size, UInt_64 extra);
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
Json(const Str_8 &data, UInt_64 extra);
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
Json(Json &&json) noexcept;
|
2024-02-05 22:25:30 -08:00
|
|
|
|
|
|
|
Json(const Json &json);
|
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
Json &operator=(Json &&json) noexcept;
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
Json &operator=(const Json &json);
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
JsonBase *GetValue();
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
JsonBase *RetrieveValue(const Str_8 &access);
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
Str_8 ToStr(bool compact) const;
|
2024-02-05 22:25:30 -08:00
|
|
|
|
|
|
|
private:
|
2024-08-15 19:28:30 -07:00
|
|
|
static Vector<Str_8> ParseAccess(const Str_8 &access);
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
void ParseValue(JsonVar *var, const Char_8 **begin, const Char_8 *end, UInt_64 extra);
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
JsonVar ParseVar(const Char_8 **begin, const Char_8 *end, UInt_64 extra);
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
void ParseObject(JsonObj *obj, const Char_8 **begin, const Char_8 *end, UInt_64 extra);
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
void ParseArray(JsonArray *arr, const Char_8 **begin, const Char_8 *end, UInt_64 extra);
|
2024-02-05 22:25:30 -08:00
|
|
|
|
2024-08-15 19:28:30 -07:00
|
|
|
void Parse(const Str_8 &data, UInt_64 extra);
|
2024-02-05 22:25:30 -08:00
|
|
|
};
|
|
|
|
}
|