DayZ 1.24
Loading...
Searching...
No Matches
PluginFileHandler Class Reference
Collaboration diagram for PluginFileHandler:
[legend]

Protected Member Functions

int GetTextType (string text)
 
bool IsString (string text)
 
bool IsParam (string text)
 
bool IsArray (string text)
 
bool IsFloat (string text)
 
bool IsInt (string text)
 
bool IsBool (string text)
 
string ParseToValueString (string param_value)
 
float ParseToValueFloat (string param_value)
 
int ParseToValueInt (string param_value)
 
bool ParseToValueBool (string param_value)
 
array< ref CfgParamParseToValueArray (string param_value)
 

Private Member Functions

void PluginConfigHandler ()
 
override void OnInit ()
 
override string GetFileName ()
 
void LoadConfigFile ()
 
void SaveConfigToFile ()
 
CfgParam GetParamByName (string name, int cfg_type)
 
array< ref CfgParamGetAllParams ()
 
void ClearParams ()
 
void RemoveParamByName (string name)
 
void RenameParam (string name, string new_name)
 
bool ParamExist (string name)
 
string ParseParam (CfgParam param)
 
CfgParam ParseText (string text)
 
void PluginLocalHistoryBase ()
 
void ~PluginLocalHistoryBase ()
 
override void OnInit ()
 
override string GetFileName ()
 
void AddNewLine (string text)
 
TStringArray GetAllLines ()
 
TStringArray GetLastLine ()
 
void PluginLocalProfile ()
 
override string GetFileName ()
 
override void OnInit ()
 
bool LoadConfigFile ()
 
void SaveConfigToFile ()
 
bool IsTextArray (string text)
 
TStringArray ParseTextToParameter (string text)
 
TStringArray ParseTextToArray (string text, out TStringArray ret)
 
array< ref map< string, string > > ParseTextArrayToParameters (string text)
 
string LoadParameter (string param_name)
 
TStringArray LoadParameterArray (string param_name)
 
string LoadSubParameter (string param_name, int sub_array_index, string sub_param_name)
 
void SaveParameter (string param_name, string value, bool save_in_file=true)
 
void SaveParameterArray (string param_name, TStringArray value, bool save_in_file=true)
 
void SaveSubParameterInArray (string param_name, int sub_array_index, string sub_param_name, string sub_param_value, bool save_in_file=true)
 
void RenameParameter (string old_name, string new_name, bool save_in_file=true)
 
void RenameParameterArray (string old_name, string new_name, bool save_in_file=true)
 
void RemoveParameter (string name, bool save_in_file=true)
 
void RemoveParameterArray (string name, bool save_in_file=true)
 
void SetParameterString (string name, string value, bool save_in_file=true)
 
void SetParameterInt (string name, int value, bool save_in_file=true)
 
void SetParameterFloat (string name, float value, bool save_in_file=true)
 
void SetParameterBool (string name, bool value, bool save_in_file=true)
 
void SetParameterArray (string name, TStringArray value, bool save_in_file=true)
 
void SetSubParameterInArray (string param_name, int sub_array_index, string sub_param_name, string sub_param_value, bool save_in_file=true)
 
string GetParameterString (string name)
 
int GetParameterInt (string name)
 
float GetParameterFloat (string name)
 
bool GetParameterBool (string name)
 
TStringArray GetParameterArray (string name)
 
string GetSubParameterInArrayString (string param_name, int sub_array_index, string sub_param_name)
 
TStringArray GetAllSubParametersInArrayString (string param_name, string sub_param_name)
 

Private Attributes

ref array< ref CfgParamm_CfgParams
 
ref map< string, stringm_ConfigParams
 
ref map< string, ref TStringArraym_ConfigParamsArray
 
ref map< string, ref map< string, string > > m_ConfigParamsInArray
 
ref map< string, ref array< ref map< string, string > > > m_ConfigParamsArrayInArray
 

Detailed Description

Definition at line 1 of file PluginConfigHandler.c.

Constructor & Destructor Documentation

◆ ~PluginLocalHistoryBase()

void PluginFileHandler::~PluginLocalHistoryBase ( )
inlineprivate

Definition at line 8 of file PluginLocalHistoryBase.c.

9 {
10 }

Member Function Documentation

◆ AddNewLine()

void PluginFileHandler::AddNewLine ( string text)
inlineprivate

Definition at line 23 of file PluginLocalHistoryBase.c.

24 {
25 // replace newline to \\n
26 text.Replace("\n", "\\n");
27 m_FileContent.Insert(text);
28 SaveFile();
29 }

◆ ClearParams()

void PluginFileHandler::ClearParams ( )
inlineprivate

Definition at line 69 of file PluginConfigHandler.c.

70 {
71 m_CfgParams.Clear();
72 }
ref array< ref CfgParam > m_CfgParams

◆ GetAllLines()

TStringArray PluginFileHandler::GetAllLines ( )
inlineprivate

