-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathname_selector.hpp
43 lines (33 loc) · 1.05 KB
/
name_selector.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef MEDIASEQUENCER_PLUGIN_UTIL_XPATH_NAME_SELECTOR_HPP
#define MEDIASEQUENCER_PLUGIN_UTIL_XPATH_NAME_SELECTOR_HPP
#include <boost/range/adaptor/transformed.hpp>
namespace mediasequencer { namespace plugin { namespace util { namespace xpath {
class _name {
};
namespace {
const _name name;
}
template<typename Element>
struct node_to_name {
typedef std::string result_type;
std::string operator()(Element element) const {
std::string name = element.get_node().name();
std::string::size_type colonPosition = name.find(':');
if (colonPosition != std::string::npos) {
name = name.substr(colonPosition+1);
}
return name;
}
};
template <>
struct is_expr<_name>: std::true_type {
};
template<typename Range>
auto
operator|(Range const& range, _name const&)
-> decltype(range |transformed(node_to_name<typename Range::iterator::reference>()))
{
return range |transformed(node_to_name<typename Range::iterator::reference>());
}
}}}}
#endif // MEDIASEQUENCER_PLUGIN_UTIL_XPATH_NAME_SELECTOR_HPP