COPASI API  4.16.103
Public Member Functions | Private Types | Private Attributes | List of all members
CCopasiXMLParser::UnsupportedAnnotationElement Class Reference

#include <CCopasiXMLParser.h>

Inheritance diagram for CCopasiXMLParser::UnsupportedAnnotationElement:
Inheritance graph
[legend]
Collaboration diagram for CCopasiXMLParser::UnsupportedAnnotationElement:
Collaboration graph
[legend]

Public Member Functions

virtual void end (const XML_Char *pszName)
 
const std::string & getName () const
 
std::string getXML () const
 
virtual void start (const XML_Char *pszName, const XML_Char **papszAttrs)
 
 UnsupportedAnnotationElement (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual ~UnsupportedAnnotationElement ()
 
- 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 { UnsupportedAnnotation = 0, Content }
 

Private Attributes

std::stack< bool > mElementEmpty
 
size_t mLevel
 
std::string mName
 
std::ostringstream mXML
 

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 25 of file CCopasiXMLParser.h.

Member Enumeration Documentation

Enum of invoked parsers

Enumerator
UnsupportedAnnotation 
Content 

Definition at line 32 of file CCopasiXMLParser.h.

88 {

Constructor & Destructor Documentation

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

Destructor

Definition at line 32 of file ListOfUnsupportedAnnotations.cpp.

33 {}

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 92 of file ListOfUnsupportedAnnotations.cpp.

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

93 {
94  std::string XML;
95 
96  switch (mCurrentElement)
97  {
99 
100  if (strcmp(pszName, "UnsupportedAnnotation"))
102  pszName, "UnsupportedAnnotation", mParser.getCurrentLineNumber());
103 
105 
106  XML = mXML.str();
107 
108  {
109  // remove leading whitepsaces
110  std::string::size_type pos = XML.find_first_not_of("\x0a\x0d\t ");
111 
112  if (pos != 0) XML.erase(0, pos);
113 
114  // remove trailing whitepsace
115  pos = XML.find_last_not_of("\x0a\x0d\t ");
116 
117  if (pos < XML.length())
118  XML = XML.substr(0, pos + 1);
119  }
120 
121  mXML.str(XML);
122 
125  mElementEmpty.pop();
126 
128 
129  /* Tell the parent element we are done. */
130  mParser.onEndElement(pszName);
131  break;
132 
133  case Content:
134  XML = mParser.getCharacterData();
135 
136  // Check whether and how we need to close the element
137  if (mElementEmpty.top() == true)
138  {
139  if (XML != "")
140  {
141  mElementEmpty.top() = false;
142  mXML << ">";
143  }
144  else
145  mXML << " />";
146  }
147 
148  if (XML != "")
150 
151  if (mElementEmpty.top() == false)
152  mXML << "</" << pszName << ">";
153 
154  mElementEmpty.pop();
155  mElementEmpty.top() = false;
156  mLevel--;
157 
159 
161  break;
162 
163  case UNKNOWN_ELEMENT:
165  break;
166 
167  default:
169  pszName, "???", mParser.getCurrentLineNumber());
170  break;
171  }
172 
173  return;
174 }
void enableCharacterDataHandler(bool fEnable=true)
#define MCXML
#define START_ELEMENT
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
const std::string & CCopasiXMLParser::UnsupportedAnnotationElement::getName ( ) const

Retrieve the name

Returns
const std::string & name

Definition at line 176 of file ListOfUnsupportedAnnotations.cpp.

177 {
178  return mName;
179 }
std::string CCopasiXMLParser::UnsupportedAnnotationElement::getXML ( ) const

Retrieve the XML

Returns
std::string XML

Definition at line 181 of file ListOfUnsupportedAnnotations.cpp.

182 {
183  return mXML.str();
184 }
void CCopasiXMLParser::UnsupportedAnnotationElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 36 of file ListOfUnsupportedAnnotations.cpp.

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

38 {
39  mCurrentElement++; /* We should always be on the next element */
40  const XML_Char ** ppAttrs;
41 
43 
44  switch (mCurrentElement)
45  {
47 
48  if (strcmp(pszName, "UnsupportedAnnotation"))
50  pszName, "UnsupportedAnnotation", mParser.getCurrentLineNumber());
51 
52  mName = mParser.getAttributeValue("name", papszAttrs);
53  mXML.str("");
54  mLevel = 0;
56  mElementEmpty.push(false);
57  break;
58 
59  case Content:
60 
61  if (mElementEmpty.top() == true)
62  {
63  mXML << ">";
64  mElementEmpty.top() = false;
65  }
66 
68  mXML << "<" << pszName;
69 
70  for (ppAttrs = papszAttrs; *ppAttrs && **ppAttrs; ppAttrs += 2)
71  mXML << " " << *ppAttrs << "=\""
73 
74  mLevel++;
75  mElementEmpty.push(true);
76 
78  break;
79 
80  default:
84  mParser.onStartElement(pszName, papszAttrs);
85  break;
86  }
87 
88  return;
89 }
UnknownElement mUnknownElement
void enableCharacterDataHandler(bool fEnable=true)
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
#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::UnsupportedAnnotationElement::mElementEmpty
private

Information whether an element is empty

Definition at line 96 of file CCopasiXMLParser.h.

size_t CCopasiXMLParser::UnsupportedAnnotationElement::mLevel
private

The level of nested XML elements.

Definition at line 91 of file CCopasiXMLParser.h.

std::string CCopasiXMLParser::UnsupportedAnnotationElement::mName
private

The name of the unsupported annotation

Definition at line 81 of file CCopasiXMLParser.h.

std::ostringstream CCopasiXMLParser::UnsupportedAnnotationElement::mXML
private

String stream to handle XML content

Definition at line 86 of file CCopasiXMLParser.h.


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