#include <cppdom.h>
Collaboration diagram for cppdom::XMLContext:

Public Methods | |
| XMLContext () | |
| ctor. More... | |
| virtual | ~XMLContext () |
| dtor. More... | |
| std::string | getEntity (const std::string &entname) |
| returns the entity representation for the named entity. More... | |
| std::string | getTagname (XMLTagNameHandle handle) |
| returns the tagname by the tagname handle. More... | |
| XMLTagNameHandle | insertTagname (const std::string &tagname) |
| inserts a tag name and returns a tag name handle to the string. More... | |
| XMLLocation & | getLocation () |
| returns the current location in the xml stream. More... | |
| virtual void | initContext () |
| called once when the context instance starts up; overwrite to customize. More... | |
event handling methods | |
| void | setEventHandler (XMLEventHandlerPtr ehptr) |
| sets the event handler; enables handling events. More... | |
| XMLEventHandler & | getEventHandler () |
| returns the currently used eventhandler (per reference). More... | |
| bool | handleEvents () const |
| returns if a valid event handler is set. More... | |
Protected Attributes | |
| bool | mInit |
| indicates if init_context() was already called. More... | |
| int | mNextHandle |
| next available tagname handle. More... | |
| XMLTagNameMap | mTagNames |
| matches XMLTagNameHandles to the real std::string's. More... | |
| XMLEntityMap | mEntities |
| Contains entity codes and their string representations. More... | |
| XMLLocation | mLocation |
| location of the xml input stream. More... | |
| bool | mHandleEvents |
| indicates if the event handler is used. More... | |
| XMLEventHandlerPtr | mEventHandler |
| current parsing event handler. More... | |
the class is the parsing context for the parsed xml document. the class has a tagname lookup table and an entity map
Definition at line 175 of file cppdom.h.
|
|
ctor.
Definition at line 138 of file cppdom.cpp. References mHandleEvents, mInit, and mNextHandle.
00139 : mEventHandler(new XMLEventHandler) 00140 { 00141 mInit = false; 00142 mNextHandle = 0; 00143 mHandleEvents = false; 00144 } |
|
|
dtor.
Definition at line 146 of file cppdom.cpp.
00147 {
00148 }
|
|
|
returns the entity representation for the named entity.
Definition at line 150 of file cppdom.cpp. References initContext(), mEntities, and mInit.
00151 {
00152 if (!mInit)
00153 {
00154 initContext();
00155 }
00156
00157 XMLEntityMap::const_iterator iter = mEntities.find(entName);
00158 return (iter == mEntities.end() ? entName : iter->second);
00159 }
|
|
|
returns the currently used eventhandler (per reference).
Definition at line 218 of file cppdom.cpp. References cppdom_boost::shared_ptr< class XMLEventHandler >::get(), and mEventHandler.
00219 {
00220 return *mEventHandler.get();
00221 }
|
|
|
returns the current location in the xml stream.
Definition at line 202 of file cppdom.cpp. References mLocation.
00203 {
00204 return mLocation;
00205 }
|
|
|
returns the tagname by the tagname handle.
Definition at line 161 of file cppdom.cpp. References initContext(), mInit, mTagNames, and cppdom::XMLTagNameHandle.
00162 {
00163 if (!mInit)
00164 {
00165 initContext();
00166 }
00167 XMLTagNameMap::const_iterator iter = mTagNames.find(handle);
00168
00169 std::string empty("");
00170 return (iter == mTagNames.end() ? empty : iter->second);
00171 }
|
|
|
returns if a valid event handler is set.
Definition at line 223 of file cppdom.cpp. References mHandleEvents.
00224 {
00225 return mHandleEvents;
00226 }
|
|
|
called once when the context instance starts up; overwrite to customize. @note: The base member should always be called, to set init to true Definition at line 207 of file cppdom.cpp. References mInit. Referenced by getEntity(), getTagname(), and insertTagname().
00208 {
00209 mInit = true;
00210 }
|
|
|
inserts a tag name and returns a tag name handle to the string.
Definition at line 173 of file cppdom.cpp. References initContext(), mInit, mNextHandle, mTagNames, and cppdom::XMLTagNameHandle.
00174 {
00175 if (!mInit)
00176 {
00177 initContext();
00178 }
00179
00180 // bugfix: first search, if the tagname is already in the list
00181 // since usually there are not much different tagnames, the search
00182 // shouldn't slow down parsing too much
00183 XMLTagNameMap::const_iterator iter,stop;
00184 iter = mTagNames.begin();
00185 stop = mTagNames.end();
00186
00187 for(; iter!=stop; ++iter)
00188 {
00189 if (iter->second == tagName)
00190 {
00191 return iter->first;
00192 }
00193 }
00194
00195 // insert new tagname
00196 XMLTagNameMap::value_type keyvaluepair(mNextHandle, tagName);
00197 mTagNames.insert(keyvaluepair);
00198
00199 return mNextHandle++;
00200 }
|
|
|
sets the event handler; enables handling events.
Definition at line 212 of file cppdom.cpp. References mEventHandler, and mHandleEvents.
00213 {
00214 mEventHandler = ehptr;
00215 mHandleEvents = true;
00216 }
|
|
|
Contains entity codes and their string representations.
Definition at line 216 of file cppdom.h. Referenced by getEntity(). |
|
|
current parsing event handler.
Definition at line 219 of file cppdom.h. Referenced by getEventHandler(), and setEventHandler(). |
|
|
indicates if the event handler is used.
Definition at line 218 of file cppdom.h. Referenced by handleEvents(), setEventHandler(), and XMLContext(). |
|
|
indicates if init_context() was already called.
Definition at line 213 of file cppdom.h. Referenced by getEntity(), getTagname(), initContext(), insertTagname(), and XMLContext(). |
|
|
location of the xml input stream.
Definition at line 217 of file cppdom.h. Referenced by getLocation(). |
|
|
next available tagname handle.
Definition at line 214 of file cppdom.h. Referenced by insertTagname(), and XMLContext(). |
|
|
matches XMLTagNameHandles to the real std::string's.
Definition at line 215 of file cppdom.h. Referenced by getTagname(), and insertTagname(). |
1.2.15