EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ClassConstructGenerator Class Reference

#include "ConstructGenerator.h"

Inheritance diagram for ClassConstructGenerator:
Collaboration diagram for ClassConstructGenerator:

Public Member Functions

 ClassConstructGenerator (FILE *outputFile=NULL)
 
- Public Member Functions inherited from Generator
 Generator (FILE *outputFile=NULL)
 Primary constructor. More...
 
void SetOutputFile (FILE *outputFile)
 Sets output file. More...
 
- Public Member Functions inherited from XMLParserEx
template<typename T >
void AddMemberParser (const char *name, T &instance, bool(T::*method)(const TiXmlElement *))
 Adds a member parser. More...
 
template<typename T >
void AddValueParser (const char *name, T &value)
 Adds a value parser. More...
 
- Public Member Functions inherited from XMLParser
 XMLParser ()
 Primary constructor. More...
 
virtual ~XMLParser ()
 A destructor. More...
 
bool ParseFile (const char *file)
 Parses file using registered parsers. More...
 
bool ParseElement (const TiXmlElement *element) const
 Parses element using registered parsers. More...
 
bool ParseElementChildren (const TiXmlElement *element, size_t max=0) const
 Parses element's children using registered parsers. More...
 
void AddParser (const char *name, ElementParser *parser)
 Adds a parser. More...
 
void RemoveParser (const char *name)
 Removes a parser. More...
 
void ClearParsers ()
 Clears all parsers. More...
 

Protected Member Functions

void RegisterProcessors ()
 
bool ProcessElementDef (const TiXmlElement *field)
 
bool ProcessElement (const TiXmlElement *field)
 
bool ProcessElementPtr (const TiXmlElement *field)
 
bool ProcessRaw (const TiXmlElement *field)
 
bool ProcessInt (const TiXmlElement *field)
 
bool ProcessLong (const TiXmlElement *field)
 
bool ProcessReal (const TiXmlElement *field)
 
bool ProcessBool (const TiXmlElement *field)
 
bool ProcessNone (const TiXmlElement *field)
 
bool ProcessBuffer (const TiXmlElement *field)
 
bool ProcessString (const TiXmlElement *field)
 
bool ProcessStringInline (const TiXmlElement *field)
 
bool ProcessWString (const TiXmlElement *field)
 
bool ProcessWStringInline (const TiXmlElement *field)
 
bool ProcessToken (const TiXmlElement *field)
 
bool ProcessTokenInline (const TiXmlElement *field)
 
bool ProcessObject (const TiXmlElement *field)
 
bool ProcessObjectInline (const TiXmlElement *field)
 
bool ProcessObjectEx (const TiXmlElement *field)
 
bool ProcessTuple (const TiXmlElement *field)
 
bool ProcessTupleInline (const TiXmlElement *field)
 
bool ProcessList (const TiXmlElement *field)
 
bool ProcessListInline (const TiXmlElement *field)
 
bool ProcessListInt (const TiXmlElement *field)
 
bool ProcessListLong (const TiXmlElement *field)
 
bool ProcessListStr (const TiXmlElement *field)
 
bool ProcessDict (const TiXmlElement *field)
 
bool ProcessDictInline (const TiXmlElement *field)
 
bool ProcessDictInlineEntry (const TiXmlElement *field)
 
bool ProcessDictRaw (const TiXmlElement *field)
 
bool ProcessDictInt (const TiXmlElement *field)
 
bool ProcessDictStr (const TiXmlElement *field)
 
bool ProcessSubStreamInline (const TiXmlElement *field)
 
bool ProcessSubStructInline (const TiXmlElement *field)
 
- Protected Member Functions inherited from Generator
void RegisterProcessors ()
 
- Protected Member Functions inherited from XMLParserEx
template<typename T >
void AddMemberParser (const char *name, bool(T::*method)(const TiXmlElement *))
 Adds a member parser, assuming that instance is this. More...
 

Additional Inherited Members

- Public Attributes inherited from XMLParser
std::unique_ptr< TiXmlDocument > m_pXML_Document
 
- Static Protected Member Functions inherited from Generator
static const char * GetEncodeType (const TiXmlElement *element)
 Obtains encode type of given element. More...
 
