EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
XMLParser.h
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 #ifndef __XML_PARSER_H__INCL__
27 #define __XML_PARSER_H__INCL__
28 
34 class XMLParser
35 {
36 public:
43  {
44  public:
53  virtual bool Parse( const TiXmlElement* field ) = 0;
54  //virtual ~ElementParser();
55  };
56 
60  XMLParser();
64  virtual ~XMLParser();
65 
74  bool ParseFile( const char* file );
83  bool ParseElement( const TiXmlElement* element ) const;
93  bool ParseElementChildren( const TiXmlElement* element, size_t max = 0 ) const;
94 
101  void AddParser( const char* name, ElementParser* parser );
107  void RemoveParser( const char* name );
111  void ClearParsers();
112 
113  std::unique_ptr<TiXmlDocument> m_pXML_Document;
114 
115 private:
117  std::map<std::string, ElementParser*> mParsers;
118 };
119 
120 #endif /* !__XML_PARSER_H__INCL__ */
121 
122 
123 
124 
bool ParseElement(const TiXmlElement *element) const
Parses element using registered parsers.
Definition: XMLParser.cpp:61
bool ParseFile(const char *file)
Parses file using registered parsers.
Definition: XMLParser.cpp:44
XMLParser()
Primary constructor.
Definition: XMLParser.cpp:35
std::map< std::string, ElementParser * > mParsers
Definition: XMLParser.h:117
This virtual interface must be implemented by all parsers.
Definition: XMLParser.h:42
virtual bool Parse(const TiXmlElement *field)=0
Parses an element.
Utility for parsing XML files.
Definition: XMLParser.h:34
virtual ~XMLParser()
A destructor.
Definition: XMLParser.cpp:39
std::unique_ptr< TiXmlDocument > m_pXML_Document
Definition: XMLParser.h:113
void AddParser(const char *name, ElementParser *parser)
Adds a parser.
Definition: XMLParser.cpp:101
int64 max(int64 x, int64 y=0)
Definition: misc.h:103
void RemoveParser(const char *name)
Removes a parser.
Definition: XMLParser.cpp:106
void ClearParsers()
Clears all parsers.
Definition: XMLParser.cpp:115
bool ParseElementChildren(const TiXmlElement *element, size_t max=0) const
Parses element's children using registered parsers.
Definition: XMLParser.cpp:72