1 #ifndef _ATTRIB_STRING_PARSER_H_
2 #define _ATTRIB_STRING_PARSER_H_
7 #include <boost/regex.hpp>
21 class AttribStringParser {
31 class Iterator:
public std::iterator<std::input_iterator_tag, Attrib> {
34 Iterator(
const boost::sregex_iterator& it,
bool expand_vars):
36 m_expandVars(expand_vars)
44 m_it(
std::move(other.m_it)),
45 m_expandVars(other.m_expandVars)
55 return std::move(old);
62 return m_it == other.m_it;
65 return m_it != other.m_it;
69 boost::sregex_iterator m_it;
70 bool m_expandVars =
false;
76 static const boost::sregex_iterator endmark;
77 if (m_it != endmark) {
79 m_attrib = Attrib{(*m_it)[1], (*m_it)[2]};
80 if (m_expandVars && m_attrib.value.find(
"${") != std::string::npos) {
81 static const boost::regex varexp{
"\\$\\{([^}]+)\\}"};
85 m_attrib.value = boost::regex_replace(m_attrib.value,
86 varexp, [&
i] (
const boost::smatch& m) -> std::string {
87 const std::string name = m[1];
88 const char* cname = name.c_str();
89 if (System::isEnvSet(cname)) {
91 return System::getEnv(cname);
95 boost::match_default | boost::format_all);
110 AttribStringParser(std::string data,
bool expand_vars=
true):
112 m_expandVars(expand_vars) {
119 boost::sregex_iterator
parse()
const {
120 static const boost::regex exp{
"[[:space:]]*([^[:space:]]+)[[:space:]]*=[[:space:]]*'(.*?)'"};
121 return boost::sregex_iterator(begin(m_data),
end(m_data), exp);
123 friend Iterator begin(
const AttribStringParser&);
bool operator==(const Gaudi::StringKey &key1, const char(&key2)[N])
equality operator with C-arrays
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
bool operator!=(const Gaudi::StringKey &key1, const char(&key2)[N])
non-equality operator with C-arrays
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Helper functions to set/get the application return code.
TO * reference(FROM *from)