Definition at line 31 of file PluginLocalHistoryBase.c.

32 {
33 // replace \\n to new line
35 for (int i = 0; i < m_FileContent.Count(); i++)
36 {
37 string history_record = m_FileContent.Get(i);
38 history_record.Replace("\\n", "\n");
40 }
41 return console_history;
42 }
array< string > TStringArray
Definition EnScript.c:666

◆ GetAllParams()

array< ref CfgParam > PluginFileHandler::GetAllParams ( )
inlineprivate

Definition at line 64 of file PluginConfigHandler.c.

65 {
66 return m_CfgParams;
67 }

◆ GetAllSubParametersInArrayString()

TStringArray PluginFileHandler::GetAllSubParametersInArrayString ( string param_name,
string sub_param_name )
inlineprivate

Definition at line 514 of file PluginLocalProfile.c.

515 {
517
519 {
521
523
524 for (int i = 0; i < arrays_in_parameter.Count(); ++i)
525 {
527
528 string sub_param = STRING_EMPTY;
529
530 if (sub_parameter.Contains(sub_param_name))
532
533 ret_value.Insert(sub_param);
534 }
535 }
536
537 return ret_value;
538 }
ref map< string, ref array< ref map< string, string > > > m_ConfigParamsArrayInArray
const string STRING_EMPTY
Definition constants.c:54

References STRING_EMPTY.

◆ GetFileName() [1/3]

override string PluginFileHandler::GetFileName ( )
inlineprivate

Definition at line 17 of file PluginConfigHandler.c.

18 {
20 }
const string CFG_FILE_USER_PROFILE
Definition constants.c:230

References CFG_FILE_USER_PROFILE.

Referenced by PluginBase::LoadFile(), and PluginBase::SaveFile().

◆ GetFileName() [2/3]

override string PluginFileHandler::GetFileName ( )
inlineprivate

Definition at line 17 of file PluginLocalHistoryBase.c.

18 {
19 Error("Cannot call GetFileName on Base class PluginLocalHistoryBase");
20 return STRING_EMPTY;
21 }
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

References Error(), and STRING_EMPTY.

◆ GetFileName() [3/3]

override string PluginFileHandler::GetFileName ( )
inlineprivate

Definition at line 16 of file PluginLocalProfile.c.

17 {
19 }

References CFG_FILE_USER_PROFILE.

◆ GetLastLine()

TStringArray PluginFileHandler::GetLastLine ( )
inlineprivate

Definition at line 44 of file PluginLocalHistoryBase.c.

45 {
46 int count = m_FileContent.Count();
47 string ret = "";
48
49 if (count > 0)
50 ret = m_FileContent.Get(count - 1);
51
52 return NULL;
53 }

◆ GetParamByName()

CfgParam PluginFileHandler::GetParamByName ( string name,
int cfg_type )
inlineprivate

Definition at line 46 of file PluginConfigHandler.c.

