-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGpJsonToObject.hpp
52 lines (37 loc) · 2.41 KB
/
GpJsonToObject.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once
#include <GpJson/GpJsonSerializerFlags.hpp>
#include <GpCore2/GpReflection/GpReflectObject.hpp>
#define RAPIDJSON_ASSERT(X) ::GPlatform::THROW_COND_GP(X, "Json processing error"_sv);
GP_WARNING_PUSH()
#if defined(GP_COMPILER_CLANG) || defined(GP_COMPILER_GCC)
GP_WARNING_DISABLE(switch-enum)
#endif// #if defined(GP_COMPILER_CLANG) || defined(GP_COMPILER_GCC)
# include <rapidjson/document.h>
GP_WARNING_POP()
namespace GPlatform {
class GpJsonToObject
{
public:
CLASS_REMOVE_CTRS_DEFAULT_MOVE_COPY(GpJsonToObject)
using ParseResT = std::variant<rapidjson::Document::ConstObject, rapidjson::Document::ConstArray>;
public:
static rapidjson::Document::ConstObject SParseJsonDom (std::string_view aJsonStr,
rapidjson::Document& aJsonDOM);
static rapidjson::Document::ConstArray SParseJsonDomVec (std::string_view aJsonStr,
rapidjson::Document& aJsonDOM);
static ParseResT SParseJsonDomInsitu (GpSpanCharRW aJsonStr,
rapidjson::Document& aJsonDOM);
static void SReadObject (GpReflectObject& aObject,
const rapidjson::Document::ConstObject& aJsonObject,
const GpJsonSerializerFlags aJsonSerializerFlags);
static const GpReflectModel& SCheckModel (const rapidjson::Document::ConstObject& aJsonObject,
const GpReflectModel& aModel);
static const GpReflectModel& SCheckModel (const rapidjson::Document::ConstObject& aJsonObject,
const std::vector<const GpReflectModel*>& aModelVariants);
static GpReflectModel::C::Opt::CRef SFindModel (const rapidjson::Document::ConstObject& aJsonObject);
private:
static std::optional<GpUUID> SFindModelUid (const rapidjson::Document::ConstObject& aJsonObject);
private:
static const std::array<std::string_view, 18> sParseErrorCodes;
};
}// namespace GPlatform