Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
Nektar::LibUtilities::XmlDataSource Class Reference

#include <FieldIOXml.h>

Inheritance diagram for Nektar::LibUtilities::XmlDataSource:
Inheritance graph
[legend]
Collaboration diagram for Nektar::LibUtilities::XmlDataSource:
Collaboration graph
[legend]

Public Member Functions

 XmlDataSource (TiXmlDocument &doc)
 Default constructor. More...
 
 XmlDataSource (const std::string &fn)
 Constructor based on filename. More...
 
 ~XmlDataSource ()
 Destructor cleans up memory usage. More...
 
TiXmlDocument & Get ()
 Return the TinyXML document of this source. More...
 
const TiXmlDocument & Get () const
 Return the TinyXML document of this source. More...
 

Static Public Member Functions

static DataSourceSharedPtr create (const std::string &fn)
 Create a new XML data source based on the filename. More...
 
static DataSourceSharedPtr create (TiXmlDocument &fn)
 Create a new XML data source based on a TiXmlDocument. More...
 

Private Attributes

TiXmlDocument * m_doc
 Internal TinyXML document storage. More...
 
bool m_needsFree
 Boolean dictating whether document needs to be freed or not. More...
 

Detailed Description

Definition at line 50 of file FieldIOXml.h.

Constructor & Destructor Documentation

Nektar::LibUtilities::XmlDataSource::XmlDataSource ( TiXmlDocument &  doc)
inline

Default constructor.

Definition at line 54 of file FieldIOXml.h.

Referenced by create().

54 : m_doc(&doc), m_needsFree(false) { }
bool m_needsFree
Boolean dictating whether document needs to be freed or not.
Definition: FieldIOXml.h:106
TiXmlDocument * m_doc
Internal TinyXML document storage.
Definition: FieldIOXml.h:104
Nektar::LibUtilities::XmlDataSource::XmlDataSource ( const std::string &  fn)
inline

Constructor based on filename.

Definition at line 57 of file FieldIOXml.h.

References ASSERTL0, and m_doc.

57  : m_needsFree(true)
58  {
59  m_doc = new TiXmlDocument(fn);
60  bool loadOkay = m_doc->LoadFile();
61  std::stringstream errstr;
62  errstr << "Unable to load file: " << fn << std::endl;
63  errstr << "Reason: " << m_doc->ErrorDesc() << std::endl;
64  errstr << "Position: Line " << m_doc->ErrorRow() << ", Column "
65  << m_doc->ErrorCol() << std::endl;
66  ASSERTL0(loadOkay, errstr.str());
67  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
bool m_needsFree
Boolean dictating whether document needs to be freed or not.
Definition: FieldIOXml.h:106
TiXmlDocument * m_doc
Internal TinyXML document storage.
Definition: FieldIOXml.h:104
Nektar::LibUtilities::XmlDataSource::~XmlDataSource ( )
inline

Destructor cleans up memory usage.

Definition at line 70 of file FieldIOXml.h.

References m_doc, and m_needsFree.

71  {
72  if (m_needsFree)
73  {
74  delete m_doc;
75  }
76  }
bool m_needsFree
Boolean dictating whether document needs to be freed or not.
Definition: FieldIOXml.h:106
TiXmlDocument * m_doc
Internal TinyXML document storage.
Definition: FieldIOXml.h:104

Member Function Documentation

static DataSourceSharedPtr Nektar::LibUtilities::XmlDataSource::create ( const std::string &  fn)
inlinestatic

Create a new XML data source based on the filename.

Definition at line 91 of file FieldIOXml.h.

References XmlDataSource().

Referenced by Nektar::SpatialDomains::MeshGraph::ReadExpansions(), Nektar::LibUtilities::FieldIOXml::v_Import(), and Nektar::LibUtilities::FieldIOXml::v_ImportFieldMetaData().

92  {
93  return DataSourceSharedPtr(new XmlDataSource(fn));
94  }
boost::shared_ptr< DataSource > DataSourceSharedPtr
Definition: FieldIO.h:81
XmlDataSource(TiXmlDocument &doc)
Default constructor.
Definition: FieldIOXml.h:54
static DataSourceSharedPtr Nektar::LibUtilities::XmlDataSource::create ( TiXmlDocument &  fn)
inlinestatic

Create a new XML data source based on a TiXmlDocument.

Definition at line 97 of file FieldIOXml.h.

References XmlDataSource().

98  {
99  return DataSourceSharedPtr(new XmlDataSource(fn));
100  }
boost::shared_ptr< DataSource > DataSourceSharedPtr
Definition: FieldIO.h:81
XmlDataSource(TiXmlDocument &doc)
Default constructor.
Definition: FieldIOXml.h:54
TiXmlDocument& Nektar::LibUtilities::XmlDataSource::Get ( )
inline

Return the TinyXML document of this source.

Definition at line 79 of file FieldIOXml.h.

References m_doc.

Referenced by Nektar::LibUtilities::FieldIOXml::ImportFieldData(), Nektar::LibUtilities::FieldIOXml::ImportFieldDefs(), and Nektar::LibUtilities::FieldIOXml::v_ImportFieldMetaData().

80  {
81  return *m_doc;
82  }
TiXmlDocument * m_doc
Internal TinyXML document storage.
Definition: FieldIOXml.h:104
const TiXmlDocument& Nektar::LibUtilities::XmlDataSource::Get ( ) const
inline

Return the TinyXML document of this source.

Definition at line 85 of file FieldIOXml.h.

References m_doc.

86  {
87  return *m_doc;
88  }
TiXmlDocument * m_doc
Internal TinyXML document storage.
Definition: FieldIOXml.h:104

Member Data Documentation

TiXmlDocument* Nektar::LibUtilities::XmlDataSource::m_doc
private

Internal TinyXML document storage.

Definition at line 104 of file FieldIOXml.h.

Referenced by Get(), XmlDataSource(), and ~XmlDataSource().

bool Nektar::LibUtilities::XmlDataSource::m_needsFree
private

Boolean dictating whether document needs to be freed or not.

Definition at line 106 of file FieldIOXml.h.

Referenced by ~XmlDataSource().