COPASI API  4.16.103
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
CExpatTemplate< CType > Class Template Reference

#include <CExpat.h>

Inheritance diagram for CExpatTemplate< CType >:
Inheritance graph
[legend]

Public Member Functions

 CExpatTemplate ()
 
bool create (const XML_Char *pszEncoding=NULL, const XML_Char *pszSep=NULL)
 
void destroy ()
 
void enableCdataSectionHandler (bool fEnable=true)
 
void enableCharacterDataHandler (bool fEnable=true)
 
void enableCommentHandler (bool fEnable=true)
 
void enableDefaultHandler (bool fEnable=true, bool fExpand=true)
 
void enableDoctypeDeclHandler (bool fEnable=true)
 
void enableElementHandler (bool fEnable=true)
 
void enableEndCdataSectionHandler (bool fEnable=true)
 
void enableEndDoctypeDeclHandler (bool fEnable=true)
 
void enableEndElementHandler (bool fEnable=true)
 
void enableEndNamespaceDeclHandler (bool fEnable=true)
 
void enableExternalEntityRefHandler (bool fEnable=true)
 
void enableNamespaceDeclHandler (bool fEnable=true)
 
void enableProcessingInstructionHandler (bool fEnable=true)
 
void enableSkippedEntityHandler (bool fEnable=true)
 
void enableStartCdataSectionHandler (bool fEnable=true)
 
void enableStartDoctypeDeclHandler (bool fEnable=true)
 
void enableStartElementHandler (bool fEnable=true)
 
void enableStartNamespaceDeclHandler (bool fEnable=true)
 
void enableUnknownEncodingHandler (bool fEnable=true)
 
void enableXmlDeclHandler (bool fEnable=true)
 
const char * getAttributeValue (const std::string &name, const char **attributes, const bool &required=true) const
 
const char * getAttributeValue (const std::string &name, const char **attributes, const char *def) const
 
voidgetBuffer (int nLength)
 
int getCurrentByteCount ()
 
long getCurrentByteIndex ()
 
int getCurrentColumnNumber ()
 
int getCurrentLineNumber () const
 
enum XML_Error getErrorCode ()
 
const XML_LChar * getErrorString ()
 
const char * getInputContext (int *pnOffset, int *pnSize)
 
void onCharacterData (const XML_Char *pszData, int nLength)
 
void onComment (const XML_Char *pszData)
 
void onDefault (const XML_Char *pszData, int nLength)
 
void onEndCdataSection ()
 
void onEndDoctypeDecl ()
 
void onEndElement (const XML_Char *pszName)
 
void onEndNamespaceDecl (const XML_Char *pszPrefix)
 
bool onExternalEntityRef (const XML_Char *pszContext, const XML_Char *pszBase, const XML_Char *pszSystemID, const XML_Char *pszPublicID)
 
void onProcessingInstruction (const XML_Char *pszTarget, const XML_Char *pszData)
 
void onSkippedEntityHandler (const XML_Char *, int)
 
void onStartCdataSection ()
 
void onStartDoctypeDecl (const XML_Char *pszDoctypeName, const XML_Char *pszSysID, const XML_Char *pszPubID, bool fHasInternalSubset)
 
void onStartElement (const XML_Char *pszName, const XML_Char **papszAttrs)
 
void onStartNamespaceDecl (const XML_Char *pszPrefix, const XML_Char *pszURI)
 
bool onUnknownEncoding (const XML_Char *pszName, XML_Encoding *pInfo)
 
void onXmlDecl (const XML_Char *pszVersion, const XML_Char *pszEncoding, bool fStandalone)
 
bool parse (const char *pszBuffer, int nLength=-1, bool fIsFinal=true)
 
bool parseBuffer (int nLength, bool fIsFinal=true)
 
 ~CExpatTemplate ()
 

Static Public Member Functions

static const XML_LChar * getErrorString (enum XML_Error nError)
 
static const XML_LChar * getExpatVersion ()
 
static void getExpatVersion (int &nMajor, int &nMinor, int &nMicro)
 
static bool toBool (const char *attribute)
 

Protected Member Functions

void onPostCreate ()
 

Static Protected Member Functions

static void characterDataHandler (void *pUserData, const XML_Char *pszData, int nLength)
 
static void commentHandler (void *pUserData, const XML_Char *pszData)
 
static void defaultHandler (void *pUserData, const XML_Char *pszData, int nLength)
 
static void endCdataSectionHandler (void *pUserData)
 
static void endDoctypeDeclHandler (void *pUserData)
 
static void endElementHandler (void *pUserData, const XML_Char *pszName)
 
static void endNamespaceDeclHandler (void *pUserData, const XML_Char *pszPrefix)
 
static int externalEntityRefHandler (XML_Parser pUserData, const XML_Char *pszContext, const XML_Char *pszBase, const XML_Char *pszSystemID, const XML_Char *pszPublicID)
 
static void processingInstructionHandler (void *pUserData, const XML_Char *pszTarget, const XML_Char *pszData)
 
static void skippedEntityHandler (void *pUserData, const XML_Char *entityName, int is_parameter_entity)
 
static void startCdataSectionHandler (void *pUserData)
 
static void startDoctypeDeclHandler (void *pUserData, const XML_Char *pszDoctypeName, const XML_Char *pszSysID, const XML_Char *pszPubID, int nHasInternalSubset)
 
static void startElementHandler (void *pUserData, const XML_Char *pszName, const XML_Char **papszAttrs)
 
