aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
ticpp::Base Class Referenceabstract

Wrapper around TiXmlBase. More...

#include <ticpp.h>

Inheritance diagram for ticpp::Base:
Collaboration diagram for ticpp::Base:

Public Member Functions

template<class T>
std::string ToString (const T &value) const
 Converts any class with a proper overload of the << opertor to a std::string.
std::string ToString (const std::string &value) const
template<class T>
void FromString (const std::string &temp, T *out) const
 Converts a std::string to any class with a proper overload of the >> opertor.
void FromString (const std::string &temp, std::string *out) const
 Specialization for std::string.
int Row () const
 Return the position, in the original source file, of this node or attribute.
int Column () const
 Return the position, in the original source file, of this node or attribute.
bool operator== (const Base &rhs) const
 Compare internal TiXml pointers to determine is both are wrappers around the same node.
bool operator!= (const Base &rhs) const
 Compare internal TiXml pointers to determine is both are wrappers around the same node.
std::string BuildDetailedErrorString () const
 Builds detailed error string using TiXmlDocument::Error() and others.
virtual ~Base ()
 Destructor.

Protected Member Functions

void SetImpRC (TiXmlBase *nodeBase)
void ValidatePointer () const
virtual TiXmlBaseGetBasePointer () const =0

Protected Attributes

TiCppRCImpm_impRC
 Holds status of internal TiXmlPointer - use this to determine if object has been deleted already.

Detailed Description

Wrapper around TiXmlBase.

Definition at line 161 of file ticpp.h.

Constructor & Destructor Documentation

◆ ~Base()

virtual ticpp::Base::~Base ( )
inlinevirtual

Destructor.

Definition at line 264 of file ticpp.h.

264{}

Member Function Documentation

◆ BuildDetailedErrorString()

std::string ticpp::Base::BuildDetailedErrorString ( ) const
inline

Builds detailed error string using TiXmlDocument::Error() and others.

Definition at line 238 of file ticpp.h.

238 {
239 std::ostringstream full_message;
240#ifndef TICPP_NO_RTTI
241 TiXmlNode* node = dynamic_cast< TiXmlNode* >(GetBasePointer());
242
243 if (node != 0) {
244 TiXmlDocument* doc = node->GetDocument();
245
246 if (doc != 0) {
247 if (doc->Error()) {
248 full_message << "\nDescription: " << doc->ErrorDesc() << "\nFile: "
249 << (strlen(doc->Value()) > 0 ? doc->Value()
250 : "<unnamed-file>")
251 << "\nLine: " << doc->ErrorRow()
252 << "\nColumn: " << doc->ErrorCol();
253 }
254 }
255 }
256
257#endif
258 return full_message.str();
259 }
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
Definition tinyxml.h:1743
int ErrorRow() const
Returns the location (if known) of the error.
Definition tinyxml.h:1761
bool Error() const
If an error occurs, Error will be set to true.
Definition tinyxml.h:1740
int ErrorCol() const
The column where the error occured. See ErrorRow().
Definition tinyxml.h:1762
const char * Value() const
The meaning of 'value' changes for the specific type of TiXmlNode.
Definition tinyxml.h:517
const TiXmlDocument * GetDocument() const
Return a pointer to the Document this node lives in.
Definition tinyxml.cpp:424
virtual TiXmlBase * GetBasePointer() const =0

References TiXmlDocument::Error(), TiXmlDocument::ErrorCol(), TiXmlDocument::ErrorDesc(), TiXmlDocument::ErrorRow(), GetBasePointer(), TiXmlNode::GetDocument(), and TiXmlNode::Value().

Here is the call graph for this function:

◆ Column()

int ticpp::Base::Column ( ) const
inline

Return the position, in the original source file, of this node or attribute.

Wrapper around TiXmlBase::Row()

Definition at line 215 of file ticpp.h.

215{ return GetBasePointer()->Column(); }
int Column() const
See Row().
Definition tinyxml.h:276

References TiXmlBase::Column(), and GetBasePointer().

Here is the call graph for this function:

◆ FromString() [1/2]

void ticpp::Base::FromString ( const std::string & temp,
std::string * out ) const
inline

Specialization for std::string.

Definition at line 201 of file ticpp.h.

201 {
202 *out = temp;
203 }

◆ FromString() [2/2]

template<class T>
void ticpp::Base::FromString ( const std::string & temp,
T * out ) const
inline

Converts a std::string to any class with a proper overload of the >> opertor.

Parameters
tempThe string to be converted
out[OUT] The container for the returned value
Exceptions
ExceptionWhen temp cannot be converted to the target type

