PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
pge_x.h
1 /*
2  * Platformer Game Engine by Wohlstand, a free platform for game making
3  * Copyright (c) 2014-2015 Vitaly Novichkov <admin@wohlnet.ru>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef PGE_X_H
20 #define PGE_X_H
21 
22 #include "pge_file_lib_globs.h"
23 
24 typedef PGEPAIR<PGESTRING, PGESTRINGList> PGEXSct;
25 
26 #ifdef PGE_FILES_QT
27 class PGEFile: PGE_FILES_INHERED
28 {
29  Q_OBJECT
30 #else
31 class PGEFile
32 {
33 #endif
34 
35 public:
36  enum PGEX_Item_type
37  {
38  PGEX_Struct=0,
39  PGEX_PlainText
40  };
41 
42 
43  struct PGEX_Val
44  {
45  PGESTRING marker;
46  PGESTRING value;
47  };
48 
49  struct PGEX_Item
50  {
51  PGEX_Item_type type;
52  PGELIST<PGEX_Val > values;
53  };
54 
55  struct PGEX_Entry
56  {
57  PGESTRING name;
58  PGEX_Item_type type;
59  PGELIST<PGEX_Item > data;
60  PGELIST<PGEX_Entry > subTree;
61  };
62 
63  #ifdef PGE_FILES_QT
64  PGEFile(QObject *parent=NULL);
65  PGEFile(PGEFile &pgeFile, QObject *parent=NULL);
66  #else
67  PGEFile();
68  PGEFile(PGEFile &pgeFile);
69  #endif
70  PGEFile(PGESTRING _rawData);
71  void setRawData(PGESTRING _rawData);
72  bool buildTreeFromRaw();
73  PGESTRING lastError();
74 
75  //data tree
76  PGELIST<PGEX_Entry > dataTree;
77 
78 private:
79  PGESTRING _lastError;
80  PGESTRING rawData;
81  PGELIST<PGEXSct > rawDataTree;
82 
83  //Static functions
84 public:
85  // /////////////Validators///////////////
86  static bool IsSectionTitle(PGESTRING in);//Section Title
87 
88  static PGEX_Entry buildTree(PGESTRINGList &src_data, bool *_valid = 0);
89 
90  //returns FALSE on valid data
91  static bool IsQStr(PGESTRING in);// QUOTED STRING
92  static bool IsHex(PGESTRING in);// Hex Encoded String
93  static bool IsIntU(PGESTRING in);// UNSIGNED INT
94  static bool IsIntS(PGESTRING in);// SIGNED INT
95  static bool IsFloat(PGESTRING &in);// FLOAT
96  static bool IsBool(PGESTRING in);//BOOL
97  static bool IsBoolArray(PGESTRING in);//Boolean array
98  static bool IsIntArray(PGESTRING in);//Integer array
99  static bool IsStringArray(PGESTRING in);//String array
100 
101  //Split string into data values
102  static PGELIST<PGESTRINGList> splitDataLine(PGESTRING src_data, bool *valid = 0);
103 
104  //PGE Extended File parameter string generators
105  static PGESTRING IntS(long input);
106  static PGESTRING BoolS(bool input);
107  static PGESTRING FloatS(double input);
108  static PGESTRING qStrS(PGESTRING input);
109  static PGESTRING hStrS(PGESTRING input);
110  static PGESTRING strArrayS(PGESTRINGList input);
111  static PGESTRING intArrayS(PGELIST<int > input);
112  static PGESTRING BoolArrayS(PGELIST<bool > input);
113 
114  static PGESTRING X2STR(PGESTRING input);
115  static PGESTRINGList X2STRArr(PGESTRING src);
116  static PGELIST<bool> X2BollArr(PGESTRING src);
117 
118  static PGESTRING escapeStr(PGESTRING input);
119  static PGESTRING restoreStr(PGESTRING input);
120  static PGESTRING encodeEscape(PGESTRING input);
121  static PGESTRING decodeEscape(PGESTRING input);
122 
123  static PGESTRING value(PGESTRING marker, PGESTRING data);
124  static PGESTRING removeQuotes(PGESTRING str);
125 };
126 
127 
128 #endif // PGE_X_H
129 
#define PGESTRING
A macro which equal to std::string if PGE File Library built in the STL mode and equal to QString if ...
Definition: pge_file_lib_globs.h:97
Definition: pge_x.h:55
Definition: pge_x.h:43
Definition: pge_x.h:31
Definition: pge_x.h:49
Contains internal settings and references for PGE File Library.
#define PGESTRINGList
A macro which equal to std::vector if PGE File Library built in the STL mode and equal t...
Definition: pge_file_lib_globs.h:104