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

Public Member Functions

virtual void end (const XML_Char *pszName)
 
 ReportElement (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void start (const XML_Char *pszName, const XML_Char **papszAttrs)
 
virtual ~ReportElement ()
 
- 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 {
  Report = 0, Comment, Header, Body,
  Footer, Table
}
 

Private Attributes

BodyElementmpBodyElement
 
FooterElementmpFooterElement
 
HeaderElementmpHeaderElement
 
TableElementmpTableElement
 
bool otherFound
 
bool tableFound
 

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

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Destructor

Definition at line 9520 of file CCopasiXMLParser.cpp.

References pdelete.

9521 {
9526 }
#define pdelete(p)
Definition: copasi.h:215

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 9690 of file CCopasiXMLParser.cpp.

References SCopasiXMLParserCommon::CharacterData, CCopasiMessage::EXCEPTION, CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pReport, CReportDefinition::setComment(), START_ELEMENT, and UNKNOWN_ELEMENT.

9691 {
9692  if (!strcmp(pszName, "Report") &&
9693  (mCurrentElement == Comment ||
9694  mCurrentElement == Header ||
9695  mCurrentElement == Body))
9697 
9698  switch (mCurrentElement)
9699  {
9700  case Report:
9701 
9702  if (strcmp(pszName, "Report"))
9704  pszName, "Report", mParser.getCurrentLineNumber());
9705 
9708 
9709  // Tell the parent element we are done.
9710  mParser.onEndElement(pszName);
9711  break;
9712 
9713  case Comment:
9714 
9715  if (strcmp(pszName, "Comment"))
9717  pszName, "Comment", mParser.getCurrentLineNumber());
9718 
9719  // check parameter type CCopasiStaticString
9721  mCommon.CharacterData = "";
9722  break;
9723 
9724  case Header:
9725 
9726  if (strcmp(pszName, "Header"))
9728  pszName, "Header", mParser.getCurrentLineNumber());
9729 
9730  break;
9731 
9732  case Body:
9733 
9734  if (strcmp(pszName, "Body"))
9736  pszName, "Body", mParser.getCurrentLineNumber());
9737 
9738  break;
9739 
9740  case Footer:
9741 
9742  if (strcmp(pszName, "Footer"))
9744  pszName, "Footer", mParser.getCurrentLineNumber());
9745 
9746  mCurrentElement = Report;
9747  break;
9748 
9749  case Table:
9750 
9751  if (strcmp(pszName, "Table"))
9753  pszName, "Table", mParser.getCurrentLineNumber());
9754 
9755  mCurrentElement = Report;
9756  break;
9757 
9758  case UNKNOWN_ELEMENT:
9759  mCurrentElement = mLastKnownElement;
9760  break;
9761 
9762  default:
9764  pszName, "???", mParser.getCurrentLineNumber());
9765  break;
9766  }
9767 }
#define START_ELEMENT
#define MCXML
virtual void onEndElement(const XML_Char *pszName)
#define UNKNOWN_ELEMENT
void setComment(const std::string &comment)
int getCurrentLineNumber() const
Definition: CExpat.h:470
CReportDefinition * pReport
void CCopasiXMLParser::ReportElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 9528 of file CCopasiXMLParser.cpp.

References CCopasiVectorN< CType >::add(), C_INVALID_INDEX, CCopasiMessage::EXCEPTION, fatalError, CCopasiVectorN< CType >::getIndex(), CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pReport, SCopasiXMLParserCommon::pReportList, CReportDefinition::setIsTable(), CCopasiObject::setObjectName(), CReportDefinition::setPrecision(), CReportDefinition::setSeparator(), CReportDefinition::setTaskType(), strToUnsignedInt(), toEnum(), UNKNOWN_ELEMENT, CCopasiTask::unset, and CCopasiTask::XMLType.