static void startNamespaceDeclHandler (void *pUserData, const XML_Char *pszPrefix, const XML_Char *pszURI)
 
static int unknownEncodingHandler (void *pUserData, const XML_Char *pszName, XML_Encoding *pInfo)
 
static void xmlDeclHandler (void *pUserData, const XML_Char *pszVersion, const XML_Char *pszEncoding, int nStandalone)
 

Protected Attributes

XML_Parser mParser
 

Detailed Description

template<class CType>
class CExpatTemplate< CType >

This file describes the C++ interface to the expat library used by COPASI.

Created for COPASI by Stefan Hoops 2003 Copyright Stefan Hoops CExpatTemplate class. The class CExpatTemplate is a template defining a C++ interface to the expat library.

Created for COPASI by Stefan Hoops 2003

Definition at line 40 of file CExpat.h.

Constructor & Destructor Documentation

template<class CType>
CExpatTemplate< CType >::CExpatTemplate ( )
inline

Default constructor

Definition at line 65 of file CExpat.h.

65  :
66  mParser(NULL)
67  {}
XML_Parser mParser
Definition: CExpat.h:48
template<class CType>
CExpatTemplate< CType >::~CExpatTemplate ( )
inline

Destructor

Definition at line 72 of file CExpat.h.

72 {destroy();}
void destroy()
Definition: CExpat.h:54

Member Function Documentation

template<class CType>
static void CExpatTemplate< CType >::characterDataHandler ( void pUserData,
const XML_Char *  pszData,
int  nLength 
)
inlinestaticprotected

Character data handler wrapper

Parameters
void*pUserData
constXML_Char *pszData
intnLength

Definition at line 776 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableCharacterDataHandler().

779  {
780  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
781  pThis->onCharacterData(pszData, nLength);
782  }
template<class CType>
static void CExpatTemplate< CType >::commentHandler ( void pUserData,
const XML_Char *  pszData 
)
inlinestaticprotected

Comment handler wrapper

Parameters
void*pUserData
constXML_Char *pszData

Definition at line 803 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableCommentHandler().

805  {
806  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
807  pThis->onComment(pszData);
808  }
template<class CType>
bool CExpatTemplate< CType >::create ( const XML_Char *  pszEncoding = NULL,
const XML_Char *  pszSep = NULL 
)
inline

Create a parser

Parameters
constXML_Char *pszEncoding (Default = NULL)
constXML_Char *pszSep (Default = NULL)

Definition at line 79 of file CExpat.h.

81  {
82  //
83  // Destroy the old parser
84  //
85 
86  destroy();
87 
88  //
89  // If the encoding or separator are empty, then NULL
90  //
91 
92  if (pszEncoding != NULL && pszEncoding [0] == 0)
93  pszEncoding = NULL;
94 
95  if (pszSep != NULL && pszSep [0] == 0)
96  pszSep = NULL;
97 
98  //
99  // Create the new one
100  //
101 
102  mParser = XML_ParserCreate_MM(pszEncoding, NULL, pszSep);
103 
104  if (mParser == NULL)
105  return false;
106 
107  //
108  // Invoke the post create routine
109  //
110 
111  CType *pThis = static_cast <CType *>(this);
112  pThis->onPostCreate();
113 
114  //
115  // Set the user data used in callbacks
116  //
117 
118  XML_SetUserData(mParser, (void *) this);
119 
120  //
121  // Allow the handling of skipped entities, e.g. in XHTML
122  //
123  XML_UseForeignDTD(mParser, XML_TRUE);
124 
125  return true;
126  }
XML_Parser mParser
Definition: CExpat.h:48
void destroy()
Definition: CExpat.h:54
template<class CType>
static void CExpatTemplate< CType >::defaultHandler ( void pUserData,
const XML_Char *  pszData,
int  nLength 
)
inlinestaticprotected

Default wrapper

Parameters
void*pUserData
constXML_Char *pszData
intnLength

Definition at line 836 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableDefaultHandler().

839  {
840  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
841  pThis->onDefault(pszData, nLength);
842  }
template<class CType>
void CExpatTemplate< CType >::destroy ( )
inline

Destroy the parser

Definition at line 54 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::create(), and CExpatTemplate< CExpat >::~CExpatTemplate().

55  {
56  if (mParser != NULL)
57  XML_ParserFree(mParser);
58 
59  mParser = NULL;
60  }
XML_Parser mParser
Definition: CExpat.h:48
template<class CType>
void CExpatTemplate< CType >::enableCdataSectionHandler ( bool  fEnable = true)
inline

Enable/Disable the CDATA section handlers

Parameters
boolfEnable (Default: true)

Definition at line 298 of file CExpat.h.

299  {
300  assert(mParser != NULL);
303  }
XML_Parser mParser
Definition: CExpat.h:48
void enableEndCdataSectionHandler(bool fEnable=true)
Definition: CExpat.h:287
void enableStartCdataSectionHandler(bool fEnable=true)
Definition: CExpat.h:276
template<class CType>
void CExpatTemplate< CType >::enableCharacterDataHandler ( bool  fEnable = true)
inline

Enable/Disable the character data handler

Parameters
boolfEnable (Default: true)

Definition at line 244 of file CExpat.h.

