COPASI API  4.16.103
Public Member Functions | Private Types | Private Attributes | List of all members
CCopasiXMLParser::MiriamAnnotationElement Class Reference
Inheritance diagram for CCopasiXMLParser::MiriamAnnotationElement:
Inheritance graph
[legend]
Collaboration diagram for CCopasiXMLParser::MiriamAnnotationElement:
Collaboration graph
[legend]

Public Member Functions

virtual void end (const XML_Char *pszName)
 
 MiriamAnnotationElement (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void start (const XML_Char *pszName, const XML_Char **papszAttrs)
 
virtual ~MiriamAnnotationElement ()
 
- Public Member Functions inherited from CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon >
 CXMLElementHandler (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void end (const XML_Char *C_UNUSED(pszName))
 
virtual void reset ()
 
virtual void start (const XML_Char *C_UNUSED(pszName), const XML_Char **C_UNUSED(papszAttrs))
 
virtual ~CXMLElementHandler ()
 

Private Types

enum  Element { MiriamAnnotation = 0, RDF }
 

Private Attributes

std::stack< bool > mElementEmpty
 
size_t mLevel
 
std::ostringstream mRDF
 

Additional Inherited Members

- Protected Member Functions inherited from CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon >
void addFix (const std::string &key, CCopasiObject *pObject)
 
void deleteCurrentHandler ()
 
- Protected Attributes inherited from CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon >
SCopasiXMLParserCommonmCommon
 
C_INT32 mCurrentElement
 
C_INT32 mLastKnownElement
 
CCopasiXMLParsermParser
 
CXMLElementHandlermpCurrentHandler
 

Detailed Description

Definition at line 3099 of file CCopasiXMLParser.h.

Member Enumeration Documentation

Enum of invoked parsers

Enumerator
MiriamAnnotation 
RDF 

Definition at line 3106 of file CCopasiXMLParser.h.

Constructor & Destructor Documentation

CCopasiXMLParser::MiriamAnnotationElement::MiriamAnnotationElement ( CCopasiXMLParser parser,
SCopasiXMLParserCommon common 
)
CCopasiXMLParser::MiriamAnnotationElement::~MiriamAnnotationElement ( )
virtual

Destructor

Definition at line 10359 of file CCopasiXMLParser.cpp.

Member Function Documentation

void CCopasiXMLParser::MiriamAnnotationElement::end ( const XML_Char *  pszName)
virtual

End element handler

Parameters
constXML_Char *pszName

Definition at line 10418 of file CCopasiXMLParser.cpp.

References SCopasiXMLParserCommon::CharacterData, CCopasiXMLInterface::encode(), CCopasiMessage::EXCEPTION, CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, START_ELEMENT, and UNKNOWN_ELEMENT.

10419 {
10420  std::string rdf;
10421 
10422  switch (mCurrentElement)
10423  {
10424  case MiriamAnnotation:
10425 
10426  if (strcmp(pszName, "MiriamAnnotation"))
10428  pszName, "MiriamAnnotation", mParser.getCurrentLineNumber());
10429 
10430  if (mRDF.str() != "")
10432  else
10434 
10435  mCommon.CharacterData = mRDF.str();
10436 
10437  {
10438  // remove leading whitepsaces
10439  std::string::size_type pos = mCommon.CharacterData.find_first_not_of("\x0a\x0d\t ");
10440 
10441  if (pos != 0) mCommon.CharacterData.erase(0, pos);
10442 
10443  // remove trailing whitepsace
10444  pos = mCommon.CharacterData.find_last_not_of("\x0a\x0d\t ");
10445 
10446  if (pos < mCommon.CharacterData.length())
10447  mCommon.CharacterData = mCommon.CharacterData.substr(0, pos + 1);
10448  }
10449 
10452  mElementEmpty.pop();
10453 
10455 
10456  /* Tell the parent element we are done. */
10457  mParser.onEndElement(pszName);
10458  break;
10459 
10460  case RDF:
10461  rdf = mParser.getCharacterData();
10462 
10463  // Check whether and how we need to close the attribute
10464  if (mElementEmpty.top() == true)
10465  {
10466  if (rdf != "")
10467  {
10468  mElementEmpty.top() = false;
10469  mRDF << ">";
10470  }
10471  else
10472  mRDF << " />";
10473  }
10474 
10475  if (rdf != "")
10477 
10478  if (mElementEmpty.top() == false)
10479  mRDF << "</" << pszName << ">";
10480 
10481  mElementEmpty.pop();
10482  mElementEmpty.top() = false;
10483  mLevel--;
10484 
10486 
10488  break;
10489 
10490  case UNKNOWN_ELEMENT:
10492  break;
10493 
10494  default:
10496  pszName, "???", mParser.getCurrentLineNumber());
10497  break;
10498  }
10499 
10500  return;
10501 }
#define START_ELEMENT
void enableCharacterDataHandler(bool fEnable=true)
#define MCXML
virtual void onEndElement(const XML_Char *pszName)
#define UNKNOWN_ELEMENT
std::string getCharacterData(const std::string &toBeStripped="", const std::string &join=" ")
static std::string encode(const std::string &str, const EncodingType &type=standard)
int getCurrentLineNumber() const
Definition: CExpat.h:470
void CCopasiXMLParser::MiriamAnnotationElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 10364 of file CCopasiXMLParser.cpp.

