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

Constructor & Destructor Documentation

◆ XmlDataSource() [1/2]

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

Default constructor.

Definition at line 53 of file FieldIOXml.h.

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

Referenced by create().

◆ XmlDataSource() [2/2]

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

Constructor based on filename.

Definition at line 58 of file FieldIOXml.h.

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:208

References ASSERTL0, and m_doc.

◆ ~XmlDataSource()

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

Destructor cleans up memory usage.

Definition at line 71 of file FieldIOXml.h.

72 {
73 if (m_needsFree)
74 {
75 delete m_doc;
76 }
77 }

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

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

References XmlDataSource().

Referenced by Nektar::SpatialDomains::MeshGraph::ReadExpansionInfo(), 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 98 of file FieldIOXml.h.

99 {
100 return DataSourceSharedPtr(new XmlDataSource(fn));
101 }

References XmlDataSource().

◆ Get() [1/2]

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

Return the TinyXML document of this source.

Definition at line 80 of file FieldIOXml.h.

81 {
82 return *m_doc;
83 }

References m_doc.

◆ 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.

87 {
88 return *m_doc;
89 }

References m_doc.

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().