245  {
246  assert(mParser != NULL);
247  XML_SetCharacterDataHandler(mParser,
248  fEnable ? characterDataHandler : NULL);
249  }
XML_Parser mParser
Definition: CExpat.h:48
static void characterDataHandler(void *pUserData, const XML_Char *pszData, int nLength)
Definition: CExpat.h:776
template<class CType>
void CExpatTemplate< CType >::enableCommentHandler ( bool  fEnable = true)
inline

Enable/Disable the comment handler

Parameters
boolfEnable (Default: true)

Definition at line 266 of file CExpat.h.

267  {
268  assert(mParser != NULL);
269  XML_SetCommentHandler(mParser, fEnable ? commentHandler : NULL);
270  }
XML_Parser mParser
Definition: CExpat.h:48
static void commentHandler(void *pUserData, const XML_Char *pszData)
Definition: CExpat.h:803
template<class CType>
void CExpatTemplate< CType >::enableDefaultHandler ( bool  fEnable = true,
bool  fExpand = true 
)
inline

Enable/Disable default handler

Parameters
boolfEnable (Default: true)

Definition at line 309 of file CExpat.h.

310  {
311  assert(mParser != NULL);
312 
313  if (fExpand)
314  {
315  XML_SetDefaultHandlerExpand(mParser,
316  fEnable ? defaultHandler : NULL);
317  }
318  else
319  XML_SetDefaultHandler(mParser, fEnable ? defaultHandler : NULL);
320  }
static void defaultHandler(void *pUserData, const XML_Char *pszData, int nLength)
Definition: CExpat.h:836
XML_Parser mParser
Definition: CExpat.h:48
template<class CType>
void CExpatTemplate< CType >::enableDoctypeDeclHandler ( bool  fEnable = true)
inline

Enable/Disable the DOCTYPE declaration handler

Parameters
boolfEnable (Default: true)

Definition at line 424 of file CExpat.h.

425  {
426  assert(mParser != NULL);
429  }
void enableStartDoctypeDeclHandler(bool fEnable=true)
Definition: CExpat.h:402
XML_Parser mParser
Definition: CExpat.h:48
void enableEndDoctypeDeclHandler(bool fEnable=true)
Definition: CExpat.h:413
template<class CType>
void CExpatTemplate< CType >::enableElementHandler ( bool  fEnable = true)
inline

Enable/Disable the element handlers

Parameters
boolfEnable (Default: true)

Definition at line 233 of file CExpat.h.

234  {
235  assert(mParser != NULL);
236  enableStartElementHandler(fEnable);
237  enableEndElementHandler(fEnable);
238  }
void enableEndElementHandler(bool fEnable=true)
Definition: CExpat.h:223
XML_Parser mParser
Definition: CExpat.h:48
void enableStartElementHandler(bool fEnable=true)
Definition: CExpat.h:213
template<class CType>
void CExpatTemplate< CType >::enableEndCdataSectionHandler ( bool  fEnable = true)
inline

Enable/Disable the end CDATA section handlers

Parameters
boolfEnable (Default: true)

Definition at line 287 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableCdataSectionHandler().

288  {
289  assert(mParser != NULL);
290  XML_SetEndCdataSectionHandler(mParser,
291  fEnable ? endCdataSectionHandler : NULL);
292  }
XML_Parser mParser
Definition: CExpat.h:48
static void endCdataSectionHandler(void *pUserData)
Definition: CExpat.h:824
template<class CType>
void CExpatTemplate< CType >::enableEndDoctypeDeclHandler ( bool  fEnable = true)
inline

Enable/Disable the end DOCTYPE declaration handler

Parameters
boolfEnable (Default: true)

Definition at line 413 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableDoctypeDeclHandler().

414  {
415  assert(mParser != NULL);
416  XML_SetEndDoctypeDeclHandler(mParser,
417  fEnable ? endDoctypeDeclHandler : NULL);
418  }
XML_Parser mParser
Definition: CExpat.h:48
static void endDoctypeDeclHandler(void *pUserData)
Definition: CExpat.h:965
template<class CType>
void CExpatTemplate< CType >::enableEndElementHandler ( bool  fEnable = true)
inline

Enable/Disable end element handler

Parameters
boolfEnable (Default: true)

Definition at line 223 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableElementHandler().

224  {
225  assert(mParser != NULL);
226  XML_SetEndElementHandler(mParser, fEnable ? endElementHandler : NULL);
227  }
XML_Parser mParser
Definition: CExpat.h:48
static void endElementHandler(void *pUserData, const XML_Char *pszName)
Definition: CExpat.h:763
template<class CType>
void CExpatTemplate< CType >::enableEndNamespaceDeclHandler ( bool  fEnable = true)
inline

Enable/Disable end namespace handler

Parameters
boolfEnable (Default: true)

Definition at line 371 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableNamespaceDeclHandler().

372  {
373  assert(mParser != NULL);
374  XML_SetEndNamespaceDeclHandler(mParser,
375  fEnable ? endNamespaceDeclHandler : NULL);
376  }
XML_Parser mParser
Definition: CExpat.h:48
static void endNamespaceDeclHandler(void *pUserData, const XML_Char *pszPrefix)
Definition: CExpat.h:919
template<class CType>
void CExpatTemplate< CType >::enableExternalEntityRefHandler ( bool  fEnable = true)
inline

Enable/Disable external entity ref handler

Parameters
boolfEnable (Default: true)

Definition at line 326 of file CExpat.h.

