COPASI API  4.16.103
Public Member Functions | Private Attributes | Friends | List of all members
CXMLAttributeList Class Reference

#include <CCopasiXMLInterface.h>

Collaboration diagram for CXMLAttributeList:
Collaboration graph
[legend]

Public Member Functions

template<class CType >
bool add (const std::string &name, const CType &value)
 
bool add (const std::string &name, const C_FLOAT64 &value)
 
template<class CType >
bool add (const std::string &name, const CType &value, const CCopasiXMLInterface::EncodingType &encodingType)
 
 CXMLAttributeList ()
 
 CXMLAttributeList (const CXMLAttributeList &src)
 
bool erase ()
 
std::string getAttribute (const size_t &index) const
 
const std::string & getName (const size_t &index) const
 
const std::string & getValue (const size_t &index) const
 
template<class CType >
bool set (const size_t &index, const std::string &name, const CType &value)
 
template<class CType >
bool set (const size_t &index, const std::string &name, const CType &value, const CCopasiXMLInterface::EncodingType &encodingType)
 
bool setName (const size_t &index, const std::string &name)
 
template<class CType >
bool setValue (const size_t &index, const CType &value)
 
template<class CType >
bool setValue (const size_t &index, const CType &value, const CCopasiXMLInterface::EncodingType &encodingType)
 
size_t size ()
 
bool skip (const size_t &index)
 
 ~CXMLAttributeList ()
 

Private Attributes

std::vector< std::string > mAttributeList
 
std::vector< bool > mSaveList
 

Friends

std::ostream & operator<< (std::ostream &os, const CXMLAttributeList &attr)
 

Detailed Description

A list of XML attributes used by saveElement and startSaveElement.

Definition at line 276 of file CCopasiXMLInterface.h.

Constructor & Destructor Documentation

CXMLAttributeList::CXMLAttributeList ( )

Constructor.

Definition at line 502 of file CCopasiXMLInterface.cpp.

502  :
503  mAttributeList(),
504  mSaveList()
505 {}
std::vector< std::string > mAttributeList
std::vector< bool > mSaveList
CXMLAttributeList::CXMLAttributeList ( const CXMLAttributeList src)

Copy constructor.

Parameters
constCXMLAttributeList & src

Definition at line 507 of file CCopasiXMLInterface.cpp.

507  :
509  mSaveList(src.mSaveList)
510 {}
std::vector< std::string > mAttributeList
std::vector< bool > mSaveList
CXMLAttributeList::~CXMLAttributeList ( )

Destructor.

Definition at line 512 of file CCopasiXMLInterface.cpp.

512 {}

Member Function Documentation

template<class CType >
bool CXMLAttributeList::add ( const std::string &  name,
const CType &  value 
)
inline

Add an attribute to the end of the list. Note: the value will be XML encoded

Parameters
conststd::string & name
constCType & value
Returns
bool success

Definition at line 321 of file CCopasiXMLInterface.h.

References CCopasiXMLInterface::attribute.

Referenced by add(), CCopasiXML::save(), CCopasiXML::save1DAttributes(), CCopasiXML::save2DAttributes(), CCopasiXML::saveAnnotation(), CCopasiXML::saveArrowHeadAttributes(), CCopasiXML::saveColorDefinition(), CCopasiXML::saveCurve(), CCopasiXML::saveDimensions(), CCopasiXML::saveEllipseElement(), CCopasiXML::saveFunctionList(), CCopasiXML::saveGradientAttributes(), CCopasiXML::saveGradientStop(), CCopasiXML::saveGUI(), CCopasiXML::saveImageElement(), CCopasiXML::saveLayoutList(), CCopasiXML::saveLinearGradient(), CCopasiXML::saveLineEnding(), CCopasiXML::saveLocalStyle(), CCopasiXML::saveModel(), CCopasiXML::saveModelParameter(), CCopasiXMLInterface::saveParameter(), CCopasiXML::savePlotList(), CCopasiXML::savePosition(), CCopasiXML::saveRadialGradient(), CCopasiXML::saveRectangleElement(), CCopasiXML::saveRenderInformationAttributes(), CCopasiXML::saveRenderPoint(), CCopasiXML::saveRenderTextElement(), CCopasiXML::saveReportList(), CCopasiXML::saveReportSection(), CCopasiXML::saveSBMLReference(), CCopasiXML::saveStyleAttributes(), CCopasiXML::saveTaskList(), CCopasiXML::saveTextAttributes(), and CCopasiXML::saveTransformationAttributes().

