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

Public Member Functions

virtual void end (const XML_Char *pszName)
 
 ModelValueElement (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void start (const XML_Char *pszName, const XML_Char **papszAttrs)
 
virtual ~ModelValueElement ()
 
- 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 {
  ModelValue = 0, MiriamAnnotation, Comment, ListOfUnsupportedAnnotations,
  Expression, InitialExpression, MathML
}
 

Private Attributes

std::string mKey
 
MathMLElementmpMathMLElement
 
CModelValuempMV
 

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

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Destructor

Definition at line 2850 of file CCopasiXMLParser.cpp.

References pdelete.

2851 {
2853 }
#define pdelete(p)
Definition: copasi.h:215

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 2969 of file CCopasiXMLParser.cpp.

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

2970 {
2971  switch (mCurrentElement)
2972  {
2973  case ModelValue:
2974 
2975  if (strcmp(pszName, "ModelValue"))
2977  pszName, "ModelValue", mParser.getCurrentLineNumber());
2978 
2981 
2982  /* Tell the parent element we are done. */
2983  mParser.onEndElement(pszName);
2984  break;
2985 
2986  case MiriamAnnotation:
2987 
2988  if (strcmp(pszName, "MiriamAnnotation"))
2990  pszName, "MiriamAnnotation", mParser.getCurrentLineNumber());
2991 
2993  mCommon.CharacterData = "";
2994  break;
2995 
2996  case Comment:
2997 
2998  if (strcmp(pszName, "Comment"))
3000  pszName, "Comment", mParser.getCurrentLineNumber());
3001 
3003  mCommon.CharacterData = "";
3004  break;
3005 
3007 
3008  if (strcmp(pszName, "ListOfUnsupportedAnnotations"))
3010  pszName, "ListOfUnsupportedAnnotations", mParser.getCurrentLineNumber());
3011 
3013 
3014  break;
3015 
3016  case Expression:
3017 
3018  if (strcmp(pszName, "Expression"))
3020  pszName, "Expression", mParser.getCurrentLineNumber());
3021 
3022  {
3023  size_t Size = CCopasiMessage::size();
3024 
3026 
3027  // Remove error messages created by setExpression as this may fail
3028  // due to incomplete model specification at this time.
3029 
3030  while (CCopasiMessage::size() > Size)
3032  }
3033 
3034  break;
3035 
3036  case InitialExpression:
3037 
3038  if (strcmp(pszName, "InitialExpression"))
3040  pszName, "InitialExpression", mParser.getCurrentLineNumber());
3041 
3042  {
3043  size_t Size = CCopasiMessage::size();
3044 
3046 
3047  // Remove error messages created by setExpression as this may fail
3048  // due to incomplete model specification at this time.
3049  while (CCopasiMessage::size() > Size)
3051  }
3052 
3053  break;
3054 
3055  case MathML: // Old file format support
3056 
3057  if (strcmp(pszName, "MathML"))
3059  pszName, "MathML", mParser.getCurrentLineNumber());
3060 
3061  {
3062  size_t Size = CCopasiMessage::size();
3063 
3065 
3066  // Remove error messages created by setExpression as this may fail
3067  // due to incomplete model specification at this time.
3068 
3069  while (CCopasiMessage::size() > Size)
3071  }
3072 
3073  break;
3074 
3075  case UNKNOWN_ELEMENT:
3076  break;
3077 
3078  default:
3080  pszName, "???", mParser.getCurrentLineNumber());
3081  break;
3082  }
3083 
3085  return;
3086 }
#define START_ELEMENT
void setNotes(const std::string &notes)
#define MCXML
const CAnnotation::UnsupportedAnnotation & getUnsupportedAnnotations() const
bool setInitialExpression(const std::string &expression)
void setMiriamAnnotation(const std::string &miriamAnnotation, const std::string &newId, const std::string &oldId)
virtual void onEndElement(const XML_Char *pszName)
#define UNKNOWN_ELEMENT
virtual const std::string & getKey() const
static size_t size()
static CCopasiMessage getLastMessage()
ListOfUnsupportedAnnotationsElement mListOfUnsupportedAnnotationsElement
UnsupportedAnnotation & getUnsupportedAnnotations()
int getCurrentLineNumber() const
Definition: CExpat.h:470
bool setExpression(const std::string &expression)
void CCopasiXMLParser::ModelValueElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 2855 of file CCopasiXMLParser.cpp.

