-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathStorage.h
94 lines (73 loc) · 1.93 KB
/
Storage.h
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#pragma once
#include <sstream>
#include <vector>
#include <boost/container/flat_map.hpp>
#include "common/ICriticalSection.h"
#include "skse/PluginAPI.h"
#include "skse/GameTypes.h"
#include "skse/GameData.h"
#include "skse/PapyrusVM.h"
#include "skse/PapyrusArgs.h"
#include "Forms.h"
namespace Storage
{
enum ValueType {
nullValue = 0,
intValue,
floatValue,
stringValue,
formValue
};
class Value{
union ValueHolder {
SInt32 _int;
float _float;
char* _string;
char* _form;
} value;
ValueType type : 4;
Value(ValueType type = nullValue);
Value(SInt32 var);
Value(float var);
Value(BSFixedString var);
Value(TESForm* var);
SInt32 asInt();
float asFloat();
BSFixedString asString();
TESForm* asForm();
template <typename T> inline T Decode();
};
/*
* Decalare classes methods
*/
template <typename T>
class Values {
public:
ICriticalSection s_dataLock;
typedef boost::container::flat_map<std::string, Value> Obj;
typedef boost::container::flat_map<UInt64, Obj> Map;
void SetValue(UInt64 obj, std::string key, T value);
T GetValue(UInt64 obj, std::string key, T value);
/*
typedef boost::container::flat_map<std::string, S> Obj;
typedef boost::container::flat_map<UInt64, Obj> Map;
Map Data;
T SetValue(UInt64 obj, std::string key, T value);
T GetValue(UInt64 obj, std::string key, T value);
T AdjustValue(UInt64 obj, std::string key, T value);
bool UnsetValue(UInt64 obj, std::string key);
bool HasValue(UInt64 obj, std::string key);
// Serialization
void Revert();
void LoadStream(std::stringstream &ss);
void SaveStream(std::stringstream &ss);
// Debug
inline int GetObjCount() { return Data.size(); }
inline int GetKeyCount(UInt64 obj) { return Data.find(obj) != Data.end() ? Data[obj].size() : 0; }
TESForm* GetNthObj(UInt32 i);
std::string GetNthKey(UInt64 obj, UInt32 i);
void RemoveForm(UInt64 &obj);
int Cleanup();
*/
};
}