- Protected Attributes inherited from Generator
FILE * mOutputFile
 

Detailed Description

Definition at line 31 of file ConstructGenerator.h.

Constructor & Destructor Documentation

ClassConstructGenerator::ClassConstructGenerator ( FILE *  outputFile = NULL)

Definition at line 30 of file ConstructGenerator.cpp.

References RegisterProcessors().

31 : Generator( outputFile )
32 {
34 }
Generator(FILE *outputFile=NULL)
Primary constructor.
Definition: Generator.cpp:38

Here is the call graph for this function:

Member Function Documentation

bool ClassConstructGenerator::ProcessBool ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 171 of file ConstructGenerator.cpp.

References Generator::mOutputFile.

172 {
173  const char* name = field->Attribute( "name" );
174  if (name == nullptr) {
175  std::cout << std::endl << "ClassConstructGenerator::ProcessBool field at line " << field->Row() << " is missing the name attribute, skipping.";
176  return false;
177  }
178 
179  const char* def = field->Attribute( "default" );
180  if (def == nullptr)
181  def = "false";
182 
183  fprintf( mOutputFile,
184  " %s = %s;\n",
185  name, def
186  );
187 
188  return true;
189 }
FILE * mOutputFile
Definition: Generator.h:108
bool ClassConstructGenerator::ProcessBuffer ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 196 of file ConstructGenerator.cpp.

References Generator::mOutputFile.

197 {
198  const char* name = field->Attribute( "name" );
199  if (name == nullptr) {
200  std::cout << std::endl << "ClassConstructGenerator::ProcessBuffer field at line " << field->Row() << " is missing the name attribute, skipping.";
201  return false;
202  }
203 
204  fprintf( mOutputFile,
205  " %s = nullptr;\n",
206  name
207  );
208 
209  return true;
210 }
FILE * mOutputFile
Definition: Generator.h:108
bool ClassConstructGenerator::ProcessDict ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 378 of file ConstructGenerator.cpp.

References Generator::mOutputFile.

379 {
380  const char *name = field->Attribute( "name" );
381  if (name == nullptr) {
382  std::cout << std::endl << "ClassConstructGenerator::ProcessDict field at line " << field->Row() << " is missing the name attribute, skipping.";
383  return false;
384  }
385 
386  fprintf( mOutputFile,
387  " %s = nullptr;\n",
388  name
389  );
390 
391  return true;
392 }
FILE * mOutputFile
Definition: Generator.h:108
bool ClassConstructGenerator::ProcessDictInline ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 394 of file ConstructGenerator.cpp.

References XMLParser::ParseElementChildren().

395 {
396  return ParseElementChildren( field );
397 }
bool ParseElementChildren(const TiXmlElement *element, size_t max=0) const
Parses element's children using registered parsers.
Definition: XMLParser.cpp:72

Here is the call graph for this function:

bool ClassConstructGenerator::ProcessDictInlineEntry ( const TiXmlElement *  field)
protected

Definition at line 399 of file ConstructGenerator.cpp.

References key(), and XMLParser::ParseElementChildren().

Referenced by RegisterProcessors().

400 {
401  //we dont really even care about this...
402  const char* key = field->Attribute( "key" );
403  if (key == nullptr) {
404  std::cout << std::endl << "ClassConstructGenerator::ProcessDictInlineEntry field at line " << field->Row() << " is missing the name attribute, skipping.";
405  return false;
406  }
407 
408  return ParseElementChildren( field, 1 );
409 }
bool ParseElementChildren(const TiXmlElement *element, size_t max=0) const
Parses element's children using registered parsers.
Definition: XMLParser.cpp:72
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type() key(value)-Send an OnRemoteMessage" ) COMMAND( setbpattr

Here is the call graph for this function:

Here is the caller graph for this function:

bool ClassConstructGenerator::ProcessDictInt ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 416 of file ConstructGenerator.cpp.

417 {
418  return true;
419 }
bool ClassConstructGenerator::ProcessDictRaw ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 411 of file ConstructGenerator.cpp.

412 {
413  return true;
414 }
bool ClassConstructGenerator::ProcessDictStr ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 421 of file ConstructGenerator.cpp.

422 {
423  return true;
424 }
bool ClassConstructGenerator::ProcessElement ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 74 of file ConstructGenerator.cpp.

