42 const std::string & type,
68 void encodeNONE(
const char & chr, std::ostringstream & xml)
74 void encodeSTD(
const char & chr, std::ostringstream & xml)
161 std::string tmp = str;
162 std::ostringstream xml;
166 std::string::const_iterator it = str.begin();
167 std::string::const_iterator end = str.end();
188 for (; it != end; ++it)
202 mValue(std::numeric_limits<
C_FLOAT64>::quiet_NaN())
204 if (!value || !*value)
return;
206 std::istringstream in;
208 in.imbue(std::locale::classic());
215 if (!strcmp(value,
"INF"))
216 mValue = std::numeric_limits<C_FLOAT64>::infinity();
217 else if (!strcmp(value,
"-INF"))
218 mValue = - std::numeric_limits<C_FLOAT64>::infinity();
226 CCopasiXMLInterface::DBL::operator
const C_FLOAT64 & ()
const
235 else if (finite(dbl.
mValue))
237 else if (dbl.
mValue > 0.0)
239 else if (dbl.
mValue < 0.0)
247 std::ostringstream
utf8;
255 for (i = 0, imax = str.length(); i < imax; i++)
257 const unsigned char Char = str[i];
263 utf8 << (unsigned char)(0xc0 + ((Char >> 6) & 0x03));
264 utf8 << (
unsigned char)(0x80 + (Char & 0x3f));
280 const std::string & relativeTo)
286 if (is.fail())
return false;
288 return load(is, relativeTo);
292 const std::string & relativeTo)
298 if (os.fail())
return false;
300 if (!
save(os, relativeTo))
return false;
318 std::string::size_type start = xhtml.find_first_not_of(
"\x0a\x0d\t ");
320 if (start != std::string::npos && xhtml[start] ==
'<')
322 std::string::size_type pos = xhtml.find(
'>');
323 std::string FirstElement = xhtml.substr(0, pos);
325 if (FirstElement.find(
"xmlns=\"http://www.w3.org/1999/xhtml\"") == std::string::npos
326 && FirstElement.find(
"xmlns='http://www.w3.org/1999/xhtml'") == std::string::npos)
327 FirstElement +=
" xmlns=\"http://www.w3.org/1999/xhtml\"";
393 if (!
saveElement(
"Parameter", Attributes)) success =
false;
400 if (!
saveElement(
"Parameter", Attributes)) success =
false;
407 if (!
saveElement(
"Parameter", Attributes)) success =
false;
414 if (!
saveElement(
"Parameter", Attributes)) success =
false;
421 if (!
saveElement(
"Parameter", Attributes)) success =
false;
428 if (!
saveElement(
"Parameter", Attributes)) success =
false;
435 if (!
saveElement(
"Parameter", Attributes)) success =
false;
446 Attributes.
add(
"value", File);
448 if (!
saveElement(
"Parameter", Attributes)) success =
false;
455 if (!
saveElement(
"Parameter", Attributes)) success =
false;
493 std::vector< CCopasiParameter * >::const_iterator it = group.begin();
494 std::vector< CCopasiParameter * >::const_iterator end = group.end();
496 for (; it != end; ++it)
508 mAttributeList(src.mAttributeList),
509 mSaveList(src.mSaveList)
532 const std::string & name)
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();
564 for (; itSave != endSave; ++itSave)
567 os <<
" " << *itAttr++;
568 os <<
"=\"" << *itAttr++ <<
"\"";
std::string * pEXPRESSION
CCopasiVector< CSlider > * getSliderList()
void encodeATTRIBUTE(const char &chr, std::ostringstream &xml)
SCopasiXMLGUI(const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=CCopasiObject::Container)
void encodeSTD(const char &chr, std::ostringstream &xml)
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
CCopasiVector< CSlider > * mpSliderList
const std::string & getObjectName() const
bool startSaveElement(const std::string &name)
static bool isRelativePath(const std::string &path)
bool saveParameterGroup(const std::vector< CCopasiParameter * > &group)
bool saveData(const std::string &data)
std::vector< CCopasiParameter * > * pGROUP
const std::string & getValue(const size_t &index) const
bool saveXhtml(const std::string &xhtml)
static std::string fileName(const std::string &path)
DBL(const C_FLOAT64 &value=0.0)
CRegisteredObjectName * pCN
const std::string & getName(const size_t &index) const
bool skip(const size_t &index)
const CCopasiParameter::Type & getType() const
virtual ~CCopasiXMLInterface()
bool setName(const size_t &index, const std::string &name)
virtual bool load(std::istream &is, const std::string &relativeTo)=0
std::string getAttribute(const size_t &index) const
const Value & getValue() const
void encodeNONE(const char &chr, std::ostringstream &xml)
void encodeCHARACTER(const char &chr, std::ostringstream &xml)
std::vector< std::string > mAttributeList
static std::string encode(const std::string &str, const EncodingType &type=standard)
bool endSaveElement(const std::string &name)
static const char * XMLType[]
std::vector< bool > mSaveList
static CLocaleString fromUtf8(const std::string &utf8)
static std::string utf8(const std::string &str)
static bool makePathRelative(std::string &absolutePath, const std::string &relativeTo)
virtual bool save(std::ostream &os, const std::string &relativeTo)=0
bool saveParameter(const CCopasiParameter ¶meter)
std::ostream & operator<<(std::ostream &os, const CCopasiXMLInterface::DBL &dbl)
bool add(const std::string &name, const CType &value)