LocalGuidance
A library that generates velocity references to follow a path.
tinyxml_tools::DocumentHandleXML Class Reference

#include <DocumentHandleXML.hpp>

Inheritance diagram for tinyxml_tools::DocumentHandleXML:
Inheritance graph

Public Member Functions

 DocumentHandleXML ()
 Default ctor. More...
 
 ~DocumentHandleXML () override=default
 Default dtor. More...
 
TiXmlHandle getRootHandle ()
 
TiXmlHandle getDocumentHandle ()
 
bool create (const std::string &path, DocumentMode mode) override
 Opens or creates a file at 'path' in depending on 'mode'. More...
 
bool create (const std::string &path, DocumentMode mode, const std::string &rootName)
 
bool merge (const std::string &path, MergeMode mode) override
 Merges file at 'path' with the handled document. More...
 
bool saveAs (const std::string &path, bool force) override
 Saves the current configuration to 'path'. More...
 
bool seek (std::string handle)
 
bool seekFromRoot (const std::string &handle)
 
void reset ()
 
template<typename T , typename U = T, typename = typename std::enable_if<!std::is_const<T>::value && std::is_convertible<U, T>::value>::type>
bool read (const std::string &name, T &value, const typename traits::element< T >::stringType &attributeName=traits::element< T >::getDefaultName(), const U &defaultValue=traits::element< T >::getDefaultValue()) const
 
template<typename T , typename U = T, typename = typename std::enable_if<!std::is_const<T>::value && std::is_convertible<U, T>::value>::type>
bool readAttributes (T &value, const typename traits::element< T >::stringType &attributeName=traits::element< T >::getDefaultName(), const U &defaultValue=traits::element< T >::getDefaultValue()) const
 
template<typename T , typename = typename std::enable_if<!std::is_const<T>::value>>
bool readSiblings (const std::string &name, T &value, const typename traits::element< T >::siblingStringType &attributeName=traits::element< typename traits::element< T >::siblingType >::getDefaultName(), const typename traits::element< T >::siblingType &defaultValue=traits::element< typename traits::element< T >::siblingType >::getDefaultValue()) const
 
template<typename T , typename = typename std::enable_if<!std::is_const<T>::value>>
bool readSiblingAttributes (T &value, const typename traits::element< T >::siblingStringType &attributeName=traits::element< typename traits::element< T >::siblingType >::getDefaultName(), const typename traits::element< T >::siblingType &defaultValue=traits::element< typename traits::element< T >::siblingType >::getDefaultValue()) const
 
template<typename T >
bool write (const std::string &name, const T &value, const typename traits::element< T >::stringType &attributeName=traits::element< T >::getDefaultName())
 
template<typename T >
bool writeAttributes (const T &value, const typename traits::element< T >::stringType &attributeName=traits::element< T >::getDefaultName())
 
template<typename T >
bool writeSiblings (const std::string &name, const T &value, const typename traits::element< T >::siblingStringType &attributeName=traits::element< typename traits::element< T >::siblingType >::getDefaultName())
 
- Public Member Functions inherited from tinyxml_tools::DocumentHandle
 DocumentHandle ()
 Default ctor. More...
 
virtual ~DocumentHandle ()=default
 Default dtor. More...
 
bool save ()
 Saves the current configuration to the file specified in create() More...
 

Protected Member Functions

bool resolveDefault ()
 
bool resolveIncludes ()
 
bool resolveExtensions ()
 
virtual std::string convertPath (const std::string &path)
 
bool merge (const std::string &path, MergeMode mode, bool force)
 
bool mergeTrees (TiXmlHandle tree1, TiXmlHandle tree2, MergeMode mode)
 
void findElements (std::vector< TiXmlHandle > &handles, TiXmlHandle tree, std::string elementName)
 
const TiXmlDocument & getDocument ()
 
- Protected Member Functions inherited from tinyxml_tools::DocumentHandle
bool writeable ()
 Check whether document can be saved (overwritten) More...
 
bool readable ()
 Check whether document shall be read on creation. More...
 

Protected Attributes

TiXmlDocument document_
 
TiXmlHandle rootHandle_
 
TiXmlHandle seekedHandle_
 
- Protected Attributes inherited from tinyxml_tools::DocumentHandle
std::string filepath_
 Path of the handled file. More...
 
DocumentMode mode_
 Document mode ( allows protecting files against reads/writes ) More...
 

Constructor & Destructor Documentation

◆ DocumentHandleXML()

tinyxml_tools::DocumentHandleXML::DocumentHandleXML ( )

Default ctor.

◆ ~DocumentHandleXML()

tinyxml_tools::DocumentHandleXML::~DocumentHandleXML ( )
overridedefault

Default dtor.

Member Function Documentation

◆ convertPath()

virtual std::string tinyxml_tools::DocumentHandleXML::convertPath ( const std::string &  path)
protectedvirtual

◆ create() [1/2]

bool tinyxml_tools::DocumentHandleXML::create ( const std::string &  path,
DocumentMode  mode 
)
inlineoverridevirtual

Opens or creates a file at 'path' in depending on 'mode'.

Parameters
pathPath of the config file to open/store
modeAccess mode for the document
Returns
true, iff successful

Implements tinyxml_tools::DocumentHandle.

◆ create() [2/2]

bool tinyxml_tools::DocumentHandleXML::create ( const std::string &  path,
DocumentMode  mode,
const std::string &  rootName 
)

