ChatPlexSDK-BS 1.0.1-v6.2.0
C++ ChatPlex BeatSaber SDK
Loading...
Searching...
No Matches
JsonConfig.hpp
1#pragma once
2
3#include "../Utils/Il2cpp.hpp"
4#include "../Utils/Json.hpp"
5
6#include <string>
7#include <filesystem>
8
9#define CP_SDK_CONFIG_JSONCONFIG_INSTANCE_DECL(__Type) \
10 private: \
11 CP_SDK_NO_COPYMOVE_CTORS(__Type) \
12 __Type() = default; \
13 static __Type* m_Instance; \
14 public: \
15 static __Type* Instance();
16
17#define CP_SDK_CONFIG_JSONCONFIG_INSTANCE_IMPL(__Type) \
18 __Type* __Type::m_Instance = nullptr; \
19 __Type* __Type::Instance() { \
20 if (!m_Instance) \
21 { \
22 m_Instance = new __Type(); \
23 m_Instance->Init(); \
24 } \
25 return m_Instance; \
26 }
27
28namespace CP_SDK::Config {
29
32 {
33 CP_SDK_NO_COPYMOVE_CTORS(JsonConfig);
34
35 protected:
39 virtual ~JsonConfig();
40
41 public:
43 void Warmup();
45 void Reset();
47 void Save();
48
49 protected:
51 virtual void Reset_Impl() = 0;
52
53 protected:
60
61 protected:
63 virtual std::filesystem::path GetRelativePath() = 0;
65 virtual std::filesystem::path GetFullPath();
66
67 protected:
70 virtual void OnInit(bool p_OnCreation) = 0;
71
72 protected:
74 void Init();
77 void WriteFile(std::filesystem::path p_FullPath);
78
79 };
80
81}
virtual void Reset_Impl()=0
Reset config to default.
virtual std::filesystem::path GetFullPath()
Get full config path.
void Warmup()
Dummy method for warmup.
void Save()
Save config file.
void Init()
Init config.
virtual CP_SDK_JSON_SERIALIZE_DECL()=0
Read the document.
virtual std::filesystem::path GetRelativePath()=0
Get relative config path.
virtual ~JsonConfig()
Destructor.
virtual CP_SDK_JSON_UNSERIALIZE_DECL()=0
Write the document.
virtual void OnInit(bool p_OnCreation)=0
On config init.
void Reset()
Reset config to default.
void WriteFile(std::filesystem::path p_FullPath)
Write file.
Json configuration utilities.