Public Types | Public Member Functions | Static Public Member Functions | List of all members
UtilsXML Class Reference

Public Types

typedef drain::Path< std::string,'/'> path_t
 Tree path type. // TODO: extract from template.
 
typedef path_t::elem_t path_elem_t
 
typedef std::list< path_tpath_list_t
 

Public Member Functions

template<class T >
bool findById (const T &t, const std::string &id, typename T::path_t &result, const typename T::path_t &path)
 
template<class T , class N >
bool findByTag (const T &t, const N &tag, UtilsXML::path_list_t &result, const path_t &path)
 
template<class T , class N >
bool findByTags (const T &t, const std::set< N > &tags, UtilsXML::path_list_t &result, const UtilsXML::path_t &path)
 

Static Public Member Functions

template<class V >
static bool findById (const V &tree, const std::string &tag, typename V::path_t &result, const typename V::path_t &path=path_t())
 Find the first occurrence of given id using recursive breath-first search. More...
 
template<class T >
static bool findById (const T &tree, const std::string &tag, path_list_t &result, const path_t &path=path_t())
 Find the occurrence(s) of given ID using recursive breath-first search. More...
 
template<class T , class E >
static bool findByTag (const T &tree, const E &tag, path_list_t &result, const path_t &path=path_t())
 
template<class T , class E >
static bool findByTags (const T &tree, const std::set< E > &tags, path_list_t &result, const path_t &path=path_t())
 "Forward definition" More...
 
template<class T , class C >
static bool findByClass (const T &t, const C &cls, std::list< typename T::path_elem_t > &result)
 Finds child elements in an XML structure by class name. More...
 
template<class T , class C >
static bool findByClass (const T &t, const C &cls, path_list_t &result, const path_t &path=path_t())
 Finds elements recursively in an XML structure by class name supplied as an enumeration type. More...
 

Member Function Documentation

◆ findByClass() [1/2]

bool findByClass ( const T &  t,
const C &  cls,
UtilsXML::path_list_t &  result,
const path_t path = path_t() 
)
inlinestatic

Finds elements recursively in an XML structure by class name supplied as an enumeration type.

Template Parameters
V- XML tree
C- enum type, for which a unique (static) EnumDict has been detected.
Parameters
path- starting point

◆ findByClass() [2/2]

bool findByClass ( const T &  t,
const C &  cls,
std::list< typename T::path_elem_t > &  result 
)
static

Finds child elements in an XML structure by class name.

Immediate descendants.

Template Parameters
V- XML tree

In a way, this is a forward definition – this could also be in TreeXMLutilities.

◆ findById() [1/2]

bool findById ( const T &  tree,
const std::string &  tag,
UtilsXML::path_list_t &  result,
const path_t path = path_t() 
)
static

Find the occurrence(s) of given ID using recursive breath-first search.

By definition, id attributes should be unique. This function nevertheless returns a list if user wants to handle more than one elements found.

Parameters
tree- source element,
id- id attribute to be searched for
result- path of pointing to
path- start path for the search.
Returns
- true, if an element was found.

◆ findById() [2/2]

static bool findById ( const V &  tree,
const std::string &  tag,
typename V::path_t &  result,
const typename V::path_t &  path = path_t() 
)
static

Find the first occurrence of given id using recursive breath-first search.

By definition, id attributes should be unique.

Parameters
tree- source element,
id- id attribute to be searched for
result- path of the element with required ID, if found.
path- start path for the search.
Returns
- true, if an element was found.

◆ findByTag() [1/2]

bool findByTag ( const T &  t,
const N &  tag,
UtilsXML::path_list_t &  result,
const path_t path 
)
Template Parameters
Tree

◆ findByTag() [2/2]

static bool findByTag ( const T &  tree,
const E &  tag,
path_list_t &  result,
const path_t path = path_t() 
)
static

Find all the occurrences of given tag type using recursive breath-first search. This is a "forward definition" – this could also be in TreeXMLutilities.

◆ findByTags() [1/2]

bool findByTags ( const T &  t,
const std::set< N > &  tags,
UtilsXML::path_list_t &  result,
const UtilsXML::path_t path 
)
Template Parameters
Tree

◆ findByTags() [2/2]

static bool findByTags ( const T &  tree,
const std::set< E > &  tags,
path_list_t &  result,
const path_t path = path_t() 
)
static

"Forward definition"

Template Parameters
V- XML tree

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