Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
XMLSerializer.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 "CEGUI/Base.h"
31 #include "CEGUI/String.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  public AllocatedObject<XMLSerializer>
88  {
89  public:
98  XMLSerializer(OutStream& out, size_t indentSpace = 4);
99 
103  virtual ~XMLSerializer(void);
104 
113  XMLSerializer& openTag(const String& name);
120  XMLSerializer& closeTag(void);
131  XMLSerializer& attribute(const String& name, const String& value);
140  XMLSerializer& text(const String& text);
141 
149  unsigned int getTagCount() const;
156  operator bool () const
157  {
158  return false == d_error;
159  }
166  bool operator!() const
167  {
168  return false != d_error;
169  }
170 
171  protected:
172  private:
173  bool d_error;
174  unsigned int d_tagCount;
175  size_t d_depth;
176  size_t d_indentSpace;
177  bool d_needClose;
178  bool d_lastIsText;
179  OutStream& d_stream;
180  std::vector<String
181  CEGUI_VECTOR_ALLOC(String)> d_tagStack;
182 
186  void indentLine();
190  static String convertEntityInText(const String& text);
194  static String convertEntityInAttribute(const String& attributeValue);
195 
196 
197  // Disabled operation
198  XMLSerializer(const XMLSerializer& obj);
199  // Disabled operation
200  XMLSerializer& operator=(const XMLSerializer& obj);
201  };
202 }
203 
204 #if defined(_MSC_VER)
205 # pragma warning(pop)
206 #endif
207 
208 #endif