]> icculus.org git repositories - divverent/netradiant.git/blob - radiant/xmlstuff.h
initial
[divverent/netradiant.git] / radiant / xmlstuff.h
1 /*
2 Copyright (c) 2001, Loki software, inc.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without modification, 
6 are permitted provided that the following conditions are met:
7
8 Redistributions of source code must retain the above copyright notice, this list 
9 of conditions and the following disclaimer.
10
11 Redistributions in binary form must reproduce the above copyright notice, this
12 list of conditions and the following disclaimer in the documentation and/or
13 other materials provided with the distribution.
14
15 Neither the name of Loki software nor the names of its contributors may be used 
16 to endorse or promote products derived from this software without specific prior 
17 written permission. 
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' 
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
22 DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 
23 DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
29 */
30
31 //-----------------------------------------------------------------------------
32 //
33 // DESCRIPTION:
34 // header for xml stuff used in radiant
35 //
36
37 #ifndef __XMLSTUFF__
38 #define __XMLSTUFF__
39
40 #include "libxml/parser.h"
41
42 #include <cstddef>
43
44 class ISAXHandler;
45
46 // a 'user data' structure we pass along in the SAX callbacks to represent the current state
47 // the recurse value tracks the current depth in the tree
48 // message_info also stores information to exit the stream listening cleanly with an error:
49 //   if msg_level == SYS_ERR, then we will reset the listening at the end of the current node
50 //   the level for stopping the feed is stored in stop_depth
51 // unkown nodes are ignored, we use ignore_depth to track the level we start ignoring from
52 struct message_info_t
53 {
54   int msg_level; // current message level (SYS_MSG, SYS_WRN, SYS_ERR)
55   int recurse; // current recursion depth (used to track various things)
56   int ignore_depth; // the ignore depth limit when we are jumping over unknown nodes (0 means we are not ignoring)
57   int stop_depth; // the depth we need to stop at the end
58   int geometry_depth; // are we parsing some geometry information (i.e. do we forward the SAX calls?)
59   ISAXHandler* pGeometry; // the handler
60
61   enum unnamed0 { bufsize = 1024 };
62   char m_buffer[bufsize];
63   std::size_t m_length;
64 };
65
66 class IGL2DWindow;
67
68 class ISAXHandler
69 {
70 public:
71   virtual void Release()
72   {
73   }
74   virtual void saxStartElement(message_info_t* ctx, const xmlChar* name, const xmlChar** attrs) = 0;
75   virtual void saxEndElement(message_info_t* ctx, const xmlChar* name) = 0;
76   virtual void saxCharacters(message_info_t* ctx, const xmlChar* ch, int len) = 0;
77   virtual const char* getName()
78   {
79     return NULL;
80   }
81   virtual IGL2DWindow* Highlight()
82   {
83     return 0;
84   }
85   virtual void DropHighlight()
86   {
87   }
88 };
89
90 #endif