327  {
328  assert(mParser != NULL);
329  XML_SetExternalEntityRefHandler(mParser,
330  fEnable ? externalEntityRefHandler : NULL);
331  }
XML_Parser mParser
Definition: CExpat.h:48
static int externalEntityRefHandler(XML_Parser pUserData, const XML_Char *pszContext, const XML_Char *pszBase, const XML_Char *pszSystemID, const XML_Char *pszPublicID)
Definition: CExpat.h:852
template<class CType>
void CExpatTemplate< CType >::enableNamespaceDeclHandler ( bool  fEnable = true)
inline

Enable/Disable namespace handlers

Parameters
boolfEnable (Default: true)

Definition at line 382 of file CExpat.h.

383  {
386  }
void enableEndNamespaceDeclHandler(bool fEnable=true)
Definition: CExpat.h:371
void enableStartNamespaceDeclHandler(bool fEnable=true)
Definition: CExpat.h:360
template<class CType>
void CExpatTemplate< CType >::enableProcessingInstructionHandler ( bool  fEnable = true)
inline

Enable/Disable the processing instruction handler

Parameters
boolfEnable (Default: true)

Definition at line 255 of file CExpat.h.

256  {
257  assert(mParser != NULL);
258  XML_SetProcessingInstructionHandler(mParser,
259  fEnable ? processingInstructionHandler : NULL);
260  }
XML_Parser mParser
Definition: CExpat.h:48
static void processingInstructionHandler(void *pUserData, const XML_Char *pszTarget, const XML_Char *pszData)
Definition: CExpat.h:790
template<class CType>
void CExpatTemplate< CType >::enableSkippedEntityHandler ( bool  fEnable = true)
inline

Enable/Disable the skipped entity handler

Parameters
boolfEnable (Default: true)

Definition at line 337 of file CExpat.h.

338  {
339  assert(mParser != NULL);
340  XML_SetSkippedEntityHandler(mParser,
341  fEnable ? skippedEntityHandler : NULL);
342  }
static void skippedEntityHandler(void *pUserData, const XML_Char *entityName, int is_parameter_entity)
Definition: CExpat.h:878
XML_Parser mParser
Definition: CExpat.h:48
template<class CType>
void CExpatTemplate< CType >::enableStartCdataSectionHandler ( bool  fEnable = true)
inline

Enable/Disable the start CDATA section handler

Parameters
boolfEnable (Default: true)

Definition at line 276 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableCdataSectionHandler().

277  {
278  assert(mParser != NULL);
279  XML_SetStartCdataSectionHandler(mParser,
280  fEnable ? startCdataSectionHandler : NULL);
281  }
XML_Parser mParser
Definition: CExpat.h:48
static void startCdataSectionHandler(void *pUserData)
Definition: CExpat.h:814
template<class CType>
void CExpatTemplate< CType >::enableStartDoctypeDeclHandler ( bool  fEnable = true)
inline

Enable/Disable the start DOCTYPE declaration handler

Parameters
boolfEnable (Default: true)

Definition at line 402 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableDoctypeDeclHandler().

403  {
404  assert(mParser != NULL);
405  XML_SetStartDoctypeDeclHandler(mParser,
406  fEnable ? startDoctypeDeclHandler : NULL);
407  }
XML_Parser mParser
Definition: CExpat.h:48
static void startDoctypeDeclHandler(void *pUserData, const XML_Char *pszDoctypeName, const XML_Char *pszSysID, const XML_Char *pszPubID, int nHasInternalSubset)
Definition: CExpat.h:950
template<class CType>
void CExpatTemplate< CType >::enableStartElementHandler ( bool  fEnable = true)
inline

Enable/Disable the start element handler

Parameters
boolfEnable (Default: true)

Definition at line 213 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableElementHandler().

214  {
215  assert(mParser != NULL);
216  XML_SetStartElementHandler(mParser, fEnable ? startElementHandler : NULL);
217  }
XML_Parser mParser
Definition: CExpat.h:48
static void startElementHandler(void *pUserData, const XML_Char *pszName, const XML_Char **papszAttrs)
Definition: CExpat.h:750
template<class CType>
void CExpatTemplate< CType >::enableStartNamespaceDeclHandler ( bool  fEnable = true)
inline

Enable/Disable start namespace handler

Parameters
boolfEnable (Default: true)

Definition at line 360 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableNamespaceDeclHandler().

361  {
362  assert(mParser != NULL);
363  XML_SetStartNamespaceDeclHandler(mParser,
364  fEnable ? startNamespaceDeclHandler : NULL);
365  }
XML_Parser mParser
Definition: CExpat.h:48
static void startNamespaceDeclHandler(void *pUserData, const XML_Char *pszPrefix, const XML_Char *pszURI)
Definition: CExpat.h:906
template<class CType>
void CExpatTemplate< CType >::enableUnknownEncodingHandler ( bool  fEnable = true)
inline

Enable/Disable unknown encoding handler

Parameters
boolfEnable (Default: true)

Definition at line 348 of file CExpat.h.

349  {
350  assert(mParser != NULL);
351  XML_SetUnknownEncodingHandler(mParser,
352  fEnable ? unknownEncodingHandler : NULL,
353  NULL);
354  }
XML_Parser mParser
Definition: CExpat.h:48
static int unknownEncodingHandler(void *pUserData, const XML_Char *pszName, XML_Encoding *pInfo)
Definition: CExpat.h:892
template<class CType>
void CExpatTemplate< CType >::enableXmlDeclHandler ( bool  fEnable = true)
inline

Enable/Disable the XML declaration handler