References CCopasiXMLInterface::attribute, CCopasiXMLInterface::encode(), CCopasiMessage::EXCEPTION, MCXML, CExpatTemplate< CExpat >::mParser, and UNKNOWN_ELEMENT.

10366 {
10367  mCurrentElement++; /* We should always be on the next element */
10368  const XML_Char ** ppAttrs;
10369 
10370  if (mLevel) mCurrentElement = RDF;
10371 
10372  switch (mCurrentElement)
10373  {
10374  case MiriamAnnotation:
10375 
10376  if (strcmp(pszName, "MiriamAnnotation"))
10378  pszName, "MiriamAnnotation", mParser.getCurrentLineNumber());
10379 
10380  mRDF.str("");
10381  mLevel = 0;
10383  mElementEmpty.push(false);
10384  break;
10385 
10386  case RDF:
10387 
10388  if (mElementEmpty.top() == true)
10389  {
10390  mRDF << ">";
10391  mElementEmpty.top() = false;
10392  }
10393 
10395  mRDF << "<" << pszName;
10396 
10397  for (ppAttrs = papszAttrs; *ppAttrs && **ppAttrs; ppAttrs += 2)
10398  mRDF << " " << *ppAttrs << "=\""
10399  << CCopasiXMLInterface::encode(*(ppAttrs + 1), CCopasiXMLInterface::attribute) << "\"";
10400 
10401  mLevel++;
10402  mElementEmpty.push(true);
10403 
10405  break;
10406 
10407  default:
10411  mParser.onStartElement(pszName, papszAttrs);
10412  break;
10413  }
10414 
10415  return;
10416 }
UnknownElement mUnknownElement
void enableCharacterDataHandler(bool fEnable=true)
#define MCXML
#define UNKNOWN_ELEMENT
virtual void onStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
void pushElementHandler(CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon > *elementHandler)
std::string getCharacterData(const std::string &toBeStripped="", const std::string &join=" ")
static std::string encode(const std::string &str, const EncodingType &type=standard)
int getCurrentLineNumber() const
Definition: CExpat.h:470

Member Data Documentation

std::stack< bool > CCopasiXMLParser::MiriamAnnotationElement::mElementEmpty
private

Information whether an element is empty

Definition at line 3125 of file CCopasiXMLParser.h.

size_t CCopasiXMLParser::MiriamAnnotationElement::mLevel
private

The level of nested xhtml elements.

Definition at line 3120 of file CCopasiXMLParser.h.

std::ostringstream CCopasiXMLParser::MiriamAnnotationElement::mRDF
private

String stream to handle RDF contents

Definition at line 3115 of file CCopasiXMLParser.h.


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