]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/xmlstuff.h
merge branch work back into trunk
[xonotic/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 struct message_info_s;
43
44 class ISAXHandler
45 {
46 public:
47         virtual ~ISAXHandler() { }
48   virtual void saxStartElement( struct message_info_s *ctx, const xmlChar *name, const xmlChar **attrs ) = 0;
49   virtual void saxEndElement( struct message_info_s *ctx, const xmlChar *name ) = 0;
50   virtual void saxCharacters( struct message_info_s *ctx, const xmlChar *ch, int len ) = 0;
51   virtual char *getName() { return NULL; }
52   virtual void Highlight() { }
53   virtual void DropHighlight() { }
54   virtual bool ShouldDelete() { return true; } // should the handler be deleted when the feedback dialog is cleared?
55 };
56
57 // a 'user data' structure we pass along in the SAX callbacks to represent the current state
58 // the recurse value tracks the current depth in the tree
59 // message_info also stores information to exit the stream listening cleanly with an error:
60 //   if msg_level == SYS_ERR, then we will reset the listening at the end of the current node
61 //   the level for stopping the feed is stored in stop_depth
62 // unkown nodes are ignored, we use ignore_depth to track the level we start ignoring from
63 typedef struct message_info_s {
64   int                           msg_level;              // current message level (SYS_MSG, SYS_WRN, SYS_ERR)
65   int                           recurse;                // current recursion depth (used to track various things)
66   int                           ignore_depth;   // the ignore depth limit when we are jumping over unknown nodes (0 means we are not ignoring)
67   int                           stop_depth;             // the depth we need to stop at the end
68   bool                          bGeometry;              // are we parsing some geometry information (i.e. do we forward the SAX calls?)
69   ISAXHandler           *pGeometry;             // the handler
70 } message_info_t;
71
72 #endif