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

Public Member Functions

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

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

Member Enumeration Documentation

Enum of invoked parsers

Enumerator
Parameter 

Definition at line 2224 of file CCopasiXMLParser.h.

Constructor & Destructor Documentation

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

Destructor

Definition at line 9013 of file CCopasiXMLParser.cpp.

9014 {}

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 9144 of file CCopasiXMLParser.cpp.

References CCopasiMessage::EXCEPTION, MCXML, CExpatTemplate< CExpat >::mParser, START_ELEMENT, and UNKNOWN_ELEMENT.

9145 {
9146  switch (mCurrentElement)
9147  {
9148  case Parameter:
9149 
9150  if (strcmp(pszName, "Parameter"))
9152  pszName, "Parameter", mParser.getCurrentLineNumber());
9153 
9156  mParser.onEndElement(pszName);
9157  break;
9158 
9159  case UNKNOWN_ELEMENT:
9160  mCurrentElement = mLastKnownElement;
9161  break;
9162 
9163  default:
9165  pszName, "???", mParser.getCurrentLineNumber());
9166  break;
9167  }
9168 
9169  return;
9170 }
#define START_ELEMENT
#define MCXML
virtual void onEndElement(const XML_Char *pszName)
#define UNKNOWN_ELEMENT
int getCurrentLineNumber() const
Definition: CExpat.h:470
void CCopasiXMLParser::ParameterElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 9016 of file CCopasiXMLParser.cpp.

References CCopasiParameter::BOOL, C_FLOAT64, C_INT32, CCopasiParameter::CN, CCopasiParameter::DOUBLE, CCopasiMessage::ERROR, CCopasiMessage::EXCEPTION, CCopasiParameter::FILE, CKeyFactory::get(), CCopasiParameter::getKey(), CCopasiObject::getKey(), CCopasiParameter::INT, CCopasiParameter::INVALID, CKeyFactory::isValidKey(), CCopasiParameter::KEY, SCopasiXMLParserCommon::KeyMap, CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pCurrentParameter, CCopasiParameter::STRING, strToInt(), strToUnsignedInt(), toEnum(), CCopasiParameter::UDOUBLE, CCopasiParameter::UINT, UNKNOWN_ELEMENT, SCopasiXMLParserCommon::UnmappedKeyParameters, and CCopasiParameter::XMLType.

9018 {
9019  mCurrentElement++; // We should always be on the next element
9020 
9021  const char * cValue = NULL;
9022  const char * cType = NULL;
9023 
9024  std::string name;
9025  std::string sValue("");
9026  bool UnmappedKey = false;
9027 
9028  void * pValue = NULL;
9030 
9031  C_FLOAT64 d;
9032  C_INT32 i;
9033  size_t ui;
9034  bool b;
9035 
9036  switch (mCurrentElement)
9037  {
9038  case Parameter:
9039 
9040  if (strcmp(pszName, "Parameter"))
9042  pszName, "Parameter", mParser.getCurrentLineNumber());
9043 
9044  // Parameter has attributes name, type and value
9045  name = mParser.getAttributeValue("name", papszAttrs);
9046  cType = mParser.getAttributeValue("type", papszAttrs);
9048  cValue = mParser.getAttributeValue("value", papszAttrs);
9049 
9050  if (cValue != NULL)
9051  {
9052  sValue = cValue;
9053  }
9054 
9055  switch (type)
9056  {
9058  d = CCopasiXMLInterface::DBL(sValue.c_str());
9059  pValue = &d;
9060  break;
9061 
9063  d = CCopasiXMLInterface::DBL(sValue.c_str());
9064  pValue = &d;
9065  break;
9066 
9067  case CCopasiParameter::INT:
9068  i = strToInt(sValue.c_str());
9069  pValue = &i;
9070  break;
9071 
9073  ui = strToUnsignedInt(sValue.c_str());
9074  pValue = &ui;
9075  break;
9076 
9078 
9079  if (sValue == "0" || sValue == "false")
9080  {
9081  b = false;
9082  }
9083  else
9084  {
9085  b = true;
9086  }
9087 
9088  pValue = &b;
9089  break;
9090 
9093  case CCopasiParameter::CN:
9094  pValue = &sValue;
9095  break;
9096 
9097  case CCopasiParameter::KEY:
9098  {
9099  if (sValue != "" &&
9100  CKeyFactory::isValidKey(sValue))
9101  {
9102  CCopasiObject * pObject = mCommon.KeyMap.get(sValue);
9103 
9104  if (pObject)
9105  {
9106  sValue = pObject->getKey();
9107  }
9108  else
9109  {
9110  UnmappedKey = true;
9111  }
9112  }
9113 
9114  pValue = &sValue;
9115  }
9116  break;
9117 
9118  default:
9120  pValue = NULL;
9121  break;
9122  }
9123 
9124  mCommon.pCurrentParameter = new CCopasiParameter(name, type, pValue);
9125 
9126  if (UnmappedKey)
9127  {
9129  }
9130 
9131  break;
9132 
9133  default:
9137  mParser.onStartElement(pszName, papszAttrs);
9138  break;
9139  }
9140 
9141  return;
9142 }
UnknownElement mUnknownElement
CCopasiObject * get(const std::string &key)
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
#define MCXML
static bool isValidKey(const std::string &key, const std::string &prefix="")
Definition: CKeyFactory.cpp:30
#define C_INT32
Definition: copasi.h:90
virtual const std::string & getKey() const
#define UNKNOWN_ELEMENT
virtual void onStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
virtual const std::string & getKey() const
void pushElementHandler(CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon > *elementHandler)
unsigned C_INT32 strToUnsignedInt(const char *str, char const **pTail)
Definition: utility.cpp:384
CType toEnum(const char *attribute, const char **enumNames, const CType &enumDefault)
Definition: utility.h:107
#define C_FLOAT64
Definition: copasi.h:92
CCopasiParameter * pCurrentParameter
static const char * XMLType[]
int getCurrentLineNumber() const
Definition: CExpat.h:470
C_INT32 strToInt(const char *str, char const **pTail)
Definition: utility.cpp:354
std::vector< std::string > UnmappedKeyParameters

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