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

Public Member Functions

virtual void end (const XML_Char *pszName)
 
 LocalStyleElement (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void start (const XML_Char *pszName, const XML_Char **papszAttrs)
 
virtual ~LocalStyleElement ()
 
- 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 { LocalStyle = 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 4399 of file CCopasiXMLParser.h.

Member Enumeration Documentation

Enumerator
LocalStyle 
Group 

Definition at line 4406 of file CCopasiXMLParser.h.

Constructor & Destructor Documentation

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

Destructor

Definition at line 13393 of file CCopasiXMLParser.cpp.

References pdelete.

13394 {
13396 }
#define pdelete(p)
Definition: copasi.h:215

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 13496 of file CCopasiXMLParser.cpp.

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

13497 {
13498  switch (mCurrentElement)
13499  {
13500  case LocalStyle:
13501 
13502  if (strcmp(pszName, "Style"))
13504  pszName, "Style", mParser.getCurrentLineNumber());
13505 
13507  mCommon.pStyle = NULL;
13508 
13509  //reset handler
13511  //call parent handler
13512  mParser.onEndElement(pszName);
13513  break;
13514 
13515  case Group:
13516 
13517  if (strcmp(pszName, "Group"))
13519  pszName, "Group", mParser.getCurrentLineNumber());
13520 
13521  //tell the handler where to continue
13523 
13524  //no need to delete Handler (since it is the only one the destructor
13525  //will handle it)
13526  break;
13527 
13528  case UNKNOWN_ELEMENT:
13529  mCurrentElement = mLastKnownElement;
13530  break;
13531 
13532  default:
13534  pszName, "???", mParser.getCurrentLineNumber());
13535  break;
13536  }
13537 
13538  return;
13539 }
#define START_ELEMENT
#define MCXML
virtual void onEndElement(const XML_Char *pszName)
#define UNKNOWN_ELEMENT
int getCurrentLineNumber() const
Definition: CExpat.h:470
void CCopasiXMLParser::LocalStyleElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 13398 of file CCopasiXMLParser.cpp.

References CCopasiMessage::EXCEPTION, CKeyFactory::get(), CLGraphicalObject::getKey(), SCopasiXMLParserCommon::KeyMap, CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pRenderInformation, SCopasiXMLParserCommon::pStyle, CLStyle::readIntoSet(), CLLocalStyle::setKeyList(), CLStyle::setRoleList(), CLStyle::setTypeList(), and UNKNOWN_ELEMENT.

13400 {
13401  mCurrentElement++; /* We should always be on the next element */
13402 
13403  const char * RoleList;
13404  const char * TypeList;
13405  const char * KeyList;
13406  CLLocalStyle* pLocalStyle = NULL;
13407 
13408  switch (mCurrentElement)
13409  {
13410  case LocalStyle:
13411 
13412  if (strcmp(pszName, "Style"))
13414  pszName, "Style", mParser.getCurrentLineNumber());
13415 
13416  RoleList = mParser.getAttributeValue("roleList", papszAttrs, false);
13417  TypeList = mParser.getAttributeValue("typeList", papszAttrs, false);
13418  KeyList = mParser.getAttributeValue("keyList", papszAttrs, false);
13419  pLocalStyle = new CLLocalStyle();
13420 
13421  if (RoleList != NULL)
13422  {
13423  std::set<std::string> s;
13424  CLStyle::readIntoSet(RoleList, s);
13425  pLocalStyle->setRoleList(s);
13426  }
13427 
13428  if (TypeList != NULL)
13429  {
13430  std::set<std::string> s;
13431  CLStyle::readIntoSet(TypeList, s);
13432  pLocalStyle->setTypeList(s);
13433  }
13434 
13435  if (KeyList != NULL)
13436  {
13437  std::set<std::string> s;
13438  CLStyle::readIntoSet(KeyList, s);
13439  // we need to translate the keys from the file to the actual keys assigned now
13440  std::set<std::string> s_conv;
13441  std::set<std::string>::const_iterator keyIt = s.begin(), keyEndit = s.end();
13442  CLGraphicalObject* pGO = NULL;
13443 
13444  while (keyIt != keyEndit)
13445  {
13446  pGO = dynamic_cast<CLGraphicalObject *>(mCommon.KeyMap.get(*keyIt));
13447  assert(pGO);
13448 
13449  if (pGO != NULL)
13450  {
13451  s_conv.insert(pGO->getKey());
13452  }
13453 
13454  ++keyIt;
13455  }
13456 
13457  pLocalStyle->setKeyList(s_conv);
13458  }
13459 
13460  assert(dynamic_cast<CLLocalRenderInformation*>(mCommon.pRenderInformation) != NULL);
13461  static_cast<CLLocalRenderInformation*>(mCommon.pRenderInformation)->addStyle(pLocalStyle);
13462  // delete the line ending again since the addLocalStyle method made a copy
13463  delete pLocalStyle;
13464  assert(static_cast<CLLocalRenderInformation*>(mCommon.pRenderInformation)->getNumStyles() > 0);
13465  mCommon.pStyle = static_cast<CLLocalRenderInformation*>(mCommon.pRenderInformation)->getStyle(static_cast<CLLocalRenderInformation*>(mCommon.pRenderInformation)->getNumStyles() - 1);
13466  break;
13467 
13468  case Group:
13469 
13470  //only one type of tags may occur here, so we can throw an exception.
13471  //No need to silently ignore unknown tags here.
13472  if (strcmp(pszName, "Group"))
13474  pszName, "Group", mParser.getCurrentLineNumber());
13475 
13476  //only one type of tags may occur here, so if the handler exists
13477  //it must be the correct one
13478  if (!mpCurrentHandler)
13479  mpCurrentHandler = new GroupElement(mParser, mCommon);
13480 
13482  mpCurrentHandler->start(pszName, papszAttrs);
13483  break;
13484 
13485  default:
13489  mParser.onStartElement(pszName, papszAttrs);
13490  break;
13491  }
13492 
13493  return;
13494 }
UnknownElement mUnknownElement
CCopasiObject * get(const std::string &key)
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
virtual const std::string & getKey() const
#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
void setKeyList(const std::set< std::string > &keyList)

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