| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Gaudi::Utils::AttribStringParser Class Reference

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

`#include <GaudiKernel/AttribStringParser.h>`

Collaboration diagram for Gaudi::Utils::AttribStringParser:
[legend]

## 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:

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

Definition at line 32 of file AttribStringParser.h.

## Constructor & Destructor Documentation

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

Initialize the parsing of an attribute string.

Parameters

  data | attribute string
  expand_vars | if true (default) expand environment variables in values

Definition at line 116 of file AttribStringParser.h.

116 : m_data( data ), m_expandVars( expand_vars ) {}
Gaudi::Utils::AttribStringParser::m_expandVars
bool m_expandVars
Definition: AttribStringParser.h:120
Gaudi::Utils::AttribStringParser::m_data
std::string m_data
Definition: AttribStringParser.h:119

## Member Function Documentation

boost::sregex_iterator Gaudi::Utils::AttribStringParser::parse | ( |  | ) | const
| inline private

Definition at line 122 of file AttribStringParser.h.

123 {
124 static const boost::regex exp{"[[:space:]]*([^[:space:]]+)[[:space:]]*=[[:space:]]*'(.*?)'"};
125 return boost::sregex_iterator( begin( m_data ), end( m_data ), exp );
126 }
Gaudi::Utils::end
AttribStringParser::Iterator end(const AttribStringParser &)
Definition: AttribStringParser.h:133
std::exp
T exp(T...args)
Gaudi::Utils::AttribStringParser::begin
friend Iterator begin(const AttribStringParser &)
Definition: AttribStringParser.h:129
Gaudi::Utils::AttribStringParser::m_data
std::string m_data
Definition: AttribStringParser.h:119

## Friends And Related Function Documentation

Iterator begin | ( | const AttribStringParser & | parser | ) |
| friend

Definition at line 129 of file AttribStringParser.h.

130 {
131 return AttribStringParser::Iterator( parser.parse(), parser.m_expandVars );
132 }
gaudirun.parser
parser
Definition: gaudirun.py:130
Iterator
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:18

## Member Data Documentation

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

Definition at line 119 of file AttribStringParser.h.

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

Definition at line 120 of file AttribStringParser.h.

The documentation for this class was generated from the following file:

- GaudiKernel/GaudiKernel/AttribStringParser.h