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

Public Member Functions

virtual void end (const XML_Char *pszName)
 
 GlobalStyleElement (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void start (const XML_Char *pszName, const XML_Char **papszAttrs)
 
virtual ~GlobalStyleElement ()
 
- 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 { GlobalStyle = 0, Group }
 

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

Member Enumeration Documentation

Enumerator
GlobalStyle 
Group 

Definition at line 4447 of file CCopasiXMLParser.h.

Constructor & Destructor Documentation

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

Destructor

Definition at line 13265 of file CCopasiXMLParser.cpp.

References pdelete.

13266 {
13268 }
#define pdelete(p)
Definition: copasi.h:215

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 13341 of file CCopasiXMLParser.cpp.

References CCopasiMessage::EXCEPTION, CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pStyle, START_ELEMENT, and UNKNOWN_ELEMENT.

13342 {
13343  switch (mCurrentElement)
13344  {
13345  case GlobalStyle:
13346 
13347  if (strcmp(pszName, "Style"))
13349  pszName, "Style", mParser.getCurrentLineNumber());
13350 
13352  mCommon.pStyle = NULL;
13353 
13354  //reset handler
13356  //call parent handler
13357  mParser.onEndElement(pszName);
13358  break;
13359 
13360  case Group:
13361 
13362  if (strcmp(pszName, "Group"))
13364  pszName, "Group", mParser.getCurrentLineNumber());
13365 
13366  //tell the handler where to continue
13368 
13369  //no need to delete Handler (since it is the only one the destructor
13370  //will handle it)
13371  break;
13372 
13373  case UNKNOWN_ELEMENT:
13374  mCurrentElement = mLastKnownElement;
13375  break;
13376 
13377  default:
13379  pszName, "???", mParser.getCurrentLineNumber());
13380  break;
13381  }
13382 
13383  return;
13384 }
#define START_ELEMENT
#define MCXML
virtual void onEndElement(const XML_Char *pszName)
#define UNKNOWN_ELEMENT
int getCurrentLineNumber() const
Definition: CExpat.h:470
void CCopasiXMLParser::GlobalStyleElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 13270 of file CCopasiXMLParser.cpp.

References CCopasiMessage::EXCEPTION, CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pRenderInformation, SCopasiXMLParserCommon::pStyle, CLStyle::readIntoSet(), CLStyle::setRoleList(), CLStyle::setTypeList(), and UNKNOWN_ELEMENT.

13272 {
13273  mCurrentElement++; /* We should always be on the next element */
13274 
13275  const char * RoleList;
13276  const char * TypeList;
13277  CLGlobalStyle* pGlobalStyle = NULL;
13278 
13279  switch (mCurrentElement)
13280  {
13281  case GlobalStyle:
13282 
13283  if (strcmp(pszName, "Style"))
13285  pszName, "Style", mParser.getCurrentLineNumber());
13286 
13287  RoleList = mParser.getAttributeValue("roleList", papszAttrs, false);
13288  TypeList = mParser.getAttributeValue("typeList", papszAttrs, false);
13289  pGlobalStyle = new CLGlobalStyle();
13290 
13291  if (RoleList != NULL)
13292  {
13293  std::set<std::string> s;
13294  CLStyle::readIntoSet(RoleList, s);
13295  pGlobalStyle->setRoleList(s);
13296  }
13297 
13298  if (TypeList != NULL)
13299  {
13300  std::set<std::string> s;
13301  CLStyle::readIntoSet(TypeList, s);
13302  pGlobalStyle->setTypeList(s);
13303  }
13304 
13305  assert(dynamic_cast<CLGlobalRenderInformation*>(mCommon.pRenderInformation) != NULL);
13306  static_cast<CLGlobalRenderInformation*>(mCommon.pRenderInformation)->addStyle(pGlobalStyle);
13307  // delete the line ending again since the addGlobalStyle method made a copy
13308  delete pGlobalStyle;
13309  assert(static_cast<CLGlobalRenderInformation*>(mCommon.pRenderInformation)->getNumStyles() > 0);
13310  mCommon.pStyle = static_cast<CLGlobalRenderInformation*>(mCommon.pRenderInformation)->getStyle(static_cast<CLGlobalRenderInformation*>(mCommon.pRenderInformation)->getNumStyles() - 1);
13311  break;
13312 
13313  case Group:
13314 
13315  //only one type of tags may occur here, so we can throw an exception.
13316  //No need to silently ignore unknown tags here.
13317  if (strcmp(pszName, "Group"))
13319  pszName, "Group", mParser.getCurrentLineNumber());
13320 
13321  //only one type of tags may occur here, so if the handler exists
13322  //it must be the correct one
13323  if (!mpCurrentHandler)
13324  mpCurrentHandler = new GroupElement(mParser, mCommon);
13325 
13327  mpCurrentHandler->start(pszName, papszAttrs);
13328  break;
13329 
13330  default:
13334  mParser.onStartElement(pszName, papszAttrs);
13335  break;
13336  }
13337 
13338  return;
13339 }
UnknownElement mUnknownElement
static void readIntoSet(const std::string &s, std::set< std::string > &set)
Definition: CLStyle.cpp:168
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
#define MCXML
CLRenderInformationBase * pRenderInformation
#define UNKNOWN_ELEMENT
virtual void onStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
void pushElementHandler(CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon > *elementHandler)
void setTypeList(const std::set< std::string > &typeList)
Definition: CLStyle.cpp:218
virtual void start(const XML_Char *C_UNUSED(pszName), const XML_Char **C_UNUSED(papszAttrs))
Definition: CXMLHandler.h:87
int getCurrentLineNumber() const
Definition: CExpat.h:470
void setRoleList(const std::set< std::string > &roleList)
Definition: CLStyle.cpp:211

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