75 {
76  return true;
77 }
bool ClassConstructGenerator::ProcessElementDef ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 43 of file ConstructGenerator.cpp.

References Generator::mOutputFile, and XMLParser::ParseElementChildren().

44 {
45  const char* name = field->Attribute( "name" );
46  if (name == nullptr) {
47  std::cout << std::endl << "ClassConstructGenerator::ProcessElementDef <element> at line " << field->Row() << " is missing the name attribute, skipping.";
48  return false;
49  }
50 
51  fprintf( mOutputFile,
52  "%s::%s()\n"
53  "{\n",
54  name, name
55  );
56 
57  if( !ParseElementChildren( field ) )
58  return false;
59 
60  fprintf( mOutputFile,
61  "}\n"
62  "\n"
63  "%s::%s( const %s& oth )\n"
64  "{\n"
65  " *this = oth;\n"
66  "}\n"
67  "\n",
68  name, name, name
69  );
70 
71  return true;
72 }
FILE * mOutputFile
Definition: Generator.h:108
bool ParseElementChildren(const TiXmlElement *element, size_t max=0) const
Parses element's children using registered parsers.
Definition: XMLParser.cpp:72

Here is the call graph for this function:

bool ClassConstructGenerator::ProcessElementPtr ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 79 of file ConstructGenerator.cpp.

References Generator::mOutputFile.

80 {
81  const char* name = field->Attribute( "name" );
82  if (name == nullptr) {
83  std::cout << std::endl << "ClassConstructGenerator::ProcessElementPtr field at line " << field->Row() << " is missing the name attribute, skipping.";
84  return false;
85  }
86 
87  fprintf( mOutputFile,
88  " %s = nullptr;\n",
89  name
90  );
91 
92  return true;
93 }
FILE * mOutputFile
Definition: Generator.h:108
bool ClassConstructGenerator::ProcessInt ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 111 of file ConstructGenerator.cpp.

References Generator::mOutputFile.

112 {
113  const char* name = field->Attribute( "name" );
114  if (name == nullptr) {
115  std::cout << std::endl << "ClassConstructGenerator::ProcessInt field at line " << field->Row() << " is missing the name attribute, skipping.";
116  return false;
117  }
118 
119  const char* def = field->Attribute( "default" );
120  if (def == nullptr)
121  def = "0";
122 
123  fprintf( mOutputFile,
124  " %s = %s;\n",
125  name, def
126  );
127 
128  return true;
129 }
FILE * mOutputFile
Definition: Generator.h:108
bool ClassConstructGenerator::ProcessList ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 342 of file ConstructGenerator.cpp.

References Generator::mOutputFile.

343 {
344  const char *name = field->Attribute( "name" );
345  if (name == nullptr) {
346  std::cout << std::endl << "ClassConstructGenerator::ProcessList field at line " << field->Row() << " is missing the name attribute, skipping.";
347  return false;
348  }
349 
350  fprintf( mOutputFile,
351  " %s = nullptr;\n",
352  name
353  );
354 
355  return true;
356 }
FILE * mOutputFile
Definition: Generator.h:108
bool ClassConstructGenerator::ProcessListInline ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 358 of file ConstructGenerator.cpp.

References XMLParser::ParseElementChildren().

359 {
360  return ParseElementChildren( field );
361 }
bool ParseElementChildren(const TiXmlElement *element, size_t max=0) const
Parses element's children using registered parsers.
Definition: XMLParser.cpp:72

Here is the call graph for this function:

bool ClassConstructGenerator::ProcessListInt ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 363 of file ConstructGenerator.cpp.

364 {
365  return true;
366 }
bool ClassConstructGenerator::ProcessListLong ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 368 of file ConstructGenerator.cpp.

369 {
370  return true;
371 }
bool ClassConstructGenerator::ProcessListStr ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 373 of file ConstructGenerator.cpp.

374 {
375  return true;
376 }
bool ClassConstructGenerator::ProcessLong ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 131 of file ConstructGenerator.cpp.

References Generator::mOutputFile.

