fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / ScanParseSkel / OSGXMLScanParseSkel.h
blob1d84bce7dcd6ac10f2f029557baac562c95fb161
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGXMLSCANPARSESKEL_H_
40 #define _OSGXMLSCANPARSESKEL_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 //---------------------------------------------------------------------------
46 // Includes
47 //---------------------------------------------------------------------------
49 #include "OSGSystemDef.h"
50 #include "OSGBaseTypes.h"
52 #ifdef OSG_WITH_EXPAT
54 #include <vector>
55 #include <stack>
56 #include <map>
58 #include <boost/function.hpp>
60 OSG_BEGIN_NAMESPACE
62 //---------------------------------------------------------------------------
63 // Forward References
64 //---------------------------------------------------------------------------
66 //---------------------------------------------------------------------------
67 // Types
68 //---------------------------------------------------------------------------
70 //---------------------------------------------------------------------------
71 // Class
72 //---------------------------------------------------------------------------
74 #ifndef DOXYGEN_SHOULD_SKIP_THIS
76 class ScanParseSkel;
78 typedef ScanParseSkel *ScanParseSkelP;
80 #endif
82 /*! \ingroup GrpSystemFileIOScanParse
83 \ingroup GrpLibOSGSystem
86 class OSG_SYSTEM_DLLMAPPING XMLScanParseSkel
88 public:
90 //-----------------------------------------------------------------------
91 // types
92 //-----------------------------------------------------------------------
94 enum CBResult
96 NoError = 0x0000,
97 Error = 0x0001
100 typedef boost::function<CBResult ( XMLScanParseSkel *,
101 const std::string &)> XMLCallback1;
102 typedef boost::function<CBResult ( XMLScanParseSkel *,
103 const std::string &,
104 const std::string &)> XMLCallback2;
106 struct XMLCallbacks
108 XMLCallback1 _startElementCB;
109 XMLCallback2 _handleAttributeCB;
110 XMLCallback1 _endElementCB;
111 XMLCallback1 _handleDataBlockCB;
114 typedef CBResult (XMLScanParseSkel::*XMLCB1)(const std::string &);
115 typedef CBResult (XMLScanParseSkel::*XMLCB2)(const std::string &,
116 const std::string &);
118 typedef std::map<std::string, XMLCallbacks *> CallbackMap;
119 typedef std::map<std::string, XMLCallbacks *>::iterator CallbackMapIt;
121 typedef std::stack< XMLCallbacks *> CallbackStack;
123 //-----------------------------------------------------------------------
124 // constants
125 //-----------------------------------------------------------------------
127 //-----------------------------------------------------------------------
128 // enums
129 //-----------------------------------------------------------------------
131 private:
133 //-----------------------------------------------------------------------
134 // enums
135 //-----------------------------------------------------------------------
137 //-----------------------------------------------------------------------
138 // types
139 //-----------------------------------------------------------------------
141 //-----------------------------------------------------------------------
142 // friend classes
143 //-----------------------------------------------------------------------
145 //-----------------------------------------------------------------------
146 // friend functions
147 //-----------------------------------------------------------------------
149 //-----------------------------------------------------------------------
150 // class variables
151 //-----------------------------------------------------------------------
153 //-----------------------------------------------------------------------
154 // class functions
155 //-----------------------------------------------------------------------
157 //-----------------------------------------------------------------------
158 // instance variables
159 //-----------------------------------------------------------------------
161 //-----------------------------------------------------------------------
162 // instance functions
163 //-----------------------------------------------------------------------
165 // prohibit default functions (move to 'public' if you need one)
167 XMLScanParseSkel(const XMLScanParseSkel &source);
168 void operator =(const XMLScanParseSkel &source);
170 protected:
172 //-----------------------------------------------------------------------
173 // enums
174 //-----------------------------------------------------------------------
176 //-----------------------------------------------------------------------
177 // types
178 //-----------------------------------------------------------------------
180 //-----------------------------------------------------------------------
181 // class variables
182 //-----------------------------------------------------------------------
184 //-----------------------------------------------------------------------
185 // class functions
186 //-----------------------------------------------------------------------
188 static void handleChar ( void * pUserData,
189 const Char8 * szData,
190 Int32 iLength);
191 static void startElement( void * pUserData,
192 const Char8 * szName,
193 const Char8 **vAtts);
195 static void endElement ( void * pUserData,
196 const Char8 * szName);
198 //-----------------------------------------------------------------------
199 // instance variables
200 //-----------------------------------------------------------------------
202 UInt32 _uiLoadOptions;
203 CBResult _eErrorState;
205 std::string _szDataLine;
206 std::string _szAttrName;
207 std::string _szAttrValue;
209 std::stack<UInt32> _sOptionStack;
211 XMLCallbacks _oIgnoreCB;
212 CallbackMap _mCallbackMap;
213 CallbackStack _sCallbackStack;
215 //-----------------------------------------------------------------------
216 // instance functions
217 //-----------------------------------------------------------------------
219 void startElement (const std::string &szName );
220 void handleAttribute (const std::string &szName,
221 const std::string &szValue);
222 void endElement (const std::string &szName );
223 void handleCharBlock (const std::string &szData );
226 CBResult ignoreStartElement (const std::string &szName );
227 CBResult ignoreHandleAttribute(const std::string &szName,
228 const std::string &szValue);
229 CBResult ignoreEndElement (const std::string &szName );
230 CBResult ignoreHandleCharBlock(const std::string &szData );
232 public :
234 //-----------------------------------------------------------------------
235 // class functions
236 //-----------------------------------------------------------------------
238 //-----------------------------------------------------------------------
239 // instance functions
240 //-----------------------------------------------------------------------
242 XMLScanParseSkel(void);
243 virtual ~XMLScanParseSkel(void);
245 /*------------------------- your_category -------------------------------*/
247 virtual void scanStream( std::istream &sInputStream);
249 virtual void scanFile (const Char8 *szFilename );
251 /*------------------------- your_operators ------------------------------*/
254 /*------------------------- assignment ----------------------------------*/
256 /*------------------------- comparison ----------------------------------*/
258 /*------------------------- comparison ----------------------------------*/
261 OSG_END_NAMESPACE
263 #endif
265 #endif /* _OSGXMLSCANPARSESKEL_H_ */