Parameters
boolfEnable (Default: true)

Definition at line 392 of file CExpat.h.

393  {
394  assert(mParser != NULL);
395  XML_SetXmlDeclHandler(mParser, fEnable ? xmlDeclHandler : NULL);
396  }
XML_Parser mParser
Definition: CExpat.h:48
static void xmlDeclHandler(void *pUserData, const XML_Char *pszVersion, const XML_Char *pszEncoding, int nStandalone)
Definition: CExpat.h:933
template<class CType>
static void CExpatTemplate< CType >::endCdataSectionHandler ( void pUserData)
inlinestaticprotected

End CDATA section wrapper

Parameters
void*pUserData

Definition at line 824 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableEndCdataSectionHandler().

825  {
826  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
827  pThis->onEndCdataSection();
828  }
template<class CType>
static void CExpatTemplate< CType >::endDoctypeDeclHandler ( void pUserData)
inlinestaticprotected

End Doctype declaration wrapper

Parameters
void*pUserData

Definition at line 965 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableEndDoctypeDeclHandler().

966  {
967  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
968  pThis->onEndDoctypeDecl();
969  }
template<class CType>
static void CExpatTemplate< CType >::endElementHandler ( void pUserData,
const XML_Char *  pszName 
)
inlinestaticprotected

End element handler wrapper

Parameters
void*pUserData
constXML_Char *pszName

Definition at line 763 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableEndElementHandler().

765  {
766  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
767  pThis->onEndElement(pszName);
768  }
template<class CType>
static void CExpatTemplate< CType >::endNamespaceDeclHandler ( void pUserData,
const XML_Char *  pszPrefix 
)
inlinestaticprotected

End namespace decl wrapper

Parameters
void*pUserData
constXML_Char *pszPrefix

Definition at line 919 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableEndNamespaceDeclHandler().

921  {
922  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
923  pThis->onEndNamespaceDecl(pszPrefix);
924  }
template<class CType>
static int CExpatTemplate< CType >::externalEntityRefHandler ( XML_Parser  pUserData,
const XML_Char *  pszContext,
const XML_Char *  pszBase,
const XML_Char *  pszSystemID,
const XML_Char *  pszPublicID 
)
inlinestaticprotected

External entity ref wrapper

Parameters
void*pUserData
constXML_Char *pszContext
constXML_Char *pszBase
constXML_Char *pszSystemID
constXML_Char *pszPublicID

Definition at line 852 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableExternalEntityRefHandler().

857  {
858  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
859  return pThis->onExternalEntityRef(pszContext,
860  pszBase, pszSystemID, pszPublicID) ? 1 : 0;
861  }
template<class CType>
const char* CExpatTemplate< CType >::getAttributeValue ( const std::string &  name,
const char **  attributes,
const bool &  required = true 
) const
inline

Retrieve the attribute value for the given name out of the list of attributes. If required is true and the attribute is not found an exception is thrown. If required is false and the attribute is not found NULL is returned.

Parameters
conststd::string & name
constchar ** attributes
constbool & required (default: true)
Returns
const char * value

Definition at line 685 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::getAttributeValue().

688  {
689  unsigned C_INT32 i;
690 
691  for (i = 0; attributes[i]; i += 2)
692  if (attributes[i] == name) break;
693 
694  if (attributes[i]) return attributes[i + 1];
695 
696  if (required)
698  name.c_str(), getCurrentLineNumber());
699 
700  return NULL;
701  }
#define MCXML
#define C_INT32
Definition: copasi.h:90
int getCurrentLineNumber() const
Definition: CExpat.h:470
template<class CType>
const char* CExpatTemplate< CType >::getAttributeValue ( const std::string &  name,
const char **  attributes,
const char *  def 
) const
inline

Retrieve the attribute value for the given name out of the list of attributes. If the attribute is not found default is returned.

Parameters
conststd::string & name
constchar ** attributes
constchar * default
Returns
const char * value

Definition at line 711 of file CExpat.h.

714  {
715  const char * tmp = getAttributeValue(name, attributes, false);
716 
717  if (!tmp) return def;
718 
719  return tmp;
720  }
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
template<class CType>
void* CExpatTemplate< CType >::getBuffer ( int  nLength)
inline

Get the internal buffer

Definition at line 203 of file CExpat.h.

204  {
205  assert(mParser != NULL);
206  return XML_GetBuffer(mParser, nLength);
207  }
XML_Parser mParser
Definition: CExpat.h:48
template<class CType>
int CExpatTemplate< CType >::getCurrentByteCount ( )
inline

Get the current byte count

Returns
in byteCount

Definition at line 490 of file CExpat.h.

491  {
492  assert(mParser != NULL);
493  return XML_GetCurrentByteCount(mParser);
494  }
XML_Parser mParser
Definition: CExpat.h:48
template<class CType>
long CExpatTemplate< CType >::getCurrentByteIndex ( )
inline

Get the current byte index

Returns
long byteIndex

Definition at line 460 of file CExpat.h.

461  {
462  assert(mParser != NULL);
463  return XML_GetCurrentByteIndex(mParser);
464  }
XML_Parser mParser
Definition: CExpat.h:48
template<class CType>
int CExpatTemplate< CType >::getCurrentColumnNumber ( )
inline

Get the current column number

Returns
in cloumnNumber

Definition at line 480 of file CExpat.h.

Referenced by CCopasiXML::load(), and CConfigurationFile::CXML::load().

