aGrUM  0.16.0
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. More...
 
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. More...
 
void FromString (const std::string &temp, std::string *out) const
 Specialization for std::string. More...
 
int Row () const
 Return the position, in the original source file, of this node or attribute. More...
 
int Column () const
 Return the position, in the original source file, of this node or attribute. More...
 
bool operator== (const Base &rhs) const
 Compare internal TiXml pointers to determine is both are wrappers around the same node. More...
 
bool operator!= (const Base &rhs) const
 Compare internal TiXml pointers to determine is both are wrappers around the same node. More...
 
std::string BuildDetailedErrorString () const
 Builds detailed error string using TiXmlDocument::Error() and others. More...
 
virtual ~Base ()
 Destructor. More...
 

Protected Attributes

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

Protected Member Functions

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

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.

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

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  }
int ErrorCol() const
The column where the error occured. See ErrorRow()
Definition: tinyxml.h:1762
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
Definition: tinyxml.h:1743
virtual TiXmlBase * GetBasePointer() const =0
bool Error() const
If an error occurs, Error will be set to true.
Definition: tinyxml.h:1740
const char * Value() const
The meaning of &#39;value&#39; changes for the specific type of TiXmlNode.
Definition: tinyxml.h:517
Always the top level node.
Definition: tinyxml.h:1655
int ErrorRow() const
Returns the location (if known) of the error.
Definition: tinyxml.h:1761
const TiXmlDocument * GetDocument() const
Return a pointer to the Document this node lives in.
Definition: tinyxml.cpp:424
The parent class for everything in the Document Object Model.
Definition: tinyxml.h:454
+ 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(); }
virtual TiXmlBase * GetBasePointer() const =0
int Column() const
See Row()
Definition: tinyxml.h:276

◆ FromString() [1/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.

References TICPPTHROW.

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

◆ FromString() [2/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  }

◆ GetBasePointer()

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

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

Referenced by operator!=(), and operator==().

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

References GetBasePointer().

231  {
232  return (GetBasePointer() != rhs.GetBasePointer());
233  }
virtual TiXmlBase * GetBasePointer() const =0
+ 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.

References GetBasePointer().

222  {
223  return (GetBasePointer() == rhs.GetBasePointer());
224  }
virtual TiXmlBase * GetBasePointer() const =0
+ 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(); }
virtual TiXmlBase * GetBasePointer() const =0
int Row() const
Return the position, in the original source file, of this node or attribute.
Definition: tinyxml.h:275

◆ SetImpRC()

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

Definition at line 279 of file ticpp.h.

Referenced by ticpp::Attribute::SetTiXmlPointer().

279 { m_impRC = nodeBase->m_tiRC; }
TiCppRCImp * m_impRC
Holds status of internal TiXmlPointer - use this to determine if object has been deleted already...
Definition: ticpp.h:267
+ Here is the caller graph for this function:

◆ ToString() [1/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.

References TICPPTHROW.

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  }
#define TICPPTHROW(message)
This allows you to stream your exceptions in.
Definition: ticpp.h:92

◆ ToString() [2/2]

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

Definition at line 180 of file ticpp.h.

180 { return value; }

◆ ValidatePointer()

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

Definition at line 281 of file ticpp.h.

References TiCppRCImp::IsNull(), and TICPPTHROW.

Referenced by ticpp::Element::FirstAttribute(), ticpp::Element::GetAttributeImp(), ticpp::Element::GetTextImp(), ticpp::Element::HasAttribute(), ticpp::Element::LastAttribute(), ticpp::Attribute::Name(), ticpp::Attribute::Next(), ticpp::Attribute::Previous(), ticpp::Attribute::Print(), ticpp::Element::RemoveAttribute(), and ticpp::Attribute::Value().

281  {
282  if (m_impRC->IsNull()) {
283  TICPPTHROW("Internal TiXml Pointer is nullptr");
284  }
285  }
#define TICPPTHROW(message)
This allows you to stream your exceptions in.
Definition: ticpp.h:92
bool IsNull()
Returns state of internal pointer - will be null if the object was deleted.
Definition: ticpp.cpp:973
TiCppRCImp * m_impRC
Holds status of internal TiXmlPointer - use this to determine if object has been deleted already...
Definition: ticpp.h:267
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_impRC


The documentation for this class was generated from the following file: