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

Public Member Functions

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

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

Member Enumeration Documentation

Enum of invoked parsers

Enumerator
InitialState 
etc 

Definition at line 507 of file CCopasiXMLParser.h.

Constructor & Destructor Documentation

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

Destructor

Definition at line 5289 of file CCopasiXMLParser.cpp.

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 5327 of file CCopasiXMLParser.cpp.

References CState::beginIndependent(), C_FLOAT64, C_INVALID_INDEX, CCopasiMessage::EXCEPTION, fatalError, CStateTemplate::getIndex(), CModel::getInitialState(), CModel::getStateTemplate(), CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pModel, CModel::setInitialState(), START_ELEMENT, SCopasiXMLParserCommon::StateVariableList, and UNKNOWN_ELEMENT.

5328 {
5329  std::istringstream Values;
5330  std::string StringValue;
5331  std::vector< CModelEntity * >::iterator it;
5332  std::vector< CModelEntity * >::iterator end;
5333  double Value;
5334 
5335  const CStateTemplate & Template = mCommon.pModel->getStateTemplate();
5336  CState IState = mCommon.pModel->getInitialState();
5337  C_FLOAT64 * pValues = IState.beginIndependent() - 1;
5338  size_t Index;
5339 
5340  switch (mCurrentElement)
5341  {
5342  case InitialState:
5343 
5344  if (strcmp(pszName, "InitialState"))
5346  pszName, "InitialState", mParser.getCurrentLineNumber());
5347 
5348  Values.str(mParser.getCharacterData("\x0a\x0d\t ", " "));
5349 
5350  it = mCommon.StateVariableList.begin();
5351  end = mCommon.StateVariableList.end();
5352 
5353  for (Values >> StringValue; it != end; ++it, Values >> StringValue)
5354  {
5355  if (Values.fail()) break;
5356 
5357  Value = CCopasiXMLInterface::DBL(StringValue.c_str());
5358 
5359  Index = Template.getIndex(*it);
5360 
5361  if (Index != C_INVALID_INDEX)
5362  {
5363  pValues[Index] = Value;
5364  continue;
5365  }
5366 
5367  fatalError();
5368  }
5369 
5370  if (it != end || !Values.fail() || !Values.eof())
5371  {
5373  }
5374 
5375  mCommon.pModel->setInitialState(IState);
5376 
5379 
5380  /* Tell the parent element we are done. */
5381  mParser.onEndElement(pszName);
5382  break;
5383 
5384  case UNKNOWN_ELEMENT:
5386  break;
5387 
5388  default:
5390  pszName, "???", mParser.getCurrentLineNumber());
5391  break;
5392  }
5393 
5394  return;
5395 }
#define START_ELEMENT
std::vector< CModelEntity * > StateVariableList
void setInitialState(const CState &state)
Definition: CModel.cpp:1774
#define fatalError()
Definition: CState.h:305
#define MCXML
#define C_INVALID_INDEX
Definition: copasi.h:222
size_t getIndex(const CModelEntity *entity) const
Definition: CState.cpp:231
virtual void onEndElement(const XML_Char *pszName)
#define UNKNOWN_ELEMENT
std::string getCharacterData(const std::string &toBeStripped="", const std::string &join=" ")
virtual void end(const XML_Char *pszName)
#define C_FLOAT64
Definition: copasi.h:92
const CState & getInitialState() const
Definition: CModel.cpp:1768
const CStateTemplate & getStateTemplate() const
Definition: CModel.cpp:1172
int getCurrentLineNumber() const
Definition: CExpat.h:470
C_FLOAT64 * beginIndependent()
Definition: CState.cpp:328
void CCopasiXMLParser::InitialStateElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 5294 of file CCopasiXMLParser.cpp.

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

5296 {
5297  const char * Type;
5298 
5299  mCurrentElement++; /* We should always be on the next element */
5300 
5301  switch (mCurrentElement)
5302  {
5303  case InitialState:
5304 
5305  if (strcmp(pszName, "InitialState"))
5307  pszName, "InitialState", mParser.getCurrentLineNumber());
5308 
5309  Type = mParser.getAttributeValue("type", papszAttrs, "initialState");
5310 
5311  if (strcmp(Type, "initialState")) fatalError();
5312 
5314  break;
5315 
5316  default:
5320  mParser.onStartElement(pszName, papszAttrs);
5321  break;
5322  }
5323 
5324  return;
5325 }
UnknownElement mUnknownElement
void enableCharacterDataHandler(bool fEnable=true)
#define fatalError()
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)
int getCurrentLineNumber() const
Definition: CExpat.h:470

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