40#ifndef DRAIN_SEARCH_XML 
   41#define DRAIN_SEARCH_XML 
   45#include <drain/Sprinter.h> 
   46#include <drain/util/Path.h> 
   60    typedef path_t::elem_t path_elem_t;
 
   62    typedef std::list<path_t> path_list_t;
 
   79    bool findById(
const V & tree, 
const std::string & tag, 
typename V::path_t & result, 
const typename V::path_t & path = 
path_t());
 
   95    bool findById(
const T & tree, 
const std::string & tag, path_list_t & result, 
const path_t & path = 
path_t());
 
   99    template <
class T, 
class E>
 
  109    template <
class T, 
class E>
 
  120    template <
class T, 
class C>
 
  122    bool findByClass(
const T & t, 
const C & cls, std::list<typename T::path_elem_t> & result);
 
  131    template <
class T, 
class C>
 
 
  146bool SearchXML::findById(
const T & t, 
const std::string & 
id, 
typename T::path_t & result, 
const typename T::path_t & path){
 
  154    for (
const auto & entry: t){
 
  155        if (
findById(entry.second, 
id, result, 
path_t(path, entry.first))){
 
  170        result.push_back(path);
 
  173    for (
const auto & entry: t){
 
  177    return !result.empty();
 
 
  184template <
class T, 
class N>
 
  190        result.push_back(path);
 
  193    for (
const auto & entry: t){
 
  197    return !result.empty();
 
 
  204template <
class T,
class N>
 
  210    if (tags.count(t->getType()) > 0){
 
  211        result.push_back(path);
 
  214    for (
const auto & entry: t){
 
  219    return !result.empty();
 
 
  224template <
class T, 
class C>
 
  229    if (t->classList.has(cls)){
 
  230        result.push_back(path);
 
  233    for (
const auto & entry: t){
 
  238    return !result.empty();
 
 
  242template <
class T, 
class C>
 
  245    for (
const auto & entry: t){
 
  246        if (entry.second->hasClass(cls)){
 
  247            result.push_back(entry.first);
 
  251    return !result.empty();
 
 
  388            for (const auto & entry: children){
 
  389                toStream(ostr, entry.second, entry.first, indent+1); // Notice, no ++indent
 
  390                // "implicit" newline
 
  392            ostr << fill; //  for CLOSING tag
 
  398    tree->nodeToStream(ostr, CLOSING_TAG);
 
  400    ostr << '\n';  // Always after closing tag!
 
  402    //if (tree.data.id >= 0)
 
  403    //  ostr << "<!-- " << tree.data.id << " /-->\n";
 
Definition SearchXML.h:54
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 SearchXML.h:243
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 SearchXML.h:59
Definition DataSelector.cpp:1277