Crazy Eddies GUI System  0.7.8
CEGUIXMLSerializer.h
1 /***********************************************************************
2  filename: CEGUIXMLSerializer.h
3  created: Thue May 16 2006
4  author: Olivier Delannoy
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIXMLSerializer_h_
29 #define _CEGUIXMLSerializer_h_
30 #include "CEGUIBase.h"
31 #include "CEGUIString.h"
32 #include <vector>
33 
34 #if defined(_MSC_VER)
35 # pragma warning(push)
36 # pragma warning(disable : 4251)
37 #endif
38 
39 // Start of CEGUI namespace section
40 namespace CEGUI
41 {
86  class CEGUIEXPORT XMLSerializer
87  {
88  public:
97  XMLSerializer(OutStream& out, size_t indentSpace = 4);
98 
102  virtual ~XMLSerializer(void);
103 
112  XMLSerializer& openTag(const String& name);
119  XMLSerializer& closeTag(void);
130  XMLSerializer& attribute(const String& name, const String& value);
139  XMLSerializer& text(const String& text);
140 
148  unsigned int getTagCount() const;
155  operator bool () const
156  {
157  return false == d_error;
158  }
165  bool operator!() const
166  {
167  return false != d_error;
168  }
169 
170  protected:
171  private:
172  bool d_error;
173  unsigned int d_tagCount;
174  size_t d_depth;
175  size_t d_indentSpace;
176  bool d_needClose;
177  bool d_lastIsText;
178  OutStream& d_stream;
179  std::vector<String> d_tagStack;
180 
184  void indentLine();
188  static String convertEntityInText(const String& text);
192  static String convertEntityInAttribute(const String& attributeValue);
193 
194 
195  // Disabled operation
196  XMLSerializer(const XMLSerializer& obj);
197  // Disabled operation
198  XMLSerializer& operator=(const XMLSerializer& obj);
199  };
200 }
201 
202 #if defined(_MSC_VER)
203 # pragma warning(pop)
204 #endif
205 
206 #endif