40 #ifndef DRAIN_UTILS_XML
41 #define DRAIN_UTILS_XML
45 #include <drain/Sprinter.h>
59 typedef path_t::elem_t path_elem_t;
61 typedef std::list<path_t> path_list_t;
78 bool findById(
const V & tree,
const std::string & tag,
typename V::path_t & result,
const typename V::path_t & path =
path_t());
94 bool findById(
const T & tree,
const std::string & tag, path_list_t & result,
const path_t & path =
path_t());
98 template <
class T,
class E>
108 template <
class T,
class E>
119 template <
class T,
class C>
121 bool findByClass(
const T & t,
const C & cls, std::list<typename T::path_elem_t> & result);
130 template <
class T,
class C>
141 bool UtilsXML::findById(
const T & t,
const std::string &
id,
typename T::path_t & result,
const typename T::path_t & path){
149 for (
const auto & entry: t){
150 if (
findById(entry.second,
id, result,
path_t(path, entry.first))){
165 result.push_back(path);
168 for (
const auto & entry: t){
172 return !result.empty();
179 template <
class T,
class N>
185 result.push_back(path);
188 for (
const auto & entry: t){
192 return !result.empty();
199 template <
class T,
class N>
205 if (tags.count(t->getType()) > 0){
206 result.push_back(path);
209 for (
const auto & entry: t){
214 return !result.empty();
219 template <
class T,
class C>
224 if (t->classList.has(cls)){
225 result.push_back(path);
228 for (
const auto & entry: t){
233 return !result.empty();
237 template <
class T,
class C>
240 for (
const auto & entry: t){
241 if (entry.second->hasClass(cls)){
242 result.push_back(entry.first);
246 return !result.empty();
Definition: UtilsXML.h:53
static bool findByTag(const T &tree, const E &tag, path_list_t &result, const path_t &path=path_t())
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.
Definition: UtilsXML.h:238
static bool findByTags(const T &tree, const std::set< E > &tags, path_list_t &result, const path_t &path=path_t())
"Forward definition"
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.
drain::Path< std::string,'/'> path_t
Tree path type. // TODO: extract from template.
Definition: UtilsXML.h:58
Definition: DataSelector.cpp:1277