Adjusted workflow.
This commit is contained in:
68
include/ehs/json/Json.h
Normal file
68
include/ehs/json/Json.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#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 Json
|
||||
{
|
||||
private:
|
||||
JsonBase* value;
|
||||
|
||||
public:
|
||||
virtual ~Json();
|
||||
|
||||
Json();
|
||||
|
||||
Json(const JsonBase& value);
|
||||
|
||||
Json(const JsonObj& value);
|
||||
|
||||
Json(const JsonArray& value);
|
||||
|
||||
Json(const JsonBool& value);
|
||||
|
||||
Json(const JsonNum& value);
|
||||
|
||||
Json(const JsonStr& value);
|
||||
|
||||
Json(const char* data, const UInt_64 size, const UInt_64 extra);
|
||||
|
||||
Json(const Str_8& data, const UInt_64 extra);
|
||||
|
||||
Json(Json&& json) noexcept;
|
||||
|
||||
Json(const Json &json);
|
||||
|
||||
Json& operator=(Json&& json) noexcept;
|
||||
|
||||
Json& operator=(const Json& json);
|
||||
|
||||
JsonBase* GetValue();
|
||||
|
||||
JsonBase* RetrieveValue(const Str_8& access);
|
||||
|
||||
Str_8 ToStr(const bool compact) const;
|
||||
|
||||
private:
|
||||
static Vector<Str_8> ParseAccess(const Str_8& access);
|
||||
|
||||
void ParseValue(JsonVar* var, const Char_8** begin, const Char_8* end, const UInt_64 extra);
|
||||
|
||||
JsonVar ParseVar(const Char_8** begin, const Char_8* end, const UInt_64 extra);
|
||||
|
||||
void ParseObject(JsonObj* obj, const Char_8** begin, const Char_8* end, const UInt_64 extra);
|
||||
|
||||
void ParseArray(JsonArray* arr, const Char_8** begin, const Char_8* end, const UInt_64 extra);
|
||||
|
||||
void Parse(const Str_8& data, const UInt_64 extra);
|
||||
};
|
||||
}
|
77
include/ehs/json/JsonArray.h
Normal file
77
include/ehs/json/JsonArray.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
|
||||
#include "ehs/EHS.h"
|
||||
#include "ehs/Str.h"
|
||||
#include "JsonBase.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class JsonObj;
|
||||
class JsonBool;
|
||||
class JsonNum;
|
||||
class JsonStr;
|
||||
|
||||
class JsonArray : public JsonBase
|
||||
{
|
||||
private:
|
||||
UInt_64 size;
|
||||
UInt_64 extra;
|
||||
UInt_64 rawSize;
|
||||
JsonBase** data;
|
||||
|
||||
public:
|
||||
virtual ~JsonArray();
|
||||
|
||||
JsonArray();
|
||||
|
||||
JsonArray(const UInt_64 extra);
|
||||
|
||||
JsonArray(const UInt_64 size, const UInt_64 extra);
|
||||
|
||||
JsonArray(JsonArray&& ja) noexcept;
|
||||
|
||||
JsonArray(const JsonArray& ja);
|
||||
|
||||
JsonArray& operator=(JsonArray&& ja) noexcept;
|
||||
|
||||
JsonArray& operator=(const JsonArray& ja);
|
||||
|
||||
operator JsonBase* const *() const;
|
||||
|
||||
operator JsonBase**();
|
||||
|
||||
UInt_64 RawSize() const;
|
||||
|
||||
UInt_64 Extra() const;
|
||||
|
||||
UInt_64 Size() const;
|
||||
|
||||
void Insert(const UInt_64 index, const JsonBase* const value);
|
||||
|
||||
void Push(const JsonBase* const value);
|
||||
|
||||
void Push(const JsonBase& value);
|
||||
|
||||
void Push(const JsonObj& value);
|
||||
|
||||
void Push(const JsonArray& value);
|
||||
|
||||
void Push(const JsonBool& value);
|
||||
|
||||
void Push(const bool value);
|
||||
|
||||
void Push(const JsonNum& value);
|
||||
|
||||
void Push(const float value);
|
||||
|
||||
void Push(const JsonStr& value);
|
||||
|
||||
void Push(const Char_8* value, const UInt_64 size = 0);
|
||||
|
||||
void Push(const Str_8& value);
|
||||
|
||||
void Pop();
|
||||
|
||||
Str_8 ToStr(const UInt_64 level, const bool compact) const;
|
||||
};
|
||||
}
|
34
include/ehs/json/JsonBase.h
Normal file
34
include/ehs/json/JsonBase.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "ehs/EHS.h"
|
||||
#include "ehs/Str.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
enum class JsonType
|
||||
{
|
||||
NULLOBJ,
|
||||
OBJ,
|
||||
ARRAY,
|
||||
BOOL,
|
||||
NUM,
|
||||
STR
|
||||
};
|
||||
|
||||
class JsonBase
|
||||
{
|
||||
private:
|
||||
JsonType type;
|
||||
|
||||
public:
|
||||
JsonBase();
|
||||
|
||||
JsonBase(const JsonType type);
|
||||
|
||||
JsonBase(const JsonBase& base) = default;
|
||||
|
||||
JsonType GetType() const;
|
||||
|
||||
virtual Str_8 ToStr(const UInt_64 level, const bool compact) const;
|
||||
};
|
||||
}
|
27
include/ehs/json/JsonBool.h
Normal file
27
include/ehs/json/JsonBool.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "ehs/EHS.h"
|
||||
#include "ehs/Str.h"
|
||||
|
||||
#include "JsonBase.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class JsonBool : public JsonBase
|
||||
{
|
||||
public:
|
||||
bool value;
|
||||
|
||||
JsonBool();
|
||||
|
||||
JsonBool(const bool value);
|
||||
|
||||
JsonBool(const JsonBool& jb) = default;
|
||||
|
||||
operator bool() const;
|
||||
|
||||
operator bool&();
|
||||
|
||||
Str_8 ToStr(const UInt_64 level, const bool compact) const;
|
||||
};
|
||||
}
|
45
include/ehs/json/JsonNum.h
Normal file
45
include/ehs/json/JsonNum.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include "ehs/EHS.h"
|
||||
#include "ehs/Str.h"
|
||||
|
||||
#include "JsonBase.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class JsonNum : public JsonBase
|
||||
{
|
||||
public:
|
||||
float value;
|
||||
|
||||
JsonNum();
|
||||
|
||||
JsonNum(const SInt_64 value);
|
||||
|
||||
JsonNum(const UInt_64 value);
|
||||
|
||||
JsonNum(const SInt_32 value);
|
||||
|
||||
JsonNum(const UInt_32 value);
|
||||
|
||||
JsonNum(const SInt_16 value);
|
||||
|
||||
JsonNum(const UInt_16 value);
|
||||
|
||||
JsonNum(const SInt_8 value);
|
||||
|
||||
JsonNum(const UInt_8 value);
|
||||
|
||||
JsonNum(const double value);
|
||||
|
||||
JsonNum(const float value);
|
||||
|
||||
JsonNum(const JsonNum& jn) = default;
|
||||
|
||||
operator float() const;
|
||||
|
||||
operator float&();
|
||||
|
||||
Str_8 ToStr(const UInt_64 level, const bool compact) const;
|
||||
};
|
||||
}
|
63
include/ehs/json/JsonObj.h
Normal file
63
include/ehs/json/JsonObj.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include "ehs/EHS.h"
|
||||
#include "ehs/Str.h"
|
||||
|
||||
#include "JsonBase.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class JsonVar;
|
||||
|
||||
class JsonObj : public JsonBase
|
||||
{
|
||||
protected:
|
||||
UInt_64 size;
|
||||
UInt_64 extra;
|
||||
UInt_64 rawSize;
|
||||
JsonVar* vars;
|
||||
|
||||
public:
|
||||
virtual ~JsonObj();
|
||||
|
||||
JsonObj();
|
||||
|
||||
JsonObj(const UInt_64 size, const UInt_64 extra);
|
||||
|
||||
JsonObj(const UInt_64 extra);
|
||||
|
||||
JsonObj(JsonObj&& value) noexcept;
|
||||
|
||||
JsonObj(const JsonObj& value);
|
||||
|
||||
JsonObj& operator=(JsonObj&& value) noexcept;
|
||||
|
||||
JsonObj& operator=(const JsonObj& value);
|
||||
|
||||
operator const JsonVar*() const;
|
||||
|
||||
operator JsonVar*();
|
||||
|
||||
UInt_64 Size() const;
|
||||
|
||||
UInt_64 Extra() const;
|
||||
|
||||
UInt_64 RawSize() const;
|
||||
|
||||
bool HasVar(const UInt_64 hashId) const;
|
||||
|
||||
bool HasVar(const Str_8& identifier) const;
|
||||
|
||||
bool AddVar(const JsonVar& var);
|
||||
|
||||
const JsonVar* GetVar(const UInt_64 hashId) const;
|
||||
|
||||
const JsonVar* GetVar(const Str_8& identifier) const;
|
||||
|
||||
JsonVar* GetVar(const UInt_64 hashId);
|
||||
|
||||
JsonVar* GetVar(const Str_8& identifier);
|
||||
|
||||
Str_8 ToStr(const UInt_64 level, const bool compact) const;
|
||||
};
|
||||
}
|
33
include/ehs/json/JsonStr.h
Normal file
33
include/ehs/json/JsonStr.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "ehs/EHS.h"
|
||||
#include "ehs/Str.h"
|
||||
|
||||
#include "JsonBase.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class JsonStr : public JsonBase
|
||||
{
|
||||
public:
|
||||
Str_8 value;
|
||||
|
||||
JsonStr();
|
||||
|
||||
JsonStr(Str_8 value);
|
||||
|
||||
JsonStr(const Char_8* value, const UInt_64 size = 0);
|
||||
|
||||
JsonStr(JsonStr&& js) noexcept;
|
||||
|
||||
JsonStr(const JsonStr& js) = default;
|
||||
|
||||
JsonStr& operator=(JsonStr&& js) noexcept;
|
||||
|
||||
operator Str_8() const;
|
||||
|
||||
operator Str_8&();
|
||||
|
||||
Str_8 ToStr(const UInt_64 level, const bool compact) const;
|
||||
};
|
||||
}
|
109
include/ehs/json/JsonVar.h
Normal file
109
include/ehs/json/JsonVar.h
Normal file
@@ -0,0 +1,109 @@
|
||||
#pragma once
|
||||
|
||||
#include "ehs/EHS.h"
|
||||
#include "ehs/Str.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class JsonBase;
|
||||
class JsonObj;
|
||||
class JsonArray;
|
||||
class JsonBool;
|
||||
class JsonNum;
|
||||
class JsonStr;
|
||||
|
||||
class JsonVar
|
||||
{
|
||||
private:
|
||||
UInt_64 hashId;
|
||||
Str_8 id;
|
||||
JsonBase* value;
|
||||
|
||||
public:
|
||||
virtual ~JsonVar();
|
||||
|
||||
JsonVar();
|
||||
|
||||
JsonVar(Str_8 id);
|
||||
|
||||
JsonVar(Str_8 id, const JsonBase* const value);
|
||||
|
||||
JsonVar(Str_8 id, const JsonBase& value);
|
||||
|
||||
JsonVar(Str_8 id, const JsonObj& value);
|
||||
|
||||
JsonVar(Str_8 id, const JsonArray& value);
|
||||
|
||||
JsonVar(Str_8 id, const JsonBool& value);
|
||||
|
||||
JsonVar(Str_8 id, const bool boolean);
|
||||
|
||||
JsonVar(Str_8 id, const JsonNum& value);
|
||||
|
||||
JsonVar(Str_8 id, const SInt_64 num);
|
||||
|
||||
JsonVar(Str_8 id, const UInt_64 num);
|
||||
|
||||
JsonVar(Str_8 id, const SInt_32 num);
|
||||
|
||||
JsonVar(Str_8 id, const UInt_32 num);
|
||||
|
||||
JsonVar(Str_8 id, const SInt_16 num);
|
||||
|
||||
JsonVar(Str_8 id, const UInt_16 num);
|
||||
|
||||
JsonVar(Str_8 id, const SInt_8 num);
|
||||
|
||||
JsonVar(Str_8 id, const UInt_8 num);
|
||||
|
||||
JsonVar(Str_8 id, const double num);
|
||||
|
||||
JsonVar(Str_8 id, const float num);
|
||||
|
||||
JsonVar(Str_8 id, const JsonStr& value);
|
||||
|
||||
JsonVar(Str_8 id, const Char_8* str, const UInt_64 size = 0);
|
||||
|
||||
JsonVar(Str_8 id, Str_8 str);
|
||||
|
||||
JsonVar(JsonVar&& var) noexcept;
|
||||
|
||||
JsonVar(const JsonVar& var);
|
||||
|
||||
JsonVar& operator=(JsonVar&& var) noexcept;
|
||||
|
||||
JsonVar& operator=(const JsonVar& var);
|
||||
|
||||
UInt_64 GetHashId() const;
|
||||
|
||||
Str_8 GetId() const;
|
||||
|
||||
void SetValue(const JsonBase* const newValue);
|
||||
|
||||
void SetValue(const JsonBase& newValue);
|
||||
|
||||
void SetValue(const JsonObj& newValue);
|
||||
|
||||
void SetValue(const JsonArray& newValue);
|
||||
|
||||
void SetValue(const JsonBool& newValue);
|
||||
|
||||
void SetValue(const bool newValue);
|
||||
|
||||
void SetValue(const JsonNum& newValue);
|
||||
|
||||
void SetValue(const float newValue);
|
||||
|
||||
void SetValue(const JsonStr& newValue);
|
||||
|
||||
void SetValue(const Char_8* newValue, const UInt_64 size = 0);
|
||||
|
||||
void SetValue(const Str_8& newValue);
|
||||
|
||||
const JsonBase* GetValue() const;
|
||||
|
||||
JsonBase* GetValue();
|
||||
|
||||
Str_8 ToStr(const UInt_64 level, const bool compact) const;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user