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 66 boost::sregex_iterator
m_it;
73 static const boost::sregex_iterator endmark;
74 if ( m_it != endmark ) {
76 m_attrib =
Attrib{( *m_it )[1], ( *m_it )[2]};
77 if ( m_expandVars && m_attrib.
value.
find(
"${" ) != std::string::npos ) {
78 static const boost::regex varexp{
"\\$\\{([^}]+)\\}"};
82 m_attrib.
value = boost::regex_replace( m_attrib.
value, varexp,
84 const std::string name = m[1];
85 const char* cname = name.c_str();
86 if ( System::isEnvSet( cname ) ) {
88 return System::getEnv( cname );
92 boost::match_default | boost::format_all );
113 boost::sregex_iterator
parse()
const {
114 static const boost::regex exp{
"[[:space:]]*([^[:space:]]+)[[:space:]]*=[[:space:]]*'(.*?)'"};
115 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.
bool operator==(const Iterator &other)
void i_setAttrib()
Helper method used to update the cached Attrib instance when dereferencing the iterator.