481  {
482  assert(mParser != NULL);
483  return XML_GetCurrentColumnNumber(mParser);
484  }
XML_Parser mParser
Definition: CExpat.h:48
template<class CType>
int CExpatTemplate< CType >::getCurrentLineNumber ( ) const
inline

Get the current line number

Returns
ing lineNumber

Definition at line 470 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::getAttributeValue(), CCopasiXML::load(), and CConfigurationFile::CXML::load().

471  {
472  assert(mParser != NULL);
473  return XML_GetCurrentLineNumber(mParser);
474  }
XML_Parser mParser
Definition: CExpat.h:48
template<class CType>
enum XML_Error CExpatTemplate< CType >::getErrorCode ( )
inline

Get last error

Returns
enum XML_Error

Definition at line 435 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::getErrorString().

436  {
437  assert(mParser != NULL);
438  return XML_GetErrorCode(mParser);
439  }
XML_Parser mParser
Definition: CExpat.h:48
template<class CType>
const XML_LChar* CExpatTemplate< CType >::getErrorString ( )
inline

Get last error string

Returns
const XML_LChar * errorString

Definition at line 445 of file CExpat.h.

Referenced by CCopasiXML::load(), and CConfigurationFile::CXML::load().

446  {return XML_ErrorString(getErrorCode());}
enum XML_Error getErrorCode()
Definition: CExpat.h:435
template<class CType>
static const XML_LChar* CExpatTemplate< CType >::getErrorString ( enum XML_Error  nError)
inlinestatic

Get error string

Parameters
enumXML_Error nError
Returns
const XML_LChar * errorString

Definition at line 453 of file CExpat.h.

454  {return XML_ErrorString(nError);}
template<class CType>
static const XML_LChar* CExpatTemplate< CType >::getExpatVersion ( )
inlinestatic

Return the version string

Returns
const XML_LChar * version

Definition at line 510 of file CExpat.h.

511  {return XML_ExpatVersion();}
template<class CType>
static void CExpatTemplate< CType >::getExpatVersion ( int &  nMajor,
int &  nMinor,
int &  nMicro 
)
inlinestatic

Get the version information

Parameters
intnMajor
intnMinor
intnMicro

Definition at line 521 of file CExpat.h.

522  {
523  XML_Expat_Version v = XML_ExpatVersionInfo();
524 
525  nMajor = v.major;
526  nMinor = v.minor;
527  nMicro = v.micro;
528  }
template<class CType>
const char* CExpatTemplate< CType >::getInputContext ( int *  pnOffset,
int *  pnSize 
)
inline

Get the input context char * inputContext

Definition at line 500 of file CExpat.h.

501  {
502  assert(mParser != NULL);
503  return XML_GetInputContext(mParser, pnOffset, pnSize);
504  }
XML_Parser mParser
Definition: CExpat.h:48
template<class CType>
void CExpatTemplate< CType >::onCharacterData ( const XML_Char *  pszData,
int  nLength 
)
inline

Character data handler

Parameters
constXML_Char *pszData
intnLength

Definition at line 550 of file CExpat.h.

551  {return;}
template<class CType>
void CExpatTemplate< CType >::onComment ( const XML_Char *  pszData)
inline

Comment handler

Parameters
constXML_Char *pszData

Definition at line 566 of file CExpat.h.

567  {return;}
template<class CType>
void CExpatTemplate< CType >::onDefault ( const XML_Char *  pszData,
int  nLength 
)
inline

Default handler

Parameters
constXML_Char *pszData
intnLength

Definition at line 586 of file CExpat.h.

587  {return;}
template<class CType>
void CExpatTemplate< CType >::onEndCdataSection ( )
inline

End CDATA section handler

Definition at line 578 of file CExpat.h.

579  {return;}
template<class CType>
void CExpatTemplate< CType >::onEndDoctypeDecl ( )
inline

End DOCTYPE declaration handler

Definition at line 671 of file CExpat.h.

672  {return;}
template<class CType>
void CExpatTemplate< CType >::onEndElement ( const XML_Char *  pszName)
inline

End element handler

Parameters
constXML_Char *pszName

Definition at line 542 of file CExpat.h.

543  {return;}
template<class CType>
void CExpatTemplate< CType >::onEndNamespaceDecl ( const XML_Char *  pszPrefix)
inline

End namespace declaration handler

Parameters
constXML_Char *pszPrefix

Definition at line 641 of file CExpat.h.

642  {return;}
template<class CType>
bool CExpatTemplate< CType >::onExternalEntityRef ( const XML_Char *  pszContext,
const XML_Char *  pszBase,
const XML_Char *  pszSystemID,
const XML_Char *  pszPublicID 
)
inline

External entity ref handler

Parameters
constXML_Char *pszContext
constXML_Char *pszBase
constXML_Char *pszSystemID
constXML_Char *pszPublicID

Definition at line 596 of file CExpat.h.

600  {return false;}
template<class CType>
void CExpatTemplate< CType >::onPostCreate ( )
inlineprotected

Handle any post creation

Definition at line 741 of file CExpat.h.

742  {}
template<class CType>
void CExpatTemplate< CType >::onProcessingInstruction ( const XML_Char *  pszTarget,
const XML_Char *  pszData 
)
inline

Processing instruction handler

Parameters
constXML_Char *pszTarget
constXML_Char *pszData

Definition at line 558 of file CExpat.h.