132 {
133  const char* name = field->Attribute( "name" );
134  if (name == nullptr) {
135  std::cout << std::endl << "ClassConstructGenerator::ProcessLong field at line " << field->Row() << " is missing the name attribute, skipping.";
136  return false;
137  }
138 
139  const char* def = field->Attribute( "default" );
140  if (def == nullptr)
141  def = "0";
142 
143  fprintf( mOutputFile,
144  " %s = %s;\n",
145  name, def
146  );
147 
148  return true;
149 }
FILE * mOutputFile
Definition: Generator.h:108
bool ClassConstructGenerator::ProcessNone ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 191 of file ConstructGenerator.cpp.

192 {
193  return true;
194 }
bool ClassConstructGenerator::ProcessObject ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 283 of file ConstructGenerator.cpp.

References Generator::mOutputFile.

284 {
285  const char* name = field->Attribute( "name" );
286  if (name == nullptr) {
287  std::cout << std::endl << "ClassConstructGenerator::ProcessObject field at line " << field->Row() << " is missing the name attribute, skipping.";
288  return false;
289  }
290 
291  fprintf( mOutputFile,
292  " %s = nullptr;\n"
293  "\n",
294  name
295  );
296 
297  return true;
298 }
FILE * mOutputFile
Definition: Generator.h:108
bool ClassConstructGenerator::ProcessObjectEx ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 305 of file ConstructGenerator.cpp.

References Generator::mOutputFile.

306 {
307  const char *name = field->Attribute( "name" );
308  if (name == nullptr) {
309  std::cout << std::endl << "ClassConstructGenerator::ProcessObjectEx field at line " << field->Row() << " is missing the name attribute, skipping.";
310  return false;
311  }
312 
313  fprintf( mOutputFile,
314  " %s = nullptr;\n",
315  name
316  );
317 
318  return true;
319 }
FILE * mOutputFile
Definition: Generator.h:108
bool ClassConstructGenerator::ProcessObjectInline ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 300 of file ConstructGenerator.cpp.

References XMLParser::ParseElementChildren().

301 {
302  return ParseElementChildren( field, 2 );
303 }
bool ParseElementChildren(const TiXmlElement *element, size_t max=0) const
Parses element's children using registered parsers.
Definition: XMLParser.cpp:72

Here is the call graph for this function:

bool ClassConstructGenerator::ProcessRaw ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 95 of file ConstructGenerator.cpp.

References Generator::mOutputFile.

96 {
97  const char* name = field->Attribute( "name" );
98  if (name == nullptr) {
99  std::cout << std::endl << "ClassConstructGenerator::ProcessRaw field at line " << field->Row() << " is missing the name attribute, skipping.";
100  return false;
101  }
102 
103  fprintf( mOutputFile,
104  " %s = nullptr;\n",
105  name
106  );
107 
108  return true;
109 }
FILE * mOutputFile
Definition: Generator.h:108
bool ClassConstructGenerator::ProcessReal ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 151 of file ConstructGenerator.cpp.

References Generator::mOutputFile.

152 {
153  const char* name = field->Attribute( "name" );
154  if (name == nullptr) {
155  std::cout << std::endl << "ClassConstructGenerator::ProcessReal field at line " << field->Row() << " is missing the name attribute, skipping.";
156  return false;
157  }
158 
159  const char* def = field->Attribute( "default" );
160  if (def == nullptr)
161  def = "0.0";
162 
163  fprintf( mOutputFile,
164  " %s = %s;\n",
165  name, def
166  );
167 
168  return true;
169 }
FILE * mOutputFile
Definition: Generator.h:108
bool ClassConstructGenerator::ProcessString ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 212 of file ConstructGenerator.cpp.

References Generator::mOutputFile.

213 {
214  const char* name = field->Attribute( "name" );
215  if (name == nullptr) {
216  std::cout << std::endl << "ClassConstructGenerator::ProcessString field at line " << field->Row() << " is missing the name attribute, skipping.";
217  return false;
218  }
219 
220  const char* def = field->Attribute( "default" );
221  if (def == nullptr)
222  def = "";
223 
224  fprintf( mOutputFile,
225  " %s = \"%s\";\n",
226  name, def
227  );
228 
229  return true;
230 }
FILE * mOutputFile
Definition: Generator.h:108
bool ClassConstructGenerator::ProcessStringInline ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 232 of file ConstructGenerator.cpp.