9530 {
9531  const char * Key;
9532  const char * Name;
9533  const char * Separator;
9534  const char * Precision;
9535  CCopasiTask::Type type;
9536 
9537  mCurrentElement++; /* We should always be on the next element */
9538  mpCurrentHandler = NULL;
9539 
9540  switch (mCurrentElement)
9541  {
9542  case Report:
9543 
9544  if (strcmp(pszName, "Report"))
9546  pszName, "Report", mParser.getCurrentLineNumber());
9547 
9548  // We have not found anything yet.
9549  tableFound = false;
9550  otherFound = false;
9551 
9552  Key = mParser.getAttributeValue("key", papszAttrs);
9553  Name = mParser.getAttributeValue("name", papszAttrs);
9554  type = toEnum(mParser.getAttributeValue("taskType", papszAttrs),
9556 
9557  Separator = mParser.getAttributeValue("separator", papszAttrs, "\t");
9558  Precision = mParser.getAttributeValue("precision", papszAttrs, "6");
9559 
9560  // create a new report
9562  mCommon.pReport->setTaskType(type);
9565 
9566  {
9567  // We need to make sure that the name is unique.
9568  std::string ValidName(Name);
9569  size_t Index = 1;
9570 
9571  while (mCommon.pReportList->getIndex(ValidName) != C_INVALID_INDEX)
9572  {
9573  std::ostringstream ValidNameStream;
9574  ValidNameStream << Name << " " << Index++;
9575  ValidName = ValidNameStream.str();
9576  }
9577 
9578  mCommon.pReport->setObjectName(ValidName);
9579  }
9580 
9581  /* We have a new report and add it to the list */
9583  addFix(Key, mCommon.pReport);
9584  return;
9585  break;
9586 
9587  case Comment:
9588 
9589  if (!strcmp(pszName, "Comment"))
9590  {
9591  /* Push the Comment element handler on the stack and call it. */
9593  }
9594 
9595  break;
9596 
9597  case Header:
9598 
9599  if (!strcmp(pszName, "Header"))
9600  {
9601  /* If we do not have a Header element handler we create one. */
9602  if (tableFound) fatalError();
9603 
9604  otherFound = true;
9605  mCommon.pReport->setIsTable(false);
9606 
9607  if (!mpHeaderElement)
9608  mpHeaderElement = new HeaderElement(mParser, mCommon);
9609 
9610  /* Push the Header element handler on the stack and call it. */
9612  }
9613 
9614  break;
9615 
9616  case Body:
9617 
9618  if (!strcmp(pszName, "Body"))
9619  {
9620  /* If we do not have a Body element handler we create one. */
9621  if (tableFound) fatalError();
9622 
9623  otherFound = true;
9624  mCommon.pReport->setIsTable(false);
9625 
9626  if (!mpBodyElement)
9627  mpBodyElement = new BodyElement(mParser, mCommon);
9628 
9629  /* Push the Body element handler on the stack and call it. */
9631  }
9632 
9633  break;
9634 
9635  case Footer:
9636 
9637  if (!strcmp(pszName, "Footer"))
9638  {
9639  /* If we do not have a Body element handler we create one. */
9640  if (tableFound) fatalError();
9641 
9642  otherFound = true;
9643  mCommon.pReport->setIsTable(false);
9644 
9645  if (!mpFooterElement)
9646  mpFooterElement = new FooterElement(mParser, mCommon);
9647 
9648  /* Push the Body element handler on the stack and call it. */
9650  }
9651 
9652  break;
9653 
9654  case Table:
9655 
9656  if (!strcmp(pszName, "Table"))
9657  {
9658  if (otherFound) fatalError();
9659 
9660  tableFound = true;
9661  mCommon.pReport->setIsTable(true);
9662 
9663  if (!mpTableElement)
9664  {
9665  mpTableElement = new TableElement(mParser, mCommon);
9666  }
9667 
9669  }
9670 
9671  break;
9672 
9673  default:
9677  break;
9678  }
9679 
9680  if (mpCurrentHandler)
9681  {
9683  }
9684 
9685  mParser.onStartElement(pszName, papszAttrs);
9686 
9687  return;
9688 }
UnknownElement mUnknownElement
bool setTaskType(const CCopasiTask::Type &taskType)
#define fatalError()
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
#define MCXML
#define C_INVALID_INDEX
Definition: copasi.h:222
virtual size_t getIndex(const std::string &name) const
void setSeparator(const CCopasiReportSeparator &Separator)
void setIsTable(bool table)
void addFix(const std::string &key, CCopasiObject *pObject)
Definition: CXMLHandler.h:119
CReportDefinitionVector * pReportList
static const char * XMLType[]
Definition: CCopasiTask.h:72
#define UNKNOWN_ELEMENT
virtual void onStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
virtual bool add(const CType &src)
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
void setPrecision(const unsigned C_INT32 &precision)
int getCurrentLineNumber() const
Definition: CExpat.h:470
CommentElement mCommentElement
CReportDefinition * pReport
bool setObjectName(const std::string &name)

Member Data Documentation

BodyElement* CCopasiXMLParser::ReportElement::mpBodyElement
private

Definition at line 2774 of file CCopasiXMLParser.h.

FooterElement* CCopasiXMLParser::ReportElement::mpFooterElement
private

Definition at line 2775 of file CCopasiXMLParser.h.

HeaderElement* CCopasiXMLParser::ReportElement::mpHeaderElement
private

Definition at line 2773 of file CCopasiXMLParser.h.

TableElement* CCopasiXMLParser::ReportElement::mpTableElement
private

Definition at line 2776 of file CCopasiXMLParser.h.

bool CCopasiXMLParser::ReportElement::otherFound
private

Definition at line 2779 of file CCopasiXMLParser.h.

bool CCopasiXMLParser::ReportElement::tableFound
private

Definition at line 2778 of file CCopasiXMLParser.h.


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