323  {return add(name, value, CCopasiXMLInterface::attribute);}
bool add(const std::string &name, const CType &value)
bool CXMLAttributeList::add ( const std::string &  name,
const C_FLOAT64 value 
)

Add an attribute to the end of the list. Note: the value will be XML encoded

Parameters
conststd::string & name
constC_FLOAT64 & value
Returns
bool success

Definition at line 524 of file CCopasiXMLInterface.cpp.

References add(), and CCopasiXMLInterface::attribute.

525 {
526  return add(name,
527  (CCopasiXMLInterface::DBL) value,
529 }
bool add(const std::string &name, const CType &value)
template<class CType >
bool CXMLAttributeList::add ( const std::string &  name,
const CType &  value,
const CCopasiXMLInterface::EncodingType encodingType 
)
inline

Add an attribute to the end of the list. Note: the value will be XML encoded

Parameters
conststd::string & name
constCType & value
constCCopasiXMLInterface::EncodingType & encodingType
Returns
bool success

Definition at line 342 of file CCopasiXMLInterface.h.

References CCopasiXMLInterface::encode(), mAttributeList, and mSaveList.

345  {
346  std::ostringstream Value;
347 
348  try
349  {
350  Value << value;
351  }
352 
353  catch (...)
354  {
355  Value << "";
356  }
357 
358  mAttributeList.push_back(name);
359  mAttributeList.push_back(CCopasiXMLInterface::encode(Value.str(),
360  encodingType));
361 
362  mSaveList.push_back(true);
363 
364  return true;
365  }
std::vector< std::string > mAttributeList
static std::string encode(const std::string &str, const EncodingType &type=standard)
std::vector< bool > mSaveList
bool CXMLAttributeList::erase ( )

Erase the content of the attribute list.

Returns
bool success

Definition at line 514 of file CCopasiXMLInterface.cpp.

References mAttributeList, and mSaveList.

Referenced by CCopasiXML::saveCurve(), CCopasiXML::saveDimensions(), CCopasiXML::saveFunctionList(), CCopasiXML::saveLayoutList(), CCopasiXML::saveModel(), CCopasiXML::savePlotList(), CCopasiXML::savePosition(), CCopasiXML::saveReportList(), CCopasiXML::saveSBMLReference(), and CCopasiXML::saveTaskList().

515 {
516  mAttributeList.clear();
517  mSaveList.clear();
518 
519  return true;
520 }
std::vector< std::string > mAttributeList
std::vector< bool > mSaveList
std::string CXMLAttributeList::getAttribute ( const size_t &  index) const

Retrieve the indexed attribute (' name="value"' or '' if skipped).

Parameters
constsize_t & index
Returns
std::string attribute

Definition at line 550 of file CCopasiXMLInterface.cpp.

References mAttributeList, and mSaveList.

551 {
552  if (mSaveList[index])
553  return " " + mAttributeList[2 * index] + "=\"" + mAttributeList[2 * index + 1] + "\"";
554  else
555  return "";
556 }
std::vector< std::string > mAttributeList
std::vector< bool > mSaveList
const std::string & CXMLAttributeList::getName ( const size_t &  index) const

Retrieve the name of the indexed attribute.

Parameters
constsize_t & index
Returns
const std::string & name

Definition at line 538 of file CCopasiXMLInterface.cpp.

References mAttributeList.

539 {return mAttributeList[2 * index];}
std::vector< std::string > mAttributeList
const std::string & CXMLAttributeList::getValue ( const size_t &  index) const

Retrieve the value of the indexed attribute.

Parameters
constsize_t & index
Returns
const std::string & value

Definition at line 541 of file CCopasiXMLInterface.cpp.

References mAttributeList.

542 {return mAttributeList[2 * index + 1];}
std::vector< std::string > mAttributeList
template<class CType >
bool CXMLAttributeList::set ( const size_t &  index,
const std::string &  name,
const CType &  value 
)
inline

Set the name and value of the indexed attribute Note: the value will be XML encoded

Parameters
constsize_t & index
conststd::string & name
constCType & value
Returns
bool success

Definition at line 397 of file CCopasiXMLInterface.h.

References CCopasiXMLInterface::attribute.

Referenced by CCopasiXML::saveReportSection().

400  {return set(index, name, value, CCopasiXMLInterface::attribute);}
bool set(const size_t &index, const std::string &name, const CType &value)
template<class CType >
bool CXMLAttributeList::set ( const size_t &  index,
const std::string &  name,
const CType &  value,
const CCopasiXMLInterface::EncodingType encodingType 
)
inline

Set the name and value of the indexed attribute Note: the value will be XML encoded

Parameters
constsize_t & index
conststd::string & name
constCType & value
constCCopasiXMLInterface::EncodingType & encodingType
Returns
bool success

Definition at line 410 of file CCopasiXMLInterface.h.

References CCopasiXMLInterface::encode(), mAttributeList, and mSaveList.

414  {
415  mAttributeList[2 * index] = name;
416 
417  std::ostringstream Value;
418 
419  try
420  {
421  Value << value;
422  }
423 
424  catch (...)
425  {
426  Value << "";
427  }
428 
429  mAttributeList[2 * index + 1] =
430  CCopasiXMLInterface::encode(Value.str(),
431  encodingType);
432  mSaveList[index] = true;
433 
434  return true;
435  }
std::vector< std::string > mAttributeList
static std::string encode(const std::string &str, const EncodingType &type=standard)
std::vector< bool > mSaveList
bool CXMLAttributeList::setName ( const size_t &  index,
const std::string &  name 
)

Set the name of the indexed attribute

Parameters
constsize_t & index
conststd::string & name
Returns
bool success

Definition at line 531 of file CCopasiXMLInterface.cpp.

References mAttributeList.

533 {
534  mAttributeList[2 * index] = name;
535  return true;
536 }
std::vector< std::string > mAttributeList
template<class CType >
bool CXMLAttributeList::setValue ( const size_t &  index,
const CType &  value 
)
inline

Set the value of the indexed attribute Note: the value will be XML encoded

Parameters
constsize_t & index
constCType & value
Returns
bool success

Definition at line 444 of file CCopasiXMLInterface.h.

References CCopasiXMLInterface::attribute.

Referenced by CCopasiXML::saveAnnotation(), CCopasiXML::saveFunctionList(), CCopasiXML::saveGUI(), CCopasiXML::saveModel(), CCopasiXML::saveReportList(), and CCopasiXML::saveSBMLReference().

446  {return setValue(index, value, CCopasiXMLInterface::attribute);}
bool setValue(const size_t &index, const CType &value)
template<class CType >
bool CXMLAttributeList::setValue ( const size_t &  index,
const CType &  value,
const CCopasiXMLInterface::EncodingType encodingType 
)
inline

Set the value of the indexed attribute Note: the value will be XML encoded

Parameters
constsize_t & index
constCType & value
constCCopasiXMLInterface::EncodingType & encodingType
Returns
bool success

Definition at line 456 of file CCopasiXMLInterface.h.

References CCopasiXMLInterface::encode(), mAttributeList, and mSaveList.

459  {
460  std::ostringstream Value;
461 
462  try
463  {
464  Value << value;
465  }
466 
467  catch (...)
468  {
469  Value << "";
470  }
471 
472  mAttributeList[2 * index + 1] =
473  CCopasiXMLInterface::encode(Value.str(),
474  encodingType);
475  mSaveList[index] = true;
476 
477  return true;
478  }
std::vector< std::string > mAttributeList
static std::string encode(const std::string &str, const EncodingType &type=standard)
std::vector< bool > mSaveList
size_t CXMLAttributeList::size ( )

Retrieve the size of the list.

Returns
size_t size

Definition at line 522 of file CCopasiXMLInterface.cpp.

References mAttributeList.

522 {return mAttributeList.size() / 2;}
std::vector< std::string > mAttributeList
bool CXMLAttributeList::skip ( const size_t &  index)

Set whether the indexed attribute shall be skipped during save.

Parameters
constsize_t & index
Returns
bool success

Definition at line 544 of file CCopasiXMLInterface.cpp.

References mSaveList.

Referenced by CCopasiXML::saveModel(), and CCopasiXMLInterface::saveParameter().

545 {
546  mSaveList[index] = false;
547  return true;
548 }
std::vector< bool > mSaveList

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const CXMLAttributeList attr 
)
friend

Definition at line 558 of file CCopasiXMLInterface.cpp.

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

Member Data Documentation

std::vector< std::string > CXMLAttributeList::mAttributeList
private

The attribute list.

Definition at line 283 of file CCopasiXMLInterface.h.

Referenced by add(), erase(), getAttribute(), getName(), getValue(), operator<<(), set(), setName(), setValue(), and size().

std::vector< bool > CXMLAttributeList::mSaveList
private

The list whether an attribute is to be saved.

Definition at line 288 of file CCopasiXMLInterface.h.

Referenced by add(), erase(), getAttribute(), operator<<(), set(), setValue(), and skip().


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