233 {
234  return true;
235 }
bool ClassConstructGenerator::ProcessSubStreamInline ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 426 of file ConstructGenerator.cpp.

References XMLParser::ParseElementChildren().

427 {
428  return ParseElementChildren( field, 1 );
429 }
bool ParseElementChildren(const TiXmlElement *element, size_t max=0) const
Parses element's children using registered parsers.
Definition: XMLParser.cpp:72

Here is the call graph for this function:

bool ClassConstructGenerator::ProcessSubStructInline ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 431 of file ConstructGenerator.cpp.

References XMLParser::ParseElementChildren().

432 {
433  return ParseElementChildren( field, 1 );
434 }
bool ParseElementChildren(const TiXmlElement *element, size_t max=0) const
Parses element's children using registered parsers.
Definition: XMLParser.cpp:72

Here is the call graph for this function:

bool ClassConstructGenerator::ProcessToken ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 262 of file ConstructGenerator.cpp.

References Generator::mOutputFile.

263 {
264  const char* name = field->Attribute( "name" );
265  if (name == nullptr) {
266  std::cout << std::endl << "ClassConstructGenerator::ProcessToken field at line " << field->Row() << " is missing the name attribute, skipping.";
267  return false;
268  }
269 
270  fprintf( mOutputFile,
271  " %s = nullptr;\n",
272  name
273  );
274 
275  return true;
276 }
FILE * mOutputFile
Definition: Generator.h:108
bool ClassConstructGenerator::ProcessTokenInline ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 278 of file ConstructGenerator.cpp.

279 {
280  return true;
281 }
bool ClassConstructGenerator::ProcessTuple ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 321 of file ConstructGenerator.cpp.

References Generator::mOutputFile.

322 {
323  const char *name = field->Attribute( "name" );
324  if (name == nullptr) {
325  std::cout << std::endl << "ClassConstructGenerator::ProcessTuple field at line " << field->Row() << " is missing the name attribute, skipping.";
326  return false;
327  }
328 
329  fprintf( mOutputFile,
330  " %s = nullptr;\n",
331  name
332  );
333 
334  return true;
335 }
FILE * mOutputFile
Definition: Generator.h:108
bool ClassConstructGenerator::ProcessTupleInline ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 337 of file ConstructGenerator.cpp.

References XMLParser::ParseElementChildren().

338 {
339  return ParseElementChildren( field );
340 }
bool ParseElementChildren(const TiXmlElement *element, size_t max=0) const
Parses element's children using registered parsers.
Definition: XMLParser.cpp:72

Here is the call graph for this function:

bool ClassConstructGenerator::ProcessWString ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 237 of file ConstructGenerator.cpp.

References Generator::mOutputFile.

238 {
239  const char* name = field->Attribute( "name" );
240  if (name == nullptr) {
241  std::cout << std::endl << "ClassConstructGenerator::ProcessWString field at line " << field->Row() << " is missing the name attribute, skipping.";
242  return false;
243  }
244 
245  const char* def = field->Attribute( "default" );
246  if (def == nullptr)
247  def = "";
248 
249  fprintf( mOutputFile,
250  " %s = \"%s\";\n",
251  name, def
252  );
253 
254  return true;
255 }
FILE * mOutputFile
Definition: Generator.h:108
bool ClassConstructGenerator::ProcessWStringInline ( const TiXmlElement *  field)
protectedvirtual

Implements Generator.

Definition at line 257 of file ConstructGenerator.cpp.

258 {
259  return true;
260 }
void ClassConstructGenerator::RegisterProcessors ( )
protected

Definition at line 36 of file ConstructGenerator.cpp.

References XMLParserEx::AddMemberParser(), ProcessDictInlineEntry(), and Generator::RegisterProcessors().

Referenced by ClassConstructGenerator().

37 {
39 
41 }
void RegisterProcessors()
Definition: Generator.cpp:44
bool ProcessDictInlineEntry(const TiXmlElement *field)
void AddMemberParser(const char *name, T &instance, bool(T::*method)(const TiXmlElement *))
Adds a member parser.
Definition: XMLParserEx.h:55

Here is the call graph for this function:

Here is the caller graph for this function:


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