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.

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

Referenced by create().

◆ XmlDataSource() [2/2]

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

Constructor based on filename.

Definition at line 60 of file FieldIOXml.h.

60  : m_needsFree(true)
61  {
62  m_doc = new TiXmlDocument(fn);
63  bool loadOkay = m_doc->LoadFile();
64  std::stringstream errstr;
65  errstr << "Unable to load file: " << fn << std::endl;
66  errstr << "Reason: " << m_doc->ErrorDesc() << std::endl;
67  errstr << "Position: Line " << m_doc->ErrorRow() << ", Column "
68  << m_doc->ErrorCol() << std::endl;
69  ASSERTL0(loadOkay, errstr.str());
70  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215

References ASSERTL0, and m_doc.

◆ ~XmlDataSource()

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

Destructor cleans up memory usage.

Definition at line 73 of file FieldIOXml.h.

74  {
75  if (m_needsFree)
76  {
77  delete m_doc;
78  }
79  }

References m_doc, and m_needsFree.

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 94 of file FieldIOXml.h.

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

References XmlDataSource().

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

◆ 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 100 of file FieldIOXml.h.

101  {
102  return DataSourceSharedPtr(new XmlDataSource(fn));
103  }

References XmlDataSource().

◆ Get() [1/2]

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

Return the TinyXML document of this source.

Definition at line 82 of file FieldIOXml.h.

83  {
84  return *m_doc;
85  }

References m_doc.

◆ Get() [2/2]

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

Return the TinyXML document of this source.

Definition at line 88 of file FieldIOXml.h.

89  {
90  return *m_doc;
91  }

References m_doc.

Member Data Documentation

◆ m_doc

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

Internal TinyXML document storage.

Definition at line 107 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 109 of file FieldIOXml.h.

Referenced by ~XmlDataSource().