◆ findElements()

void tinyxml_tools::DocumentHandleXML::findElements ( std::vector< TiXmlHandle > &  handles,
TiXmlHandle  tree,
std::string  elementName 
)
protected

◆ getDocument()

const TiXmlDocument& tinyxml_tools::DocumentHandleXML::getDocument ( )
inlineprotected

◆ getDocumentHandle()

TiXmlHandle tinyxml_tools::DocumentHandleXML::getDocumentHandle ( )
inline

◆ getRootHandle()

TiXmlHandle tinyxml_tools::DocumentHandleXML::getRootHandle ( )
inline

◆ merge() [1/2]

bool tinyxml_tools::DocumentHandleXML::merge ( const std::string &  path,
MergeMode  mode 
)
overridevirtual

Merges file at 'path' with the handled document.

Parameters
pathPath of the config file to append
modeMode of the merge, see Enum description on top of this file
Returns
true, iff successful

Implements tinyxml_tools::DocumentHandle.

◆ merge() [2/2]

bool tinyxml_tools::DocumentHandleXML::merge ( const std::string &  path,
MergeMode  mode,
bool  force 
)
protected

◆ mergeTrees()

bool tinyxml_tools::DocumentHandleXML::mergeTrees ( TiXmlHandle  tree1,
TiXmlHandle  tree2,
MergeMode  mode 
)
protected

◆ read()

template<typename T , typename U = T, typename = typename std::enable_if<!std::is_const<T>::value && std::is_convertible<U, T>::value>::type>
bool tinyxml_tools::DocumentHandleXML::read ( const std::string &  name,
T &  value,
const typename traits::element< T >::stringType &  attributeName = traits::element<T>::getDefaultName(),
const U &  defaultValue = traits::element<T>::getDefaultValue() 
) const
inline

◆ readAttributes()

template<typename T , typename U = T, typename = typename std::enable_if<!std::is_const<T>::value && std::is_convertible<U, T>::value>::type>
bool tinyxml_tools::DocumentHandleXML::readAttributes ( T &  value,
const typename traits::element< T >::stringType &  attributeName = traits::element<T>::getDefaultName(),
const U &  defaultValue = traits::element<T>::getDefaultValue() 
) const
inline

◆ readSiblingAttributes()

template<typename T , typename = typename std::enable_if<!std::is_const<T>::value>>
bool tinyxml_tools::DocumentHandleXML::readSiblingAttributes ( T &  value,
const typename traits::element< T >::siblingStringType &  attributeName = traits::element<typename traits::element<T>::siblingType>::getDefaultName(),
const typename traits::element< T >::siblingType &  defaultValue = traits::element<typename traits::element<T>::siblingType>::getDefaultValue() 
) const
inline

◆ readSiblings()

template<typename T , typename = typename std::enable_if<!std::is_const<T>::value>>
bool tinyxml_tools::DocumentHandleXML::readSiblings ( const std::string &  name,
T &  value,
const typename traits::element< T >::siblingStringType &  attributeName = traits::element<typename traits::element<T>::siblingType>::getDefaultName(),
const typename traits::element< T >::siblingType &  defaultValue = traits::element<typename traits::element<T>::siblingType>::getDefaultValue() 
) const
inline

◆ reset()

void tinyxml_tools::DocumentHandleXML::reset ( )

◆ resolveDefault()

bool tinyxml_tools::DocumentHandleXML::resolveDefault ( )
protected

◆ resolveExtensions()

bool tinyxml_tools::DocumentHandleXML::resolveExtensions ( )
protected

◆ resolveIncludes()

bool tinyxml_tools::DocumentHandleXML::resolveIncludes ( )
protected

◆ saveAs()

bool tinyxml_tools::DocumentHandleXML::saveAs ( const std::string &  path,
bool  force 
)
overridevirtual

Saves the current configuration to 'path'.

Parameters
pathpath of the output file
forceforce saving if file already exists
Returns
true, iff successful

Implements tinyxml_tools::DocumentHandle.

◆ seek()

bool tinyxml_tools::DocumentHandleXML::seek ( std::string  handle)

◆ seekFromRoot()

bool tinyxml_tools::DocumentHandleXML::seekFromRoot ( const std::string &  handle)

◆ write()

template<typename T >
bool tinyxml_tools::DocumentHandleXML::write ( const std::string &  name,
const T &  value,
const typename traits::element< T >::stringType &  attributeName = traits::element<T>::getDefaultName() 
)
inline

◆ writeAttributes()

template<typename T >
bool tinyxml_tools::DocumentHandleXML::writeAttributes ( const T &  value,
const typename traits::element< T >::stringType &  attributeName = traits::element<T>::getDefaultName() 
)
inline

◆ writeSiblings()

template<typename T >
bool tinyxml_tools::DocumentHandleXML::writeSiblings ( const std::string &  name,
const T &  value,
const typename traits::element< T >::siblingStringType &  attributeName = traits::element<typename traits::element<T>::siblingType>::getDefaultName() 
)
inline

Member Data Documentation

◆ document_

TiXmlDocument tinyxml_tools::DocumentHandleXML::document_
protected

◆ rootHandle_

TiXmlHandle tinyxml_tools::DocumentHandleXML::rootHandle_
protected

◆ seekedHandle_

TiXmlHandle tinyxml_tools::DocumentHandleXML::seekedHandle_
protected

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