References CCopasiVectorN< CType >::add(), CCopasiMessage::EXCEPTION, CModelEntity::FIXED, CModel::getModelValues(), CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pModel, toEnum(), UNKNOWN_ELEMENT, and CModelEntity::XMLStatus.

2857 {
2858  const char * Name;
2859  const char * simulationType;
2860  CModelEntity::Status SimulationType;
2861 
2862  mpCurrentHandler = NULL;
2864 
2865  while (mpCurrentHandler == NULL)
2866  {
2867  mCurrentElement++; /* We should always be on the next element */
2868 
2869  switch (mCurrentElement)
2870  {
2871  case ModelValue:
2872 
2873  if (strcmp(pszName, "ModelValue"))
2875  pszName, "ModelValue", mParser.getCurrentLineNumber());
2876 
2877  mKey = mParser.getAttributeValue("key", papszAttrs);
2878  Name = mParser.getAttributeValue("name", papszAttrs);
2879  simulationType = mParser.getAttributeValue("simulationType", papszAttrs, false);
2880 
2881  // We need to handle old files which used the attribute status.
2882  if (!simulationType)
2883  {
2884  simulationType = mParser.getAttributeValue("status", papszAttrs, false);
2885 
2886  if (!simulationType) // status and simulationType are both missing
2887  simulationType = mParser.getAttributeValue("simulationType", papszAttrs);
2888  }
2889 
2890  SimulationType = toEnum(simulationType, CModelEntity::XMLStatus, CModelEntity::FIXED);
2891 
2892  mpMV = new CModelValue();
2893  addFix(mKey, mpMV);
2894  mpMV->setObjectName(Name);
2895  mpMV->setStatus(SimulationType);
2896 
2897  mCommon.pModel->getModelValues().add(mpMV, true);
2899 
2900  return;
2901 
2902  case MiriamAnnotation:
2903 
2904  if (!strcmp(pszName, "MiriamAnnotation"))
2906 
2907  break;
2908 
2909  case Comment:
2910 
2911  if (!strcmp(pszName, "Comment"))
2913 
2914  break;
2915 
2917 
2918  if (!strcmp(pszName, "ListOfUnsupportedAnnotations"))
2920 
2921  break;
2922 
2923  case Expression:
2924 
2925  if (!strcmp(pszName, "Expression"))
2927 
2928  break;
2929 
2930  case InitialExpression:
2931 
2932  if (!strcmp(pszName, "InitialExpression"))
2934 
2935  break;
2936 
2937  case MathML: // Old file format support
2938 
2939  if (!strcmp(pszName, "MathML"))
2940  {
2941  /* If we do not have a MathML element handler we create one. */
2942  if (!mpMathMLElement)
2943  mpMathMLElement = new MathMLElement(mParser, mCommon);
2944 
2946  }
2947 
2948  break;
2949 
2950  default:
2953  break;
2954  }
2955  }
2956 
2958 
2960  {
2962  }
2963 
2964  mParser.onStartElement(pszName, papszAttrs);
2965 
2966  return;
2967 }
UnknownElement mUnknownElement
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
#define MCXML
void addFix(const std::string &key, CCopasiObject *pObject)
Definition: CXMLHandler.h:119
#define UNKNOWN_ELEMENT
virtual void onStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
virtual bool add(const CType &src)
virtual void setStatus(const CModelEntity::Status &status)
void pushElementHandler(CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon > *elementHandler)
CharacterDataElement mCharacterDataElement
static const char * XMLStatus[]
Definition: CModelValue.h:72
CType toEnum(const char *attribute, const char **enumNames, const CType &enumDefault)
Definition: utility.h:107
MiriamAnnotationElement mMiriamAnnotationElement
ListOfUnsupportedAnnotationsElement mListOfUnsupportedAnnotationsElement
int getCurrentLineNumber() const
Definition: CExpat.h:470
CommentElement mCommentElement
bool setObjectName(const std::string &name)

Member Data Documentation

std::string CCopasiXMLParser::ModelValueElement::mKey
private

The key in the CopasiML file

Definition at line 1469 of file CCopasiXMLParser.h.

MathMLElement* CCopasiXMLParser::ModelValueElement::mpMathMLElement
private

Definition at line 1464 of file CCopasiXMLParser.h.

CModelValue* CCopasiXMLParser::ModelValueElement::mpMV
private

Definition at line 1463 of file CCopasiXMLParser.h.


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