Nektar++
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:
[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 51 of file FieldIOXml.h.

Constructor & Destructor Documentation

◆ XmlDataSource() [1/2]

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

Default constructor.

Definition at line 55 of file FieldIOXml.h.

Referenced by create().

55 : m_doc(&doc), m_needsFree(false) { }
bool m_needsFree
Boolean dictating whether document needs to be freed or not.
Definition: FieldIOXml.h:107
TiXmlDocument * m_doc
Internal TinyXML document storage.
Definition: FieldIOXml.h:105

◆ XmlDataSource() [2/2]

Nektar::LibUtilities::XmlDataSource::XmlDataSource ( const std::string &  fn)
inline

Constructor based on filename.

Definition at line 58 of file FieldIOXml.h.

References ASSERTL0, and m_doc.

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

◆ ~XmlDataSource()

Nektar::LibUtilities::XmlDataSource::~XmlDataSource ( )
inline

Destructor cleans up memory usage.

Definition at line 71 of file FieldIOXml.h.

References m_doc, and m_needsFree.

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

Member Function Documentation

◆ create() [1/2]

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

Create a new XML data source based on the filename.

Definition at line 92 of file FieldIOXml.h.

References XmlDataSource().

Referenced by Nektar::FieldUtils::OutputInfo::Process(), Nektar::LibUtilities::FieldIOXml::v_Import(), and Nektar::LibUtilities::FieldIOXml::v_ImportFieldMetaData().

93  {
94  return DataSourceSharedPtr(new XmlDataSource(fn));
95  }
std::shared_ptr< DataSource > DataSourceSharedPtr
Definition: FieldIO.h:79
XmlDataSource(TiXmlDocument &doc)
Default constructor.
Definition: FieldIOXml.h:55

◆ create() [2/2]

static DataSourceSharedPtr Nektar::LibUtilities::XmlDataSource::create ( TiXmlDocument &  fn)
inlinestatic

Create a new XML data source based on a TiXmlDocument.

Definition at line 98 of file FieldIOXml.h.

References XmlDataSource().

99  {
100  return DataSourceSharedPtr(new XmlDataSource(fn));
101  }
std::shared_ptr< DataSource > DataSourceSharedPtr
Definition: FieldIO.h:79
XmlDataSource(TiXmlDocument &doc)
Default constructor.
Definition: FieldIOXml.h:55

◆ Get() [1/2]

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

Return the TinyXML document of this source.

Definition at line 80 of file FieldIOXml.h.

References m_doc.

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

81  {
82  return *m_doc;
83  }
TiXmlDocument * m_doc
Internal TinyXML document storage.
Definition: FieldIOXml.h:105

◆ Get() [2/2]

const TiXmlDocument& Nektar::LibUtilities::XmlDataSource::Get ( ) const
inline

Return the TinyXML document of this source.

Definition at line 86 of file FieldIOXml.h.

References m_doc.

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

Member Data Documentation

◆ m_doc

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

Internal TinyXML document storage.

Definition at line 105 of file FieldIOXml.h.

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

◆ m_needsFree

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

Boolean dictating whether document needs to be freed or not.

Definition at line 107 of file FieldIOXml.h.

Referenced by ~XmlDataSource().