12 override void OnInit()
17 override string GetFileName()
28 for (
int j = 0; j < m_FileContent.Count(); j++ )
30 m_CfgParams.Insert( ParseText(m_FileContent.Get(j)) );
34 void SaveConfigToFile()
38 for (
int i = 0; i < m_CfgParams.Count(); ++i )
40 string s = ParseParam(m_CfgParams.Get(i));
42 m_FileContent.Insert(s);
52 for (
int i = 0; i < m_CfgParams.Count(); ++i )
54 param = m_CfgParams.Get(i);
56 if ( param.GetName() ==
name )
64 m_CfgParams.Insert(param);
78 void RemoveParamByName(
string name )
80 for (
int i = 0; i < m_CfgParams.Count(); ++i )
84 if ( param.GetName() ==
name )
86 m_CfgParams.Remove( i );
92 void RenameParam(
string name,
string new_name )
94 for (
int i = 0; i < m_CfgParams.Count(); ++i )
98 if ( param.GetName() ==
name )
100 param.SetName( new_name );
106 bool ParamExist(
string name)
110 for (
int i = 0; i < m_CfgParams.Count(); ++i )
112 param = m_CfgParams.Get(i);
114 if ( param.GetName() ==
name )
129 text += param.GetName()+
"=";
132 switch ( param.GetType() )
136 CfgParamArray param_array = CfgParamArray.Cast( param );
141 for (
int i = 0; i < params.Count(); ++i )
148 text += ParseParam(params.Get(i));
157 CfgParamString param_string = CfgParamString.Cast( param );
158 text +=
"\""+param_string.GetValue()+
"\"";
164 CfgParamInt param_int = CfgParamInt.Cast( param );
165 text += param_int.GetValue().ToString();
171 CfgParamFloat param_float = CfgParamFloat.Cast( param );
172 string s = param_float.GetValue().ToString();
174 if ( s.IndexOf(
".") == -1 )
185 CfgParamBool param_bool = CfgParamBool.Cast( param );
187 if ( param_bool.GetValue() )
206 string param_value = text.Trim();;
207 int text_type = GetTextType(param_value);
213 int pos = param_value.IndexOf(
"=");
217 param_name = param_value.Substring(0, pos).Trim();
218 int pos_end = param_value.Length() - pos;
219 param_value = param_value.Substring(pos + 1, pos_end - 1).Trim();
223 CfgParam param = ParseText(param_value);
224 param.SetName(param_name);
233 CfgParamArray param_array =
new CfgParamArray(param_name);
235 param_array.SetParams(array_params);
243 CfgParamString param_string =
new CfgParamString(param_name);
244 param_string.SetValue( ParseToValueString(param_value) );
252 CfgParamInt param_int =
new CfgParamInt(param_name);
253 param_int.SetValue( ParseToValueInt(param_value) );
261 CfgParamFloat param_float =
new CfgParamFloat(param_name);
262 param_float.SetValue( ParseToValueFloat(param_value) );
270 CfgParamBool param_bool =
new CfgParamBool(param_name);
271 param_bool.SetValue( ParseToValueBool(param_value) );
281 protected int GetTextType(
string text)
283 int lenght = text.Length();
286 int pos1 = text.IndexOf(
"{");
287 if ( pos1 == 0 && text.Substring(lenght - 1, 1) ==
"}" )
293 pos1 = text.IndexOf(
"\"");
295 if ( pos1 == 0 && text.Substring(lenght - 1, 1) ==
"\"" )
297 string string_text = text.Substring(1, lenght - 2);
298 if ( string_text.IndexOf(
"\"") == -1 )
305 pos1 = text.IndexOf(
"=");
312 pos1 = text.IndexOf(
"true");
313 if ( lenght == 4 && pos1 > -1 )
319 pos1 = text.IndexOf(
"false");
320 if ( lenght == 5 && pos1 > -1 )
326 pos1 = text.IndexOf(
".");
336 protected bool IsString(
string text)
346 protected bool IsParam(
string text)
356 protected bool IsArray(
string text)
366 protected bool IsFloat(
string text)
376 protected bool IsInt(
string text)
386 protected bool IsBool(
string text)
396 protected string ParseToValueString(
string param_value)
398 return param_value.Substring(1, param_value.Length() - 2);
401 protected float ParseToValueFloat(
string param_value)
403 return param_value.ToFloat();
406 protected int ParseToValueInt(
string param_value)
408 return param_value.ToInt();
411 protected bool ParseToValueBool(
string param_value)
413 if ( param_value.Contains(
"true") )
436 while ( pos_a > -1 || pos_b > -1 )
438 pos_a = param_value.IndexOfFrom(pos_a,
"{" );
445 pos_b = param_value.IndexOfFrom(pos_b,
"}" );
456 for ( pos_a = 0; pos_a < a.Count(); ++pos_a )
458 if ( a.Get(pos_a) > b.Get(pos_b) )
464 value_end = b.Get(pos_b) - value_start + 1;
468 strings.Insert( param_value.Substring(value_start, value_end) );
470 value_start = b.Get(pos_b) + 1;
476 else if ( a.Get(pos_a) < b.Get(pos_b) )
478 if ( pos_a == a.Count() - 1 && pos_b < b.Count() - 1 )
484 value_end = b.Get(pos_b) - value_start;
488 strings.Insert( param_value.Substring(value_start + 1, value_end) );
490 value_start = b.Get(pos_b) + 1;
502 value_start = a.Get(pos_a);
510 if ( strings.Count() == 0 )
514 string param_value_content = param_value.Substring(1, param_value.Length() - 2);
518 param_value_content.Split(
",", strings);
521 for (
int i = 0; i < strings.Count(); ++i )
523 string str = strings.Get(i);
529 param_parent.Insert(param);