PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
pge_x_macro.h
1 #ifndef PGE_X_MACRO_H
2 #define PGE_X_MACRO_H
3 
4 #define PGEX_FileBegin() int str_count=0; /*Line Counter*/\
5  PGESTRING line; /*Current Line data*/
6 
7 #define PGEX_FileParseTree(raw) PGEFile pgeX_Data(raw);\
8  if( !pgeX_Data.buildTreeFromRaw() )\
9  {\
10  errorString = pgeX_Data.lastError();\
11  goto badfile;\
12  }
13 #define PGEX_FetchSection() for(int section=0; section<(signed)pgeX_Data.dataTree.size(); section++)
14 #define PGEX_FetchSection_begin() PGEFile::PGEX_Entry &f_section = pgeX_Data.dataTree[section];\
15  if(f_section.name=="") continue;
16 
17 #define PGEX_Section(sct) else if(f_section.name==sct)
18 #define PGEX_SectionBegin(stype) if(f_section.type!=stype) \
19 { \
20  errorString=PGESTRING("Wrong section data syntax:\nSection ["+f_section.name+"]");\
21  goto badfile;\
22 }
23 
24 #define PGEX_Items() for(int sdata=0;sdata<(signed)f_section.data.size();sdata++)
25 #define PGEX_ItemBegin(stype) if(f_section.data[sdata].type!=stype) \
26 { \
27  errorString=PGESTRING("Wrong data item syntax:\nSection ["+f_section.name+"]\nData line "+fromNum(sdata));\
28  goto badfile;\
29 }\
30 PGEFile::PGEX_Item x = f_section.data[sdata];
31 
32 
33 #define PGEX_Values() for(int sval=0;sval<(signed)x.values.size();sval++)
34 #define PGEX_ValueBegin() PGEFile::PGEX_Val v = x.values[sval];\
35  errorString=PGESTRING("Wrong value syntax\nSection ["+f_section.name+ \
36  "]\nData line "+fromNum(sdata) \
37  +"\nMarker "+v.marker+"\nValue "+v.value);\
38  if(v.marker=="") continue;
39 
40 #define PGEX_StrVal(Mark, targetValue) else if(v.marker==Mark) { if(PGEFile::IsQStr(v.value)) \
41  targetValue = PGEFile::X2STR(v.value); \
42  else goto badfile; }
43 
44 #define PGEX_StrArrVal(Mark, targetValue) else if(v.marker==Mark) { if(PGEFile::IsStringArray(v.value)) \
45  targetValue = PGEFile::X2STRArr(v.value); \
46  else goto badfile; }
47 
48 #define PGEX_BoolVal(Mark, targetValue) if(v.marker==Mark) { if(PGEFile::IsBool(v.value)) \
49  targetValue = (bool)toInt(v.value);\
50  else goto badfile; }
51 
52 #define PGEX_BoolArrVal(Mark, targetValue) else if(v.marker==Mark) { if(PGEFile::IsBoolArray(v.value)) \
53  targetValue = PGEFile::X2BollArr(v.value); \
54  else goto badfile; }
55 
56 #define PGEX_UIntVal(Mark, targetValue) if(v.marker==Mark) { if(PGEFile::IsIntU(v.value)) \
57  targetValue = toInt(v.value);\
58  else goto badfile; }
59 
60 #define PGEX_SIntVal(Mark, targetValue) if(v.marker==Mark) { if(PGEFile::IsIntS(v.value)) \
61  targetValue = toInt(v.value);\
62  else goto badfile; }
63 
64 #define PGEX_FloatVal(Mark, targetValue) if(v.marker==Mark) { if(PGEFile::IsFloat(v.value)) \
65  targetValue = toDouble(v.value);\
66  else goto badfile; }
67 
68 
69 #endif // PGE_X_MACRO_H
70