47 {
49
50 for (int i = 0; i < m_CfgParams.Count(); ++i)
51 {
52 param = m_CfgParams.Get(i);
53
54 if (param.GetName() == name)
55 return param;
56 }
57
58 // cfg_type == -1 returns NULL
60 m_CfgParams.Insert(param);
61 return param;
62 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
static CfgParam CreateParam(string name, int cfg_type)
Definition CfgParam.c:38

References CfgParam::CreateParam(), and name.

◆ GetParameterArray()

TStringArray PluginFileHandler::GetParameterArray ( string name)
inlineprivate

Definition at line 482 of file PluginLocalProfile.c.

483 {
485
486 if (m_ConfigParamsArray.Contains(name))
488 else
489 {
492 }
493
494 return ret_value;
495 }
void SetParameterArray(string name, TStringArray value, bool save_in_file=true)
ref map< string, ref TStringArray > m_ConfigParamsArray

References name.

◆ GetParameterBool()

bool PluginFileHandler::GetParameterBool ( string name)
inlineprivate

Definition at line 465 of file PluginLocalProfile.c.

466 {
468 bool ret_value = false;
469
470 if (loaded_param != "")
471 {
472 int v = loaded_param.ToInt();
473 if (v == 1)
474 ret_value = true;
475 }
476 else
478
479 return ret_value;
480 }
void SetParameterBool(string name, bool value, bool save_in_file=true)
string LoadParameter(string param_name)

References name.

◆ GetParameterFloat()

float PluginFileHandler::GetParameterFloat ( string name)
inlineprivate

Definition at line 452 of file PluginLocalProfile.c.

453 {
455 float ret_value = 0;
456
457 if (loaded_param != "")
458 ret_value = loaded_param.ToFloat();
459 else
461
462 return ret_value;
463 }
void SetParameterFloat(string name, float value, bool save_in_file=true)

References name.

◆ GetParameterInt()

int PluginFileHandler::GetParameterInt ( string name)
inlineprivate

Definition at line 439 of file PluginLocalProfile.c.

440 {
442 int ret_value = 0;
443
444 if (loaded_param != "")
445 ret_value = loaded_param.ToInt();
446 else
448
449 return ret_value;
450 }
void SetParameterInt(string name, int value, bool save_in_file=true)

References name.

◆ GetParameterString()

string PluginFileHandler::GetParameterString ( string name)
inlineprivate

Definition at line 421 of file PluginLocalProfile.c.

422 {
424 string ret_value = STRING_EMPTY;
425
426 if (loaded_param != "")
427 {
429 loaded_param.Split("\"", arr);
430 if (arr.Count() > 0)
431 ret_value = arr.Get(0);
432 }
433 else
435
436 return ret_value;
437 }
void SetParameterString(string name, string value, bool save_in_file=true)

References name, and STRING_EMPTY.

◆ GetSubParameterInArrayString()

string PluginFileHandler::GetSubParameterInArrayString ( string param_name,
int sub_array_index,
string sub_param_name )
inlineprivate

Definition at line 497 of file PluginLocalProfile.c.

498 {
500 string ret_value = STRING_EMPTY;
501
503
504 if (loaded_param != "")
505 {
506 arr.Clear();
507 loaded_param.Split("\"", arr);
508 ret_value = arr.Get(1);
509 }
510
511 return ret_value;
512 }
string LoadSubParameter(string param_name, int sub_array_index, string sub_param_name)

References STRING_EMPTY.

◆ GetTextType()

int PluginFileHandler::GetTextType ( string text)
inlineprotected

Definition at line 265 of file PluginConfigHandler.c.

266 {
267 int lenght = text.Length();
268
269 // Check Array
270 int pos1 = text.IndexOf("{");
271 if (pos1 == 0 && text.Substring(lenght - 1, 1) == "}")
272 return CFG_TYPE_ARRAY;
273
274 // Check String
275 pos1 = text.IndexOf("\"");
276
277 if (pos1 == 0 && text.Substring(lenght - 1, 1) == "\"")
278 {
279 string string_text = text.Substring(1, lenght - 2);
280 if (string_text.IndexOf("\"") == -1)
281 return CFG_TYPE_STRING;
282 }
283
284 // Check Param
285 pos1 = text.IndexOf("=");
286 if (pos1 > -1)
287 return CFG_TYPE_PARAM;
288
289 // Check Param True
290 pos1 = text.IndexOf("true");
291 if (lenght == 4 && pos1 > -1)
292 return CFG_TYPE_BOOL;
293
294 // Check Param False
295 pos1 = text.IndexOf("false");
296 if (lenght == 5 && pos1 > -1)
297 return CFG_TYPE_BOOL;
298
299 // Check Param Float
300 pos1 = text.IndexOf(".");
301 if (pos1 > -1)
302 return CFG_TYPE_FLOAT;
303
304 // Is Int
305 return CFG_TYPE_INT;
306 }
const int CFG_TYPE_BOOL
Definition CfgParam.c:4
const int CFG_TYPE_ARRAY
Definition CfgParam.c:5
const int CFG_TYPE_PARAM
Definition CfgParam.c:6
const int CFG_TYPE_INT
Definition CfgParam.c:2
const int CFG_TYPE_STRING
Definition CfgParam.c:1
const int CFG_TYPE_FLOAT
Definition CfgParam.c:3

References CFG_TYPE_ARRAY, CFG_TYPE_BOOL, CFG_TYPE_FLOAT, CFG_TYPE_INT, CFG_TYPE_PARAM, and CFG_TYPE_STRING.

◆ IsArray()

bool PluginFileHandler::IsArray ( string text)
inlineprotected

Definition at line 324 of file PluginConfigHandler.c.

325 {
327 return true;
328
329 return false;
330 }
int GetTextType(string text)

References CFG_TYPE_ARRAY.

◆ IsBool()

bool PluginFileHandler::IsBool ( string text)
inlineprotected

Definition at line 348 of file PluginConfigHandler.c.

349 {
351 return true;
352
353 return false;
354 }

References CFG_TYPE_BOOL.

◆ IsFloat()

bool PluginFileHandler::IsFloat ( string text)
inlineprotected

Definition at line 332 of file PluginConfigHandler.c.

333 {
335 return true;
336
337 return false;
338 }

References CFG_TYPE_FLOAT.

◆ IsInt()

bool PluginFileHandler::IsInt ( string text)
inlineprotected

Definition at line 340 of file PluginConfigHandler.c.

341 {
343 return true;
344
345 return false;
346 }

References CFG_TYPE_INT.

◆ IsParam()

bool PluginFileHandler::IsParam ( string text)
inlineprotected

Definition at line 316 of file PluginConfigHandler.c.

317 {
319 return true;
320
321 return false;
322 }

References CFG_TYPE_PARAM.

◆ IsString()

bool PluginFileHandler::IsString ( string text)
inlineprotected

Definition at line 308 of file PluginConfigHandler.c.

309 {
311 return true;
312
313 return false;
314 }

References CFG_TYPE_STRING.

◆ IsTextArray()

bool PluginFileHandler::IsTextArray ( string text)
inlineprivate

Definition at line 191 of file PluginLocalProfile.c.

192 {
193 if (text.Length() > 0 && text.Substring(0, 1) == "{")
194 {
195 if (text.Substring(text.Length() - 1, 1) == "}")
196 return true;
197 }
198
199 return false;
200 }

◆ LoadConfigFile() [1/2]

void PluginFileHandler::LoadConfigFile ( )
inlineprivate

Definition at line 22 of file PluginConfigHandler.c.

23 {
24 LoadFile();
25
26 m_CfgParams.Clear();
27
28 for (int j = 0; j < m_FileContent.Count(); j++)
29 m_CfgParams.Insert(ParseText(m_FileContent.Get(j)));
30 }
CfgParam ParseText(string text)

◆ LoadConfigFile() [2/2]

bool PluginFileHandler::LoadConfigFile ( )
inlineprivate

Definition at line 28 of file PluginLocalProfile.c.

29 {
30 TStringArray file_content = GetFileContent();
31
32 string line_content = "";
33 string param_name = "";
34 string param_value = "";
36 int pos_sep = -1;
37
38 for (int i = 0; i < file_content.Count(); ++i)
39 {
41
43
44 if (param_content.Count() == 0)
45 {
46 PrintString(GetFileName() + "(" + i.ToString() + "): Error in config -> Maybe missing '=' !");
47 return false;
48 }
49
52
53 //{{name = apple, damage = 0.5, quantity = 2},{name = banana, damage = 0.5, quantity = 2}}
54
57 //{name = apple, damage = 0.5, quantity = 2}
58 //{name = banana, damage = 0.5, quantity = 2}
59
61
62 if (array_items.Count() > 0)
63 {
65
66 for (int j = 0; j < array_items.Count(); ++j)
67 {
68 string array_content = array_items.Get(j);
69 //{name = apple, damage = 0.5, quantity = 2}
70
71 array_content_raw.Clear();
72
74 //name = apple
75 //damage = 0.5
76 //quantity = 2
77
78 if (array_content_raw.Count() > 0)
79 {
82
85
86 for (int k = 0; k < array_content_raw.Count(); ++k)
87 {
88 string params = array_content_raw.Get(k);
90
91 if (p.Count() == 2)
92 parameters.Set(p.Get(0), p.Get(1));
93 }
94
96 }
97 }
98 }
99 else
101 }
102
103 return true;
104 }
TStringArray ParseTextToArray(string text, out TStringArray ret)
override string GetFileName()
TStringArray ParseTextToParameter(string text)
ref map< string, string > m_ConfigParams
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
Definition EnScript.c:344

References PluginLocalProfile::GetFileName(), and PrintString().

◆ LoadParameter()

string PluginFileHandler::LoadParameter ( string param_name)
inlineprivate

Definition at line 280 of file PluginLocalProfile.c.

281 {
282 string ret_value = STRING_EMPTY;
283
284 if (m_ConfigParams.Contains(param_name))
286
287 return ret_value;
288 }

References STRING_EMPTY.

◆ LoadParameterArray()

TStringArray PluginFileHandler::LoadParameterArray ( string param_name)
inlineprivate

Definition at line 290 of file PluginLocalProfile.c.

291 {
292 if (m_ConfigParamsArray.Contains(param_name))
294
295 return NULL;
296 }

◆ LoadSubParameter()

string PluginFileHandler::LoadSubParameter ( string param_name,
int sub_array_index,
string sub_param_name )
inlineprivate

Definition at line 298 of file PluginLocalProfile.c.

299 {
300 string ret_value = STRING_EMPTY;
303
305 {
307
308 if (sub_arrays != NULL)
309 {
310 if (sub_array_index < sub_arrays.Count())
311 {
313
314 if (param.Contains(sub_param_name))
316 }
317 }
318 }
319
320 return ret_value;
321 }

References STRING_EMPTY.

◆ OnInit() [1/3]

override void PluginFileHandler::OnInit ( )
inlineprivate

Definition at line 12 of file PluginConfigHandler.c.

13 {
14 super.OnInit();
15 }

◆ OnInit() [2/3]

override void PluginFileHandler::OnInit ( )
inlineprivate

Definition at line 12 of file PluginLocalHistoryBase.c.

13 {
14 super.OnInit();
15 }

◆ OnInit() [3/3]

override void PluginFileHandler::OnInit ( )
inlineprivate

Definition at line 21 of file PluginLocalProfile.c.

22 {
23 super.OnInit();
24
26 }

◆ ParamExist()

bool PluginFileHandler::ParamExist ( string name)
inlineprivate

Definition at line 102 of file PluginConfigHandler.c.

103 {
105
106 for (int i = 0; i < m_CfgParams.Count(); ++i)
107 {
108 param = m_CfgParams.Get(i);
109
110 if (param.GetName() == name)
111 return true;
112 }
113
114 return false;
115 }

References name.

◆ ParseParam()

string PluginFileHandler::ParseParam ( CfgParam param)
inlineprivate

Definition at line 117 of file PluginConfigHandler.c.

118 {
119 string text = STRING_EMPTY;
120
121 if (param.GetName() != STRING_EMPTY)
122 text += param.GetName() + "=";
123
124 switch (param.GetType())
125 {
126 case CFG_TYPE_ARRAY:
127 {
128 CfgParamArray param_array = CfgParamArray.Cast(param);
130
131 text += "{";
132
133 for (int i = 0; i < params.Count(); ++i)
134 {
135 if (i > 0)
136 text += ",";
137
138 text += ParseParam(params.Get(i));
139 }
140
141 text += "}";
142
143 break;
144 }
145 case CFG_TYPE_STRING:
146 {
147 CfgParamString param_string = CfgParamString.Cast(param);
148 text += "\"" + param_string.GetValue() + "\"";
149
150 break;
151 }
152 case CFG_TYPE_INT:
153 {
154 CfgParamInt param_int = CfgParamInt.Cast(param);
155 text += param_int.GetValue().ToString();
156
157 break;
158 }
159 case CFG_TYPE_FLOAT:
160 {
161 CfgParamFloat param_float = CfgParamFloat.Cast(param);
162 string s = param_float.GetValue().ToString();
163
164 if (s.IndexOf(".") == -1)
165 s += ".0";
166
167 text += s;
168
169 break;
170 }
171 case CFG_TYPE_BOOL:
172 {
173 CfgParamBool param_bool = CfgParamBool.Cast(param);
174
175 if (param_bool.GetValue())
176 text += "true";
177 else
178 text += "false";
179
180 break;
181 }
182 }
183
184 return text;
185 }
string ParseParam(CfgParam param)

References CFG_TYPE_ARRAY, CFG_TYPE_BOOL, CFG_TYPE_FLOAT, CFG_TYPE_INT, CFG_TYPE_STRING, and STRING_EMPTY.

◆ ParseText()

CfgParam PluginFileHandler::ParseText ( string text)
inlineprivate

Definition at line 187 of file PluginConfigHandler.c.

188 {
189 string param_name = STRING_EMPTY;
190 string param_value = text.Trim();;
192
193 //Log("ParseText -> text_type: "+itoa(text_type));
194
196 {
197 int pos = param_value.IndexOf("=");
198
199 if (pos > 0)
200 {
201 param_name = param_value.Substring(0, pos).Trim();
202 int pos_end = param_value.Length() - pos;
203 param_value = param_value.Substring(pos + 1, pos_end - 1).Trim();
204
205 //Log("ParseText -> param -> "+param_name+" = "+param_value);
206
208 param.SetName(param_name);
209
210 return param;
211 }
212 }
213 else if (text_type == CFG_TYPE_ARRAY)
214 {
215 //Log("ParseText -> array -> "+param_name+" = "+param_value);
216
217 CfgParamArray param_array = new CfgParamArray(param_name);
219 param_array.SetParams(array_params);
220
221 return param_array;
222 }
223 else if (text_type == CFG_TYPE_STRING)
224 {
225 //Log("ParseText -> string -> "+param_value);
226
227 CfgParamString param_string = new CfgParamString(param_name);
229
230 return param_string;
231 }
232 else if (text_type == CFG_TYPE_INT)
233 {
234 //Log("ParseText -> int -> "+param_name+" = "+param_value);
235
236 CfgParamInt param_int = new CfgParamInt(param_name);
238
239 return param_int;
240 }
241 else if (text_type == CFG_TYPE_FLOAT)
242 {
243 //Log("ParseText -> float -> "+param_name+" = "+param_value);
244
245 CfgParamFloat param_float = new CfgParamFloat(param_name);
247
248 return param_float;
249 }
250 else if (text_type == CFG_TYPE_BOOL)
251 {
252 //Log("ParseText -> bool -> "+param_name+" = "+param_value);
253
254 CfgParamBool param_bool = new CfgParamBool(param_name);
256
257 return param_bool;
258 }
259
260 //Log("ParseText -> none -> "+param_name+" = "+param_value);
261
262 return NULL;
263 }
float ParseToValueFloat(string param_value)
string ParseToValueString(string param_value)
int ParseToValueInt(string param_value)
array< ref CfgParam > ParseToValueArray(string param_value)
bool ParseToValueBool(string param_value)

References CFG_TYPE_ARRAY, CFG_TYPE_BOOL, CFG_TYPE_FLOAT, CFG_TYPE_INT, CFG_TYPE_PARAM, CFG_TYPE_STRING, and STRING_EMPTY.

◆ ParseTextArrayToParameters()

array< ref map< string, string > > PluginFileHandler::ParseTextArrayToParameters ( string text)
inlineprivate

Definition at line 255 of file PluginLocalProfile.c.

256 {
259
261
263
264 for (int i = 0; i < array_items.Count(); ++i)
265 {
266 string param = array_items.Get(i);
268
269 string param_name = t_param.Get(0);
270 string param_value = t_param.Get(1);
271
273 }
274
275 ret.Insert(ret_param);
276
277 return ret;
278 }

◆ ParseTextToArray()

TStringArray PluginFileHandler::ParseTextToArray ( string text,
out TStringArray ret )
inlineprivate

Definition at line 225 of file PluginLocalProfile.c.

226 {
227 if (!IsTextArray(text))
228 return NULL;
229
230 text = text.Substring(1, text.Length() - 2);
231
232 int pos_array_start = text.IndexOf("{");
233 int pos_array_end = text.IndexOf("}");
234
235 if (pos_array_start > -1 && pos_array_end > -1)
236 {
237 while (true)
238 {
240 ret.Insert(array_value);
241
242 pos_array_start = text.IndexOfFrom(pos_array_end, "{");
243 pos_array_end = text.IndexOfFrom(pos_array_start, "}");
244
245 if (pos_array_start == -1)
246 break;
247 }
248 }
249 else
250 text.Split(",", ret);
251
252 return ret;
253 }
bool IsTextArray(string text)

◆ ParseTextToParameter()

TStringArray PluginFileHandler::ParseTextToParameter ( string text)
inlineprivate

Definition at line 202 of file PluginLocalProfile.c.

203 {
205
206 int pos = text.IndexOf("=");
207
208 if (pos > 0)
209 {
210 string param_name = text.Substring(0, pos).Trim();
211 int pos_end = text.Length() - pos;
212 string param_value = text.Substring(pos + 1, pos_end - 1).Trim();
213
214 int lenght = param_value.Length();
215 if (lenght > 1 && param_value.Substring(0, 1) == "\"" && param_value.Substring(lenght - 1, 1) == "\"")
216 param_value = param_value.Substring(1, lenght - 2);
217
218 ret.Insert(param_name);
219 ret.Insert(param_value);
220 }
221
222 return ret;
223 }

◆ ParseToValueArray()

array< ref CfgParam > PluginFileHandler::ParseToValueArray ( string param_value)
inlineprotected

Definition at line 379 of file PluginConfigHandler.c.

380 {
382
384
385 array<int> a = new array<int>;
386 array<int> b = new array<int>;
387
388 int pos_a = 0;
389 int pos_b = 0;
390 int element = 0;
391 int value_start = 0;
392 int value_end = 0;
393
394 while (pos_a > -1 || pos_b > -1)
395 {
396 pos_a = param_value.IndexOfFrom(pos_a, "{");
397 if (pos_a > -1)
398 {
399 a.Insert(pos_a);
400 pos_a++;
401 }
402
403 pos_b = param_value.IndexOfFrom(pos_b, "}");
404 if (pos_b > -1)
405 {
406 b.Insert(pos_b);
407 pos_b++;
408 }
409 }
410
411 pos_a = 0;
412 pos_b = 0;
413
414 for (pos_a = 0; pos_a < a.Count(); ++pos_a)
415 {
416 if (a.Get(pos_a) > b.Get(pos_b))
417 {
418 element--;
419
420 if (element <= 1)
421 {
422 value_end = b.Get(pos_b) - value_start + 1;
423
424 //Log("1 -> "+substr(param_value, value_start, value_end))
425
426 strings.Insert(param_value.Substring(value_start, value_end));
427
428 value_start = b.Get(pos_b) + 1;
429 }
430
431 pos_a--;
432 pos_b++;
433 }
434 else if (a.Get(pos_a) < b.Get(pos_b))
435 {
436 if (pos_a == a.Count() - 1 && pos_b < b.Count() - 1)
437 {
438 element--;
439
440 if (element == 0)
441 {
442 value_end = b.Get(pos_b) - value_start;
443
444 //Log("2 -> "+substr(param_value, value_start + 1, value_end))
445
446 strings.Insert(param_value.Substring(value_start + 1, value_end));
447
448 value_start = b.Get(pos_b) + 1;
449 }
450
451 pos_a--;
452 pos_b++;
453 }
454 else
455 {
456 element++;
457
458 if (element == 2)
459 value_start = a.Get(pos_a);
460 }
461 }
462 }
463
464 //Log(param_value+" => "+itoa(a.Count())+" / "+itoa(b.Count())+" count: "+itoa(strings.Count()));
465
466 if (strings.Count() == 0)
467 {
468 //Log(param_value+" -> ZERO {}");
469
470 string param_value_content = param_value.Substring(1, param_value.Length() - 2);
471
472 //Log(param_value+" -> Trimmed -> "+param_value_content);
473
474 param_value_content.Split(",", strings);
475 }
476
477 for (int i = 0; i < strings.Count(); ++i)
478 {
479 string str = strings.Get(i);
480
481 //Log("To Parse => "+str);
482
484
485 param_parent.Insert(param);
486 }
487
488 return param_parent;
489 }

◆ ParseToValueBool()

bool PluginFileHandler::ParseToValueBool ( string param_value)
inlineprotected

Definition at line 371 of file PluginConfigHandler.c.

372 {
373 if (param_value.Contains("true"))
374 return true;
375
376 return false;
377 }

◆ ParseToValueFloat()

float PluginFileHandler::ParseToValueFloat ( string param_value)
inlineprotected

Definition at line 361 of file PluginConfigHandler.c.

362 {
363 return param_value.ToFloat();
364 }

◆ ParseToValueInt()

int PluginFileHandler::ParseToValueInt ( string param_value)
inlineprotected

Definition at line 366 of file PluginConfigHandler.c.

367 {
368 return param_value.ToInt();
369 }

◆ ParseToValueString()

string PluginFileHandler::ParseToValueString ( string param_value)
inlineprotected

Definition at line 356 of file PluginConfigHandler.c.

357 {
358 return param_value.Substring(1, param_value.Length() - 2);
359 }

◆ PluginConfigHandler()

void PluginFileHandler::PluginConfigHandler ( )
inlineprivate

Definition at line 5 of file PluginConfigHandler.c.

◆ PluginLocalHistoryBase()

void PluginFileHandler::PluginLocalHistoryBase ( )
inlineprivate

Definition at line 3 of file PluginLocalHistoryBase.c.

4 {
5 m_ReadOnly = false;
6 }

◆ PluginLocalProfile()

void PluginFileHandler::PluginLocalProfile ( )
inlineprivate

◆ RemoveParamByName()

void PluginFileHandler::RemoveParamByName ( string name)
inlineprivate

Definition at line 74 of file PluginConfigHandler.c.

75 {
76 for (int i = 0; i < m_CfgParams.Count(); ++i)
77 {
79
80 if (param.GetName() == name)
81 {
82 m_CfgParams.Remove(i);
83 return;
84 }
85 }
86 }

References name.

◆ RemoveParameter()

void PluginFileHandler::RemoveParameter ( string name,
bool save_in_file = true )
inlineprivate

Definition at line 374 of file PluginLocalProfile.c.

375 {
376 m_ConfigParams.Remove(name);
377
378 if (save_in_file)
380 }

References name.

◆ RemoveParameterArray()

void PluginFileHandler::RemoveParameterArray ( string name,
bool save_in_file = true )
inlineprivate

Definition at line 382 of file PluginLocalProfile.c.

383 {
385
386 if (save_in_file)
388 }

References name.

◆ RenameParam()

void PluginFileHandler::RenameParam ( string name,
string new_name )
inlineprivate

Definition at line 88 of file PluginConfigHandler.c.

89 {
90 for (int i = 0; i < m_CfgParams.Count(); ++i)
91 {
93
94 if (param.GetName() == name)
95 {
96 param.SetName(new_name);
97 return;
98 }
99 }
100 }

References name.

◆ RenameParameter()

void PluginFileHandler::RenameParameter ( string old_name,
string new_name,
bool save_in_file = true )
inlineprivate

Definition at line 352 of file PluginLocalProfile.c.

353 {
354 if (m_ConfigParams.Contains(old_name))
355 {
356 m_ConfigParams.ReplaceKey(old_name, new_name);
357
358 if (save_in_file)
360 }
361 }

◆ RenameParameterArray()

void PluginFileHandler::RenameParameterArray ( string old_name,
string new_name,
bool save_in_file = true )
inlineprivate

Definition at line 363 of file PluginLocalProfile.c.

364 {
365 if (m_ConfigParamsArray.Contains(old_name))
366 {
368
369 if (save_in_file)
371 }
372 }

◆ SaveConfigToFile() [1/2]

void PluginFileHandler::SaveConfigToFile ( )
inlineprivate

Definition at line 32 of file PluginConfigHandler.c.

33 {
34 ClearFileNoSave();
35
36 for (int i = 0; i < m_CfgParams.Count(); ++i)
37 {
38 string s = ParseParam(m_CfgParams.Get(i));
39
40 m_FileContent.Insert(s);
41 }
42
43 SaveFile();
44 }

◆ SaveConfigToFile() [2/2]

void PluginFileHandler::SaveConfigToFile ( )
inlineprivate

Definition at line 106 of file PluginLocalProfile.c.

107 {
108 ClearFileNoSave();
109
110 int i;
111 int j;
112 int k;
113
114 string variable_name;
115 string variable_value;
116 string text;
118
119 for (i = 0; i < m_ConfigParams.Count(); ++i)
120 {
122 variable_value = m_ConfigParams.GetElement(i);
123
125
126 AddNewLineNoSave(text);
127 }
128
129 for (i = 0; i < m_ConfigParamsArray.Count(); ++i)
130 {
133
135 continue;
136
137 text = variable_name + " = {";
138
139 for (j = 0; j < variable_array.Count(); ++j)
140 {
141 if (j > 0)
142 text += ",";
143
144 text += variable_array.Get(j);
145 }
146
147 text += "}";
148
149 AddNewLineNoSave(text);
150 }
151
152 for (i = 0; i < m_ConfigParamsArrayInArray.Count(); ++i)
153 {
156
157 text = variable_name + " = {";
158
159 if (variable_param != NULL)
160 {
161 for (j = 0; j < variable_param.Count(); ++j)
162 {
163 if (j > 0)
164 text += ",";
165 text += "{";
166
168 for (k = 0; k < params.Count(); ++k)
169 {
170 if (k > 0)
171 text += ",";
172
173 string param_name = params.GetKey(k);
174 string param_value = params.GetElement(k);
175
176 text += param_name + "=" + param_value;
177 }
178
179 text += "}";
180 }
181 }
182
183 text += "}";
184
185 AddNewLineNoSave(text);
186 }
187
188 SaveFile();
189 }

◆ SaveParameter()

void PluginFileHandler::SaveParameter ( string param_name,
string value,
bool save_in_file = true )
inlineprivate

Definition at line 323 of file PluginLocalProfile.c.

324 {
325 if (param_name == "" || param_name == "scene_editor_scene")
326 Log("SaveParameter: " + param_name + " = " + value, "");
327
329
330 if (save_in_file)
332 }
class LogTemplates Log(string message, LogTemplateID template_id=0)
Creates debug log (optional) from LogTemplate which are registred.

References Log().

◆ SaveParameterArray()

void PluginFileHandler::SaveParameterArray ( string param_name,
TStringArray value,
bool save_in_file = true )
inlineprivate

Definition at line 334 of file PluginLocalProfile.c.

335 {
337
338 if (save_in_file)
340 }

◆ SaveSubParameterInArray()

void PluginFileHandler::SaveSubParameterInArray ( string param_name,
int sub_array_index,
string sub_param_name,
string sub_param_value,
bool save_in_file = true )
inlineprivate

◆ SetParameterArray()

void PluginFileHandler::SetParameterArray ( string name,
TStringArray value,
bool save_in_file = true )
inlineprivate

Definition at line 411 of file PluginLocalProfile.c.

412 {
414 }
void SaveParameterArray(string param_name, TStringArray value, bool save_in_file=true)

References name.

◆ SetParameterBool()

void PluginFileHandler::SetParameterBool ( string name,
bool value,
bool save_in_file = true )
inlineprivate

Definition at line 406 of file PluginLocalProfile.c.

407 {
408 SaveParameter(name, value.ToString(), save_in_file);
409 }
void SaveParameter(string param_name, string value, bool save_in_file=true)

References name.

◆ SetParameterFloat()

void PluginFileHandler::SetParameterFloat ( string name,
float value,
bool save_in_file = true )
inlineprivate

Definition at line 401 of file PluginLocalProfile.c.

402 {
403 SaveParameter(name, value.ToString(), save_in_file);
404 }

References name.

◆ SetParameterInt()

void PluginFileHandler::SetParameterInt ( string name,
int value,
bool save_in_file = true )
inlineprivate

Definition at line 396 of file PluginLocalProfile.c.

397 {
398 SaveParameter(name, value.ToString(), save_in_file);
399 }

References name.

◆ SetParameterString()

void PluginFileHandler::SetParameterString ( string name,
string value,
bool save_in_file = true )
inlineprivate

Definition at line 390 of file PluginLocalProfile.c.

391 {
392 string s = "\"" + value + "\"";
394 }

References name.

◆ SetSubParameterInArray()

void PluginFileHandler::SetSubParameterInArray ( string param_name,
int sub_array_index,
string sub_param_name,
string sub_param_value,
bool save_in_file = true )
inlineprivate

Definition at line 416 of file PluginLocalProfile.c.

417 {
419 }
void SaveSubParameterInArray(string param_name, int sub_array_index, string sub_param_name, string sub_param_value, bool save_in_file=true)

Member Data Documentation

◆ m_CfgParams

ref array<ref CfgParam> PluginFileHandler::m_CfgParams
private

Definition at line 3 of file PluginConfigHandler.c.

◆ m_ConfigParams

ref map<string, string> PluginFileHandler::m_ConfigParams
private

Definition at line 3 of file PluginLocalProfile.c.

◆ m_ConfigParamsArray

ref map<string, ref TStringArray> PluginFileHandler::m_ConfigParamsArray
private

Definition at line 4 of file PluginLocalProfile.c.

◆ m_ConfigParamsArrayInArray

ref map<string, ref array<ref map<string, string> > > PluginFileHandler::m_ConfigParamsArrayInArray
private

Definition at line 6 of file PluginLocalProfile.c.

◆ m_ConfigParamsInArray

ref map<string, ref map<string, string> > PluginFileHandler::m_ConfigParamsInArray
private

Definition at line 5 of file PluginLocalProfile.c.


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