560  {return;}
template<class CType>
void CExpatTemplate< CType >::onSkippedEntityHandler ( const XML_Char *  ,
int   
)
inline

Skipped entity handler This is called in two situations: 1) An entity reference is encountered for which no declaration has been read and this is not an error. 2) An internal entity reference is read, but not expanded, because XML_SetDefaultHandler has been called. Note: skipped parameter entities in declarations and skipped general entities in attribute values cannot be reported, because the event would be out of sync with the reporting of the declarations or attribute values

Parameters
constXML_Char *entityName
intis_parameter_entity

Definition at line 616 of file CExpat.h.

618  {return;}
template<class CType>
void CExpatTemplate< CType >::onStartCdataSection ( )
inline

Start CDATA section handler

Definition at line 572 of file CExpat.h.

573  {return;}
template<class CType>
void CExpatTemplate< CType >::onStartDoctypeDecl ( const XML_Char *  pszDoctypeName,
const XML_Char *  pszSysID,
const XML_Char *  pszPubID,
bool  fHasInternalSubset 
)
inline

Start DOCTYPE declaration handler

Parameters
constXML_Char *pszDoctypeName
constXML_Char *pszSysID
constXML_Char *pszPubID
boolfHasInternalSubset

Definition at line 662 of file CExpat.h.

666  {return;}
template<class CType>
void CExpatTemplate< CType >::onStartElement ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
inline

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 535 of file CExpat.h.

536  {return;}
template<class CType>
void CExpatTemplate< CType >::onStartNamespaceDecl ( const XML_Char *  pszPrefix,
const XML_Char *  pszURI 
)
inline

Start namespace declaration handler

Parameters
constXML_Char *pszPrefix
constXML_Char *pszURI

Definition at line 633 of file CExpat.h.

635  {return;}
template<class CType>
bool CExpatTemplate< CType >::onUnknownEncoding ( const XML_Char *  pszName,
XML_Encoding *  pInfo 
)
inline

Unknown encoding handler

Parameters
constXML_Char *pszName
XML_Encoding*pInfo

Definition at line 625 of file CExpat.h.

626  {return false;}
template<class CType>
void CExpatTemplate< CType >::onXmlDecl ( const XML_Char *  pszVersion,
const XML_Char *  pszEncoding,
bool  fStandalone 
)
inline

XML declaration handler

Parameters
constXML_Char *pszVersion
constXML_Char *pszEncoding
boolfStandalone

Definition at line 650 of file CExpat.h.

653  {return;}
template<class CType>
bool CExpatTemplate< CType >::parse ( const char *  pszBuffer,
int  nLength = -1,
bool  fIsFinal = true 
)
inline

Parse a block of character data

Parameters
constchar *pszBuffer
intnLength (Default: -1 (zero terminated))
boolfIsFinal (Default: true)
Returns
bool Success

Definition at line 135 of file CExpat.h.

Referenced by CAnnotation::isValidXML(), CCopasiXML::load(), and CConfigurationFile::CXML::load().

136  {
137  //
138  // Validate
139  //
140 
141  assert(mParser != NULL);
142 
143  //
144  // Get the length if not specified
145  //
146 
147  if (nLength < 0)
148  nLength = (int) strlen(pszBuffer);
149 
150  //
151  // Invoke the parser
152  //
153 
154  return XML_Parse(mParser, pszBuffer, nLength, fIsFinal) != 0;
155  }
XML_Parser mParser
Definition: CExpat.h:48
template<class CType>
bool CExpatTemplate< CType >::parseBuffer ( int  nLength,
bool  fIsFinal = true 
)
inline

Parse internal buffer

Parameters
intnLength
boolfIsFinal (Default: true)
Returns
bool Success

Definition at line 194 of file CExpat.h.

195  {
196  assert(mParser != NULL);
197  return XML_ParseBuffer(mParser, nLength, fIsFinal) != 0;
198  }
XML_Parser mParser
Definition: CExpat.h:48
template<class CType>
static void CExpatTemplate< CType >::processingInstructionHandler ( void pUserData,
const XML_Char *  pszTarget,
const XML_Char *  pszData 
)
inlinestaticprotected

Processing instruction handler wrapper

Parameters
void*pUserData
constXML_Char *pszTarget
constXML_Char *pszData

Definition at line 790 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableProcessingInstructionHandler().

793  {
794  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
795  pThis->onProcessingInstruction(pszTarget, pszData);
796  }
template<class CType>
static void CExpatTemplate< CType >::skippedEntityHandler ( void pUserData,
const XML_Char *  entityName,
int  is_parameter_entity 
)
inlinestaticprotected

Skipped entity handler This is called in two situations: 1) An entity reference is encountered for which no declaration has been read and this is not an error. 2) An internal entity reference is read, but not expanded, because XML_SetDefaultHandler has been called. Note: skipped parameter entities in declarations and skipped general entities in attribute values cannot be reported, because the event would be out of sync with the reporting of the declarations or attribute values

Parameters
void*pUserData
constXML_Char *entityName
intis_parameter_entity

Definition at line 878 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableSkippedEntityHandler().

881  {
882  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
883  pThis->onSkippedEntityHandler(entityName, is_parameter_entity);
884  }
template<class CType>
static void CExpatTemplate< CType >::startCdataSectionHandler ( void pUserData)
inlinestaticprotected

Start CDATA section wrapper

Parameters
void*pUserData

Definition at line 814 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableStartCdataSectionHandler().

