1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGXMLSCANPARSESKEL_H_
40 #define _OSGXMLSCANPARSESKEL_H_
45 //---------------------------------------------------------------------------
47 //---------------------------------------------------------------------------
49 #include "OSGSystemDef.h"
50 #include "OSGBaseTypes.h"
58 #include <boost/function.hpp>
62 //---------------------------------------------------------------------------
64 //---------------------------------------------------------------------------
66 //---------------------------------------------------------------------------
68 //---------------------------------------------------------------------------
70 //---------------------------------------------------------------------------
72 //---------------------------------------------------------------------------
74 #ifndef DOXYGEN_SHOULD_SKIP_THIS
78 typedef ScanParseSkel
*ScanParseSkelP
;
82 /*! \ingroup GrpSystemFileIOScanParse
83 \ingroup GrpLibOSGSystem
86 class OSG_SYSTEM_DLLMAPPING XMLScanParseSkel
90 //-----------------------------------------------------------------------
92 //-----------------------------------------------------------------------
100 typedef boost::function
<CBResult ( XMLScanParseSkel
*,
101 const std::string
&)> XMLCallback1
;
102 typedef boost::function
<CBResult ( XMLScanParseSkel
*,
104 const std::string
&)> XMLCallback2
;
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 //-----------------------------------------------------------------------
125 //-----------------------------------------------------------------------
127 //-----------------------------------------------------------------------
129 //-----------------------------------------------------------------------
133 //-----------------------------------------------------------------------
135 //-----------------------------------------------------------------------
137 //-----------------------------------------------------------------------
139 //-----------------------------------------------------------------------
141 //-----------------------------------------------------------------------
143 //-----------------------------------------------------------------------
145 //-----------------------------------------------------------------------
147 //-----------------------------------------------------------------------
149 //-----------------------------------------------------------------------
151 //-----------------------------------------------------------------------
153 //-----------------------------------------------------------------------
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
);
172 //-----------------------------------------------------------------------
174 //-----------------------------------------------------------------------
176 //-----------------------------------------------------------------------
178 //-----------------------------------------------------------------------
180 //-----------------------------------------------------------------------
182 //-----------------------------------------------------------------------
184 //-----------------------------------------------------------------------
186 //-----------------------------------------------------------------------
188 static void handleChar ( void * pUserData
,
189 const Char8
* szData
,
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
);
234 //-----------------------------------------------------------------------
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 ----------------------------------*/
265 #endif /* _OSGXMLSCANPARSESKEL_H_ */