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

Public Member Functions

 CXML ()
 
const CCopasiParameterGroupgetConfiguration () const
 
virtual bool load (std::istream &is, const std::string &relativeTo)
 
virtual bool save (std::ostream &os, const std::string &relativeTo)
 
void setConfiguration (const CCopasiParameterGroup &configuration)
 
 ~CXML ()
 
- Public Member Functions inherited from CCopasiXMLInterface
 CCopasiXMLInterface ()
 
bool load (const std::string &fileName, const std::string &relativeTo)
 
bool save (const std::string &fileName, const std::string &relativeTo)
 
virtual ~CCopasiXMLInterface ()
 

Private Attributes

CCopasiParameterGroup mConfiguration
 

Additional Inherited Members

- Public Types inherited from CCopasiXMLInterface
enum  EncodingType { none = 0, standard, attribute, character }
 
- Static Public Member Functions inherited from CCopasiXMLInterface
static std::string encode (const std::string &str, const EncodingType &type=standard)
 
static std::string utf8 (const std::string &str)
 
- Protected Member Functions inherited from CCopasiXMLInterface
bool endSaveElement (const std::string &name)
 
bool saveData (const std::string &data)
 
bool saveElement (const std::string &name, CXMLAttributeList &attributeList)
 
bool saveParameter (const CCopasiParameter &parameter)
 
bool saveParameterGroup (const std::vector< CCopasiParameter * > &group)
 
bool saveXhtml (const std::string &xhtml)
 
bool startSaveElement (const std::string &name)
 
bool startSaveElement (const std::string &name, CXMLAttributeList &attributeList)
 
- Protected Attributes inherited from CCopasiXMLInterface
std::string mIndent
 
std::istream * mpIstream
 
std::ostream * mpOstream
 
std::string mPWD
 

Detailed Description

Class dealing with the loading and writing of the XML configuration file.

Definition at line 253 of file CConfigurationFile.h.

Constructor & Destructor Documentation

CConfigurationFile::CXML::CXML ( )

Constructor

Definition at line 343 of file CConfigurationFile.cpp.

References CCopasiParameterGroup::assertGroup(), and mConfiguration.

343  :
345  mConfiguration("Configuration")
346 {
347  mConfiguration.assertGroup("Recent Files");
348  mConfiguration.assertGroup("Recent SBML Files");
349  mConfiguration.assertGroup("MIRIAM Resources");
350  mConfiguration.assertGroup("Recent SEDML Files");
351 }
CCopasiParameterGroup * assertGroup(const std::string &name)
CCopasiParameterGroup mConfiguration
CConfigurationFile::CXML::~CXML ( )

Destructor

Definition at line 353 of file CConfigurationFile.cpp.

354 {}

Member Function Documentation

const CCopasiParameterGroup & CConfigurationFile::CXML::getConfiguration ( ) const

Retrieve the configuration contents

Returns
const CConfigurationFile & configuration

Definition at line 445 of file CConfigurationFile.cpp.

Referenced by CConfigurationFile::load().

446 {return mConfiguration;}
CCopasiParameterGroup mConfiguration
bool CConfigurationFile::CXML::load ( std::istream &  is,
const std::string &  relativeTo 
)
virtual

Load information from a given istream.

Parameters
std::istream& is
conststd::string & relativeTo
Returns
bool success

Implements CCopasiXMLInterface.

Definition at line 381 of file CConfigurationFile.cpp.

References BUFFER_SIZE, CCopasiParameterGroup::clear(), CExpatTemplate< CType >::getCurrentColumnNumber(), CCopasiXMLParser::getCurrentGroup(), CExpatTemplate< CType >::getCurrentLineNumber(), CExpatTemplate< CType >::getErrorString(), COptions::getValue(), MCConfiguration, MCXML, CExpatTemplate< CType >::parse(), CCopasiMessage::RAW, CCopasiObject::setObjectName(), and CCopasiMessage::WARNING.

383 {
384  mPWD = relativeTo;
385 
386  is.imbue(std::locale::classic());
387  is.precision(16);
388 
389  mpIstream = &is;
390  bool success = true;
391  bool done = false;
392 
393  CVersion Version;
394  CCopasiXMLParser Parser(Version);
395 
396 #define BUFFER_SIZE 0xfffe
397  char * pBuffer = new char[BUFFER_SIZE + 1];
398 
399  while (!done)
400  {
401  mpIstream->get(pBuffer, BUFFER_SIZE, 0);
402 
403  if (mpIstream->eof()) done = true;
404 
405  if (mpIstream->fail() && !done)
406  {
407  std::string ConfigFile;
408  COptions::getValue("ConfigFile", ConfigFile);
410 
411  done = true;
412  success = false;
413  }
414 
415  if (!Parser.parse(pBuffer, -1, done))
416  {
418  Parser.getCurrentLineNumber(),
419  Parser.getCurrentColumnNumber(),
420  Parser.getErrorString());
421  done = true;
422  success = false;
423  }
424  }
425 
426  delete [] pBuffer;
427 #undef BUFFER_SIZE
428 
429  if (success && Parser.getCurrentGroup() != NULL)
430  {
431  mConfiguration = * Parser.getCurrentGroup();
432  mConfiguration.setObjectName("Configuration");
433 
434  delete Parser.getCurrentGroup();
435  }
436  else
438 
439  return success;
440 }
#define MCConfiguration
#define MCXML
struct MESSAGES Message
static void getValue(const std::string &name, CType &value)
Definition: COptions.h:124
CCopasiParameterGroup mConfiguration
#define BUFFER_SIZE
bool setObjectName(const std::string &name)
bool CConfigurationFile::CXML::save ( std::ostream &  os,
const std::string &  relativeTo 
)
virtual

Save information to a given ostream.

Parameters
std::ostream& os
conststd::string & relativeTo
Returns
bool success

Implements CCopasiXMLInterface.

Definition at line 356 of file CConfigurationFile.cpp.

References CVersion::getVersion(), UTCTimeStamp(), and CVersion::VERSION.

358 {
359  mPWD = relativeTo;
360 
361  os.imbue(std::locale::classic());
362  os.precision(16);
363 
364  mpOstream = &os;
365 
366  *mpOstream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
367  << std::endl;
368 
369  *mpOstream << "<!-- generated with COPASI "
371  << " (http://www.copasi.org) at "
372  << UTCTimeStamp()
373  << " UTC -->"
374  << std::endl;
375 
377 
378  return true;
379 }
CCopasiParameterGroup mConfiguration
std::string UTCTimeStamp()
Definition: utility.cpp:64
const std::string & getVersion() const
Definition: CVersion.cpp:139
bool saveParameter(const CCopasiParameter &parameter)
static const CVersion VERSION
Definition: CVersion.h:164
void CConfigurationFile::CXML::setConfiguration ( const CCopasiParameterGroup configuration)

Set the configuration contents

Parameters
constCConfigurationFile & configuration

Definition at line 442 of file CConfigurationFile.cpp.

Referenced by CConfigurationFile::save().

443 {mConfiguration = configuration;}
CCopasiParameterGroup mConfiguration

Member Data Documentation

CCopasiParameterGroup CConfigurationFile::CXML::mConfiguration
private

A pointer to the CCopasiParameterGroup containing the information

Definition at line 302 of file CConfigurationFile.h.

Referenced by CXML().


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