EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Generator.cpp
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Zhur
24 */
25 
26 #include "eve-xmlpktgen.h"
27 
28 #include "Generator.h"
29 
30 
31 /************************************************************************/
32 /* Generator */
33 /************************************************************************/
34 bool Generator::smEncTypesLoaded = false;
35 std::map<std::string, std::string> Generator::smEncTypes;
36 
37 
38 Generator::Generator( FILE* outputFile )
39 : mOutputFile( outputFile )
40 {
41  LoadEncTypes();
42 }
43 
45 {
49 
57 
64 
68 
81 
84 }
85 
86 const char* Generator::GetEncodeType( const TiXmlElement* element )
87 {
88  std::map<std::string, std::string>::const_iterator res = smEncTypes.find( element->Value() );
89  if( res == smEncTypes.end() )
90  return "PyRep";
91 
92  return res->second.c_str();
93 }
94 
96 {
97  if( !smEncTypesLoaded ) {
98  smEncTypes[ "elementDef" ] = "PyRep";
99  smEncTypes[ "element" ] = "PyRep";
100  smEncTypes[ "elementPtr" ] = "PyRep";
101 
102  smEncTypes[ "raw" ] = "PyRep";
103  smEncTypes[ "int" ] = "PyInt";
104  smEncTypes[ "long" ] = "PyLong";
105  smEncTypes[ "real" ] = "PyFloat";
106  smEncTypes[ "bool" ] = "PyBool";
107  smEncTypes[ "none" ] = "PyNone";
108  smEncTypes[ "buffer" ] = "PyBuffer";
109 
110  smEncTypes[ "string" ] = "PyString";
111  smEncTypes[ "stringInline" ] = "PyString";
112  smEncTypes[ "wstring" ] = "PyWString";
113  smEncTypes[ "wstringInline" ] = "PyWString";
114  smEncTypes[ "token" ] = "PyToken";
115  smEncTypes[ "tokenInline" ] = "PyToken";
116 
117  smEncTypes[ "object" ] = "PyObject";
118  smEncTypes[ "objectInline" ] = "PyObject";
119  smEncTypes[ "objectEx" ] = "PyObjectEx";
120 
121  smEncTypes[ "tuple" ] = "PyTuple";
122  smEncTypes[ "tupleInline" ] = "PyTuple";
123  smEncTypes[ "list" ] = "PyList";
124  smEncTypes[ "listInline" ] = "PyList";
125  smEncTypes[ "listInt" ] = "PyList";
126  smEncTypes[ "listLong" ] = "PyList";
127  smEncTypes[ "listStr" ] = "PyList";
128  smEncTypes[ "dict" ] = "PyDict";
129  smEncTypes[ "dictInline" ] = "PyDict";
130  smEncTypes[ "dictRaw" ] = "PyDict";
131  smEncTypes[ "dictInt" ] = "PyDict";
132  smEncTypes[ "dictStr" ] = "PyDict";
133 
134  smEncTypes[ "substreamInline" ] = "PySubStream";
135  smEncTypes[ "substructInline" ] = "PySubStruct";
136 
137  smEncTypesLoaded = true;
138  }
139 }
140 
virtual bool ProcessList(const TiXmlElement *field)=0
virtual bool ProcessDictInt(const TiXmlElement *field)=0
virtual bool ProcessDictStr(const TiXmlElement *field)=0
virtual bool ProcessBuffer(const TiXmlElement *field)=0
virtual bool ProcessSubStructInline(const TiXmlElement *field)=0
virtual bool ProcessWStringInline(const TiXmlElement *field)=0
void RegisterProcessors()
Definition: Generator.cpp:44
virtual bool ProcessObject(const TiXmlElement *field)=0
virtual bool ProcessDictRaw(const TiXmlElement *field)=0
virtual bool ProcessElementDef(const TiXmlElement *field)=0
virtual bool ProcessElementPtr(const TiXmlElement *field)=0
virtual bool ProcessDictInline(const TiXmlElement *field)=0
virtual bool ProcessLong(const TiXmlElement *field)=0
virtual bool ProcessTokenInline(const TiXmlElement *field)=0
virtual bool ProcessWString(const TiXmlElement *field)=0
virtual bool ProcessListInline(const TiXmlElement *field)=0
virtual bool ProcessInt(const TiXmlElement *field)=0
virtual bool ProcessTuple(const TiXmlElement *field)=0
virtual bool ProcessObjectInline(const TiXmlElement *field)=0
virtual bool ProcessElement(const TiXmlElement *field)=0
virtual bool ProcessObjectEx(const TiXmlElement *field)=0
virtual bool ProcessRaw(const TiXmlElement *field)=0
virtual bool ProcessListLong(const TiXmlElement *field)=0
virtual bool ProcessListStr(const TiXmlElement *field)=0
virtual bool ProcessString(const TiXmlElement *field)=0
static bool smEncTypesLoaded
Definition: Generator.h:115
virtual bool ProcessStringInline(const TiXmlElement *field)=0
Generator(FILE *outputFile=NULL)
Primary constructor.
Definition: Generator.cpp:38
static void LoadEncTypes()
Definition: Generator.cpp:95
static std::map< std::string, std::string > smEncTypes
Definition: Generator.h:117
virtual bool ProcessBool(const TiXmlElement *field)=0
virtual bool ProcessNone(const TiXmlElement *field)=0
static const char * GetEncodeType(const TiXmlElement *element)
Obtains encode type of given element.
Definition: Generator.cpp:86
virtual bool ProcessListInt(const TiXmlElement *field)=0
virtual bool ProcessReal(const TiXmlElement *field)=0
virtual bool ProcessToken(const TiXmlElement *field)=0
virtual bool ProcessSubStreamInline(const TiXmlElement *field)=0
virtual bool ProcessTupleInline(const TiXmlElement *field)=0
virtual bool ProcessDict(const TiXmlElement *field)=0
void AddMemberParser(const char *name, T &instance, bool(T::*method)(const TiXmlElement *))
Adds a member parser.
Definition: XMLParserEx.h:55