The Gaudi Framework  master (594c33fa)
Gaudi::Utils::AttribStringParser Class Reference

Parse attribute strings allowing iteration over the various attributes. More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/AttribStringParser.h>

Collaboration diagram for Gaudi::Utils::AttribStringParser:

Classes

struct  Attrib
 Simple class to wrap tag/value pairs. More...
 
class  Iterator
 Iterator to loop over the tag/value pairs in the attribute string. More...
 

Public Member Functions

 AttribStringParser (std::string data, bool expand_vars=true)
 Initialize the parsing of an attribute string. More...
 

Private Member Functions

boost::sregex_iterator parse () const
 

Private Attributes

std::string m_data
 
bool m_expandVars
 

Friends

Iterator begin (const AttribStringParser &)
 

Detailed Description

Parse attribute strings allowing iteration over the various attributes.

Example of usage:

std::string input{"key1='value1' key2='value2'"};
for(auto attrib: Parser(input)) {
std::cout << attrib.tag << " -> " << attrib.value << std::endl;
}

Definition at line 40 of file AttribStringParser.h.

Constructor & Destructor Documentation

◆ AttribStringParser()

Gaudi::Utils::AttribStringParser::AttribStringParser ( std::string  data,
bool  expand_vars = true 
)
inline

Initialize the parsing of an attribute string.

Parameters
dataattribute string
expand_varsif true (default) expand environment variables in values

Definition at line 124 of file AttribStringParser.h.

124 : m_data( data ), m_expandVars( expand_vars ) {}

Member Function Documentation

◆ parse()

boost::sregex_iterator Gaudi::Utils::AttribStringParser::parse ( ) const
inlineprivate

Definition at line 130 of file AttribStringParser.h.

130  {
131  static const boost::regex exp{ "[[:space:]]*([^[:space:]]+)[[:space:]]*=[[:space:]]*'(.*?)'" };
132  return boost::sregex_iterator( begin( m_data ), end( m_data ), exp );
133  }

Friends And Related Function Documentation

◆ begin

Iterator begin ( const AttribStringParser parser)
friend

Definition at line 136 of file AttribStringParser.h.

136  {
137  return AttribStringParser::Iterator( parser.parse(), parser.m_expandVars );
138  }

Member Data Documentation

◆ m_data

std::string Gaudi::Utils::AttribStringParser::m_data
private

Definition at line 127 of file AttribStringParser.h.

◆ m_expandVars

bool Gaudi::Utils::AttribStringParser::m_expandVars
private

Definition at line 128 of file AttribStringParser.h.


The documentation for this class was generated from the following file:
Gaudi::Utils::AttribStringParser::begin
friend Iterator begin(const AttribStringParser &)
Definition: AttribStringParser.h:136
std::string
STL class.
std::cout
Gaudi::Utils::end
AttribStringParser::Iterator end(const AttribStringParser &)
Definition: AttribStringParser.h:139
Gaudi::Utils::AttribStringParser::m_data
std::string m_data
Definition: AttribStringParser.h:127
std::endl
T endl(T... args)
std::exp
T exp(T... args)
Gaudi::Utils::AttribStringParser::m_expandVars
bool m_expandVars
Definition: AttribStringParser.h:128
gaudirun.parser
parser
Definition: gaudirun.py:149
Gaudi::Utils::AttribStringParser
Parse attribute strings allowing iteration over the various attributes.
Definition: AttribStringParser.h:40
Iterator
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:28