Definition at line 189 of file ticpp.h.

189 {
190 std::istringstream val(temp);
191 val >> *out;
192
193 if (val.fail()) {
194 TICPPTHROW("Could not convert \"" << temp << "\" to target type");
195 }
196 }
#define TICPPTHROW(message)
This allows you to stream your exceptions in.
Definition ticpp.h:92

References TICPPTHROW.

Referenced by ticpp::Attribute::GetName(), ticpp::Attribute::GetValue(), and ticpp::Node::GetValue().

Here is the caller graph for this function:

◆ GetBasePointer()

virtual TiXmlBase * ticpp::Base::GetBasePointer ( ) const
protectedpure virtual

Implemented in ticpp::Attribute, and ticpp::Node.

Referenced by BuildDetailedErrorString(), Column(), operator!=(), operator==(), and Row().

Here is the caller graph for this function:

◆ operator!=()

bool ticpp::Base::operator!= ( const Base & rhs) const
inline

Compare internal TiXml pointers to determine is both are wrappers around the same node.

Definition at line 231 of file ticpp.h.

231 {
232 return (GetBasePointer() != rhs.GetBasePointer());
233 }

References GetBasePointer().

Here is the call graph for this function:

◆ operator==()

bool ticpp::Base::operator== ( const Base & rhs) const
inline

Compare internal TiXml pointers to determine is both are wrappers around the same node.

Definition at line 222 of file ticpp.h.

222 {
223 return (GetBasePointer() == rhs.GetBasePointer());
224 }

References GetBasePointer().

Here is the call graph for this function:

◆ Row()

int ticpp::Base::Row ( ) const
inline

Return the position, in the original source file, of this node or attribute.

Wrapper around TiXmlBase::Row()

Definition at line 209 of file ticpp.h.

209{ return GetBasePointer()->Row(); }
int Row() const
Return the position, in the original source file, of this node or attribute.
Definition tinyxml.h:275

References GetBasePointer(), and TiXmlBase::Row().

Here is the call graph for this function:

◆ SetImpRC()

void ticpp::Base::SetImpRC ( TiXmlBase * nodeBase)
inlineprotected

Definition at line 279 of file ticpp.h.

279{ m_impRC = nodeBase->m_tiRC; }
TiCppRCImp * m_tiRC
Pointer to reference counter.
Definition ticpprc.h:46
TiCppRCImp * m_impRC
Holds status of internal TiXmlPointer - use this to determine if object has been deleted already.
Definition ticpp.h:267

References m_impRC, and TiCppRC::m_tiRC.

Referenced by ticpp::Attribute::SetTiXmlPointer(), and ticpp::NodeImp< T >::SetTiXmlPointer().

Here is the caller graph for this function:

◆ ToString() [1/2]

std::string ticpp::Base::ToString ( const std::string & value) const
inline

Definition at line 180 of file ticpp.h.

180{ return value; }

◆ ToString() [2/2]

template<class T>
std::string ticpp::Base::ToString ( const T & value) const
inline

Converts any class with a proper overload of the << opertor to a std::string.

Parameters
valueThe value to be converted
Exceptions
ExceptionWhen value cannot be converted to a std::string

Definition at line 169 of file ticpp.h.

169 {
170 std::stringstream convert;
171 convert << value;
172
173 if (convert.fail()) {
174 TICPPTHROW("Could not convert value to text");
175 }
176
177 return convert.str();
178 }

References TICPPTHROW.

Referenced by ticpp::Attribute::SetName(), ticpp::Attribute::SetValue(), and ticpp::Node::SetValue().

Here is the caller graph for this function:

◆ ValidatePointer()

void ticpp::Base::ValidatePointer ( ) const
inlineprotected

Definition at line 281 of file ticpp.h.

281 {
282 if (m_impRC->IsNull()) {
283 TICPPTHROW("Internal TiXml Pointer is nullptr");
284 }
285 }

References m_impRC, and TICPPTHROW.

Referenced by ticpp::Attribute::GetBasePointer(), ticpp::Attribute::GetName(), ticpp::NodeImp< T >::GetTiXmlPointer(), ticpp::Attribute::GetValue(), ticpp::Attribute::Name(), ticpp::Attribute::Next(), ticpp::Attribute::Previous(), ticpp::Attribute::Print(), ticpp::Attribute::SetName(), ticpp::Attribute::SetValue(), and ticpp::Attribute::Value().

Here is the caller graph for this function:

Member Data Documentation

◆ m_impRC


The documentation for this class was generated from the following file:
  • agrum/base/external/tinyxml/ticpp/ticpp.h