EHS/include/ehs/json/Json.h

68 lines
1.4 KiB
C
Raw Permalink Normal View History

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
{
class EHS_LIB_IO Json final
2024-02-05 22:25:30 -08:00
{
private:
JsonBase *value;
2024-02-05 22:25:30 -08:00
public:
~Json();
2024-02-05 22:25:30 -08:00
Json();
Json(const JsonBase &value);
2024-02-05 22:25:30 -08:00
Json(const JsonObj &value);
2024-02-05 22:25:30 -08:00
Json(const JsonArray &value);
2024-02-05 22:25:30 -08:00
Json(const JsonBool &value);
2024-02-05 22:25:30 -08:00
Json(const JsonNum &value);
2024-02-05 22:25:30 -08:00
Json(const JsonStr &value);
2024-02-05 22:25:30 -08:00
Json(const char *data, UInt_64 size, UInt_64 extra);
2024-02-05 22:25:30 -08:00
Json(const Str_8 &data, UInt_64 extra);
2024-02-05 22:25:30 -08:00
Json(Json &&json) noexcept;
2024-02-05 22:25:30 -08:00
Json(const Json &json);
Json &operator=(Json &&json) noexcept;
2024-02-05 22:25:30 -08:00
Json &operator=(const Json &json);
2024-02-05 22:25:30 -08:00
JsonBase *GetValue();
2024-02-05 22:25:30 -08:00
JsonBase *RetrieveValue(const Str_8 &access);
2024-02-05 22:25:30 -08:00
Str_8 ToStr(bool compact) const;
2024-02-05 22:25:30 -08:00
private:
static Vector<Str_8> ParseAccess(const Str_8 &access);
2024-02-05 22:25:30 -08:00
void ParseValue(JsonVar *var, const Char_8 **begin, const Char_8 *end, UInt_64 extra);
2024-02-05 22:25:30 -08:00
JsonVar ParseVar(const Char_8 **begin, const Char_8 *end, UInt_64 extra);
2024-02-05 22:25:30 -08:00
void ParseObject(JsonObj *obj, const Char_8 **begin, const Char_8 *end, UInt_64 extra);
2024-02-05 22:25:30 -08:00
void ParseArray(JsonArray *arr, const Char_8 **begin, const Char_8 *end, UInt_64 extra);
2024-02-05 22:25:30 -08:00
void Parse(const Str_8 &data, UInt_64 extra);
2024-02-05 22:25:30 -08:00
};
}