1 #ifndef _ATTRIB_STRING_PARSER_H_ 2 #define _ATTRIB_STRING_PARSER_H_ 8 #pragma clang diagnostic push 11 #pragma clang diagnostic ignored "-Wkeyword-macro" 13 #include <boost/regex.hpp> 15 #pragma clang diagnostic pop 74 boost::sregex_iterator
m_it;
82 static const boost::sregex_iterator endmark;
83 if ( m_it != endmark ) {
85 m_attrib =
Attrib{( *m_it )[1], ( *m_it )[2]};
86 if ( m_expandVars && m_attrib.
value.
find(
"${" ) != std::string::npos ) {
87 static const boost::regex varexp{
"\\$\\{([^}]+)\\}"};
91 m_attrib.
value = boost::regex_replace( m_attrib.
value, varexp,
93 const std::string name = m[1];
94 const char* cname = name.c_str();
95 if ( System::isEnvSet( cname ) ) {
97 return System::getEnv( cname );
101 boost::match_default | boost::format_all );
122 boost::sregex_iterator
parse()
const 124 static const boost::regex exp{
"[[:space:]]*([^[:space:]]+)[[:space:]]*=[[:space:]]*'(.*?)'"};
125 return boost::sregex_iterator(
begin( m_data ),
end( m_data ), exp );
Parse attribute strings allowing iteration over the various attributes.
AttribStringParser::Iterator end(const AttribStringParser &)
friend Iterator begin(const AttribStringParser &)
Iterator to loop over the tag/value pairs in the attribute string.
Iterator(Iterator &&other)
bool operator!=(const Iterator &other)
Iterator(const Iterator &other)
Iterator(const boost::sregex_iterator &it, bool expand_vars)
boost::sregex_iterator m_it
Wrapped boost::sregex_iterator instance.
Simple class to wrap tag/value pairs.
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Attrib m_attrib
Cached Attrib instance.
AttribStringParser(std::string data, bool expand_vars=true)
Initialize the parsing of an attribute string.
boost::sregex_iterator parse() const
Helper functions to set/get the application return code.
TO * reference(FROM *from)
bool operator==(const Iterator &other)
void i_setAttrib()
Helper method used to update the cached Attrib instance when dereferencing the iterator.