815  {
816  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
817  pThis->onStartCdataSection();
818  }
template<class CType>
static void CExpatTemplate< CType >::startDoctypeDeclHandler ( void pUserData,
const XML_Char *  pszDoctypeName,
const XML_Char *  pszSysID,
const XML_Char *  pszPubID,
int  nHasInternalSubset 
)
inlinestaticprotected

Start Doctype declaration wrapper

Parameters
void*pUserData
constXML_Char *pszDoctypeName
constXML_Char *pszSysID
constXML_Char *pszPubID
intnHasInternalSubset

Definition at line 950 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableStartDoctypeDeclHandler().

955  {
956  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
957  pThis->onStartDoctypeDecl(pszDoctypeName, pszSysID,
958  pszPubID, nHasInternalSubset != 0);
959  }
template<class CType>
static void CExpatTemplate< CType >::startElementHandler ( void pUserData,
const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
inlinestaticprotected

Start element handler wrapper

Parameters
void*pUserData
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 750 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableStartElementHandler().

753  {
754  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
755  pThis->onStartElement(pszName, papszAttrs);
756  }
template<class CType>
static void CExpatTemplate< CType >::startNamespaceDeclHandler ( void pUserData,
const XML_Char *  pszPrefix,
const XML_Char *  pszURI 
)
inlinestaticprotected

Start namespace decl wrapper

Parameters
void*pUserData
constXML_Char *pszPrefix
constXML_Char *pszURI

Definition at line 906 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableStartNamespaceDeclHandler().

909  {
910  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
911  pThis->onStartNamespaceDecl(pszPrefix, pszURI);
912  }
template<class CType>
static bool CExpatTemplate< CType >::toBool ( const char *  attribute)
inlinestatic

Convert an attribute of type xs:boolean to bool. If attribute is NULL false is returned.

Parameters
constchar * attribute
Returns
bool

Definition at line 728 of file CExpat.h.

729  {
730  if (!attribute) return false;
731 
732  if (!strcmp(attribute, "true") || !strcmp(attribute, "1")) return true;
733 
734  return false;
735  }
template<class CType>
static int CExpatTemplate< CType >::unknownEncodingHandler ( void pUserData,
const XML_Char *  pszName,
XML_Encoding *  pInfo 
)
inlinestaticprotected

Unknown encoding wrapper

Parameters
void*pUserData
constXML_Char *pszName
XML_Encoding*pInfo

Definition at line 892 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableUnknownEncodingHandler().

895  {
896  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
897  return pThis->onUnknownEncoding(pszName, pInfo) ? 1 : 0;
898  }
template<class CType>
static void CExpatTemplate< CType >::xmlDeclHandler ( void pUserData,
const XML_Char *  pszVersion,
const XML_Char *  pszEncoding,
int  nStandalone 
)
inlinestaticprotected

XML declaration wrapper

Parameters
void*pUserData
constXML_Char *pszVersion
constXML_Char *pszEncoding
intnStandalone

Definition at line 933 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::enableXmlDeclHandler().

937  {
938  CType *pThis = static_cast <CType *>((CExpatTemplate <CType> *) pUserData);
939  pThis->onXmlDecl(pszVersion, pszEncoding, nStandalone != 0);
940  }

Member Data Documentation

template<class CType>
XML_Parser CExpatTemplate< CType >::mParser
protected

The expat parser

Definition at line 48 of file CExpat.h.

Referenced by CExpatTemplate< CExpat >::create(), CExpatTemplate< CExpat >::destroy(), CExpatTemplate< CExpat >::enableCdataSectionHandler(), CExpatTemplate< CExpat >::enableCharacterDataHandler(), CExpatTemplate< CExpat >::enableCommentHandler(), CExpatTemplate< CExpat >::enableDefaultHandler(), CExpatTemplate< CExpat >::enableDoctypeDeclHandler(), CExpatTemplate< CExpat >::enableElementHandler(), CExpatTemplate< CExpat >::enableEndCdataSectionHandler(), CExpatTemplate< CExpat >::enableEndDoctypeDeclHandler(), CExpatTemplate< CExpat >::enableEndElementHandler(), CExpatTemplate< CExpat >::enableEndNamespaceDeclHandler(), CExpatTemplate< CExpat >::enableExternalEntityRefHandler(), CExpatTemplate< CExpat >::enableProcessingInstructionHandler(), CExpatTemplate< CExpat >::enableSkippedEntityHandler(), CExpatTemplate< CExpat >::enableStartCdataSectionHandler(), CExpatTemplate< CExpat >::enableStartDoctypeDeclHandler(), CExpatTemplate< CExpat >::enableStartElementHandler(), CExpatTemplate< CExpat >::enableStartNamespaceDeclHandler(), CExpatTemplate< CExpat >::enableUnknownEncodingHandler(), CExpatTemplate< CExpat >::enableXmlDeclHandler(), CExpatTemplate< CExpat >::getBuffer(), CExpatTemplate< CExpat >::getCurrentByteCount(), CExpatTemplate< CExpat >::getCurrentByteIndex(), CExpatTemplate< CExpat >::getCurrentColumnNumber(), CExpatTemplate< CExpat >::getCurrentLineNumber(), CExpatTemplate< CExpat >::getErrorCode(), CExpatTemplate< CExpat >::getInputContext(), CExpatTemplate< CExpat >::parse(), and CExpatTemplate< CExpat >::parseBuffer().


The documentation for this class was generated from the following file: