| The Gaudi Framework v32r1 (f65d50dc)

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 30 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

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

Definition at line 108 of file AttribStringParser.h.

108 : m_data( data ), m_expandVars( expand_vars ) {}
Gaudi::Utils::AttribStringParser::m_expandVars
bool m_expandVars
Definition: AttribStringParser.h:112
Gaudi::Utils::AttribStringParser::m_data
std::string m_data
Definition: AttribStringParser.h:111

## Member Function Documentation

## ◆ parse()

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

Definition at line 114 of file AttribStringParser.h.

114 {
115 static const boost::regex exp{"[[:space:]]*([^[:space:]]+)[[:space:]]*=[[:space:]]*'(.*?)'"};
116 return boost::sregex_iterator( begin( m_data ), end( m_data ), exp );
117 }
Gaudi::Utils::end
AttribStringParser::Iterator end(const AttribStringParser &)
Definition: AttribStringParser.h:123
std::exp
T exp(T... args)
Gaudi::Utils::AttribStringParser::begin
friend Iterator begin(const AttribStringParser &)
Definition: AttribStringParser.h:120
Gaudi::Utils::AttribStringParser::m_data
std::string m_data
Definition: AttribStringParser.h:111

## Friends And Related Function Documentation

## ◆ begin

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

Definition at line 120 of file AttribStringParser.h.

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

## Member Data Documentation

## ◆ m_data

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

Definition at line 111 of file AttribStringParser.h.

## ◆ m_expandVars

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

Definition at line 112 of file AttribStringParser.h.

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

- GaudiKernel/GaudiKernel/AttribStringParser.h