COPASI API  4.16.103
Functions
CCopasiXMLInterface.cpp File Reference
#include <fstream>
#include <limits>
#include <cmath>
#include "copasi.h"
#include "CCopasiXMLInterface.h"
#include "model/CModel.h"
#include "report/CReportDefinition.h"
#include "report/CReportDefinitionVector.h"
#include "plot/COutputDefinitionVector.h"
#include "plot/CPlotSpecification.h"
#include "CCopasiXMLParser.h"
#include "utilities/CCopasiVector.h"
#include "utilities/CSlider.h"
#include "utilities/CDirEntry.h"
#include "commandline/CLocaleString.h"
Include dependency graph for CCopasiXMLInterface.cpp:

Go to the source code of this file.

Functions

void encodeATTRIBUTE (const char &chr, std::ostringstream &xml)
 
void encodeCHARACTER (const char &chr, std::ostringstream &xml)
 
void encodeNONE (const char &chr, std::ostringstream &xml)
 
void encodeSTD (const char &chr, std::ostringstream &xml)
 
std::ostream & operator<< (std::ostream &os, const CCopasiXMLInterface::DBL &dbl)
 
std::ostream & operator<< (std::ostream &os, const CXMLAttributeList &attr)
 

Function Documentation

void encodeATTRIBUTE ( const char &  chr,
std::ostringstream &  xml 
)

Definition at line 106 of file CCopasiXMLInterface.cpp.

Referenced by CCopasiXMLInterface::encode().

107 {
108  switch (chr)
109  {
110  case '&':
111  xml << "&amp;";
112  break;
113 
114  case '<':
115  xml << "&lt;";
116  break;
117 
118  case '\"':
119  xml << "&quot;";
120  break;
121 
122  case '\t': // Without this <tab> is converted to <space>
123  xml << "&#x09;";
124  break;
125 
126  case '\n': // Without this linebreak is converted to <space>
127  xml << "&#x0a;";
128  break;
129 
130  default:
131  xml << chr;
132  break;
133  }
134 
135  return;
136 }
void encodeCHARACTER ( const char &  chr,
std::ostringstream &  xml 
)

Definition at line 138 of file CCopasiXMLInterface.cpp.

Referenced by CCopasiXMLInterface::encode().

139 {
140  switch (chr)
141  {
142  case '&':
143  xml << "&amp;";
144  break;
145 
146  case '<':
147  xml << "&lt;";
148  break;
149 
150  default:
151  xml << chr;
152  break;
153  }
154 
155  return;
156 }
void encodeNONE ( const char &  chr,
std::ostringstream &  xml 
)

Definition at line 68 of file CCopasiXMLInterface.cpp.

Referenced by CCopasiXMLInterface::encode().

69 {
70  xml << chr;
71  return;
72 }
void encodeSTD ( const char &  chr,
std::ostringstream &  xml 
)

Definition at line 74 of file CCopasiXMLInterface.cpp.

Referenced by CCopasiXMLInterface::encode().

75 {
76  switch (chr)
77  {
78  case '&':
79  xml << "&amp;";
80  break;
81 
82  case '\'':
83  xml << "&apos;";
84  break;
85 
86  case '<':
87  xml << "&lt;";
88  break;
89 
90  case '>':
91  xml << "&gt;";
92  break;
93 
94  case '\"':
95  xml << "&quot;";
96  break;
97 
98  default:
99  xml << chr;
100  break;
101  }
102 
103  return;
104 }
std::ostream& operator<< ( std::ostream &  os,
const CCopasiXMLInterface::DBL dbl 
)

Definition at line 229 of file CCopasiXMLInterface.cpp.

References CCopasiXMLInterface::DBL::mValue.

230 {
231  os.precision(16);
232 
233  if (isnan(dbl.mValue))
234  os << "NaN";
235  else if (finite(dbl.mValue))
236  os << dbl.mValue;
237  else if (dbl.mValue > 0.0)
238  os << "INF";
239  else if (dbl.mValue < 0.0)
240  os << "-INF";
241 
242  return os;
243 }
std::ostream& operator<< ( std::ostream &  os,
const CXMLAttributeList attr 
)

Definition at line 558 of file CCopasiXMLInterface.cpp.

References CXMLAttributeList::mAttributeList, and CXMLAttributeList::mSaveList.

559 {
560  std::vector< std::string >::const_iterator itAttr = attr.mAttributeList.begin();
561  std::vector< bool >::const_iterator itSave = attr.mSaveList.begin();
562  std::vector< bool >::const_iterator endSave = attr.mSaveList.end();
563 
564  for (; itSave != endSave; ++itSave)
565  if (*itSave)
566  {
567  os << " " << *itAttr++;
568  os << "=\"" << *itAttr++ << "\"";
569  }
570  else
571  itAttr += 2;
572 
573  return os;
574 }
std::vector< std::string > mAttributeList
std::vector< bool > mSaveList