DayZ 1.24
Loading...
Searching...
No Matches
JsonObject Class Reference

Private Member Functions

void JsonObject ()
 
void ~JsonObject ()
 
void Clear ()
 
void AddString (string name, string value)
 
void AddInt (string name, int value)
 
void AddFloat (string name, float value)
 
void AddBool (string name, bool value)
 
void AddVector2 (string name, float x, float y)
 
string GetJson ()
 

Private Attributes

ref map< string, stringm_Strings
 
ref map< string, intm_Ints
 
ref map< string, floatm_Floats
 
ref map< string, boolm_Bools
 
ref map< string, ref Vector2m_Vectors2
 

Detailed Description

Definition at line 1 of file JsonObject.c.

Constructor & Destructor Documentation

◆ JsonObject()

void JsonObject::JsonObject ( )
inlineprivate

Definition at line 9 of file JsonObject.c.

10 {
16 }
ref map< string, string > m_Strings
Definition JsonObject.c:3
ref map< string, float > m_Floats
Definition JsonObject.c:5
ref map< string, int > m_Ints
Definition JsonObject.c:4
ref map< string, ref Vector2 > m_Vectors2
Definition JsonObject.c:7
ref map< string, bool > m_Bools
Definition JsonObject.c:6

References m_Bools, m_Floats, m_Ints, m_Strings, and m_Vectors2.

◆ ~JsonObject()

void JsonObject::~JsonObject ( )
inlineprivate

Definition at line 18 of file JsonObject.c.

19 {
20 Clear();
21 }
void Clear()
Definition JsonObject.c:23

References Clear().

Member Function Documentation

◆ AddBool()

void JsonObject::AddBool ( string name,
bool value )
inlineprivate

Definition at line 74 of file JsonObject.c.

75 {
76 m_Bools.Insert(name, value);
77 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo

References m_Bools, and name.

◆ AddFloat()

void JsonObject::AddFloat ( string name,
float value )
inlineprivate

Definition at line 69 of file JsonObject.c.

70 {
71 m_Floats.Insert(name, value);
72 }

References m_Floats, and name.

◆ AddInt()

void JsonObject::AddInt ( string name,
int value )
inlineprivate

Definition at line 64 of file JsonObject.c.

65 {
66 m_Ints.Insert(name, value);
67 }

References m_Ints, and name.

◆ AddString()

void JsonObject::AddString ( string name,
string value )
inlineprivate

Definition at line 32 of file JsonObject.c.

33 {
35 value.Split("\"", strgs);
36
37 if (strgs.Count() > 1)
38 {
39 value = "";
40 int str_count = strgs.Count();
41
42 for (int i = 0; i < str_count; ++i)
43 {
44 string s = strgs[i];
45
46 int length = s.Length();
47
48 if (s[length - 1] != "\\")
49 {
50 value += s;
51
52 if (i < str_count - 1)
53 {
54 value += "\\";
55 value += "\"";
56 }
57 }
58 }
59 }
60
61 m_Strings.Insert(name, value);
62 }

References m_Strings, and name.

◆ AddVector2()

void JsonObject::AddVector2 ( string name,
float x,
float y )
inlineprivate

Definition at line 79 of file JsonObject.c.

80 {
81 Vector2 v = new Vector2(x, y);
82 m_Vectors2.Insert(name, v);
83 }
Icon x
Icon y

References m_Vectors2, name, x, and y.

◆ Clear()

void JsonObject::Clear ( )
inlineprivate

Definition at line 23 of file JsonObject.c.

24 {
25 m_Strings.Clear();
26 m_Ints.Clear();
27 m_Floats.Clear();
28 m_Bools.Clear();
29 m_Vectors2.Clear();
30 }

References m_Bools, m_Floats, m_Ints, m_Strings, and m_Vectors2.

Referenced by ~JsonObject().

◆ GetJson()

string JsonObject::GetJson ( )
inlineprivate

Definition at line 85 of file JsonObject.c.

86 {
87 string name;
88 int i;
89
90 string jsn = "";
91 jsn += "{";
92
93 // Parse Strings
94 for (i = 0; i < m_Strings.Count(); ++i)
95 {
96 if (jsn.Length() > 1)
97 jsn += ",";
98
99 name = m_Strings.GetKey(i);
100 string value_str = m_Strings.GetElement(i);
101
102 jsn += "\"" + name + "\":\"" + value_str + "\"";
103 }
104
105 // Parse Ints
106 for (i = 0; i < m_Ints.Count(); ++i)
107 {
108 if (jsn.Length() > 1)
109 jsn += ",";
110
111 name = m_Ints.GetKey(i);
112 int value_int = m_Ints.GetElement(i);
113
114 jsn += "\"" + name + "\":" + value_int;
115 }
116
117 // Parse Floats
118 for (i = 0; i < m_Floats.Count(); ++i)
119 {
120 if (jsn.Length() > 1)
121 jsn += ",";
122
123 name = m_Floats.GetKey(i);
124 float value_flt = m_Floats.GetElement(i);
125
126 jsn += "\"" + name + "\":" + value_flt;
127 }
128
129 // Parse Bools
130 for (i = 0; i < m_Bools.Count(); ++i)
131 {
132 if (jsn.Length() > 1)
133 jsn += ",";
134
135 name = m_Bools.GetKey(i);
136
137 if (m_Bools.GetElement(i))
138 jsn += "\"" + name + "\":true";
139 else
140 jsn += "\"" + name + "\":false";
141 }
142
143 // Parse Vectors2
144 for (i = 0; i < m_Vectors2.Count(); ++i)
145 {
146 if (jsn.Length() > 1)
147 jsn += ",";
148
149 name = m_Vectors2.GetKey(i);
150 Vector2 value_vct = m_Vectors2.GetElement(i);
151
152 jsn += "\"" + name + "\":{\"x\":" + value_vct.x + ",\"y\":" + value_vct.y + "}";
153 }
154
155 jsn += "}";
156
157 return jsn;
158 }

References m_Bools, m_Floats, m_Ints, m_Strings, m_Vectors2, and name.

Member Data Documentation

◆ m_Bools

ref map<string, bool> JsonObject::m_Bools
private

Definition at line 6 of file JsonObject.c.

Referenced by AddBool(), Clear(), GetJson(), and JsonObject().

◆ m_Floats

ref map<string, float> JsonObject::m_Floats
private

Definition at line 5 of file JsonObject.c.

Referenced by AddFloat(), Clear(), GetJson(), and JsonObject().

◆ m_Ints

ref map<string, int> JsonObject::m_Ints
private

Definition at line 4 of file JsonObject.c.

Referenced by AddInt(), Clear(), GetJson(), and JsonObject().

◆ m_Strings

ref map<string, string> JsonObject::m_Strings
private

Definition at line 3 of file JsonObject.c.

Referenced by AddString(), Clear(), GetJson(), and JsonObject().

◆ m_Vectors2

ref map<string, ref Vector2> JsonObject::m_Vectors2
private

Definition at line 7 of file JsonObject.c.

Referenced by AddVector2(), Clear(), GetJson(), and JsonObject().


The documentation for this class was generated from the following file: