The Gaudi Framework  v36r6 (b1ee9983)
Gaudi::Utils::AttribStringParser::Iterator Class Reference

Iterator to loop over the tag/value pairs in the attribute string. More...

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

Inheritance diagram for Gaudi::Utils::AttribStringParser::Iterator:
Collaboration diagram for Gaudi::Utils::AttribStringParser::Iterator:

Public Member Functions

 Iterator ()=default
 
 Iterator (const boost::sregex_iterator &it, bool expand_vars)
 
 Iterator (const Iterator &other)
 
 Iterator (Iterator &&other)
 
Iterator operator++ (int)
 
Iterator operator++ ()
 
reference operator* ()
 
bool operator== (const Iterator &other)
 
bool operator!= (const Iterator &other)
 

Private Member Functions

void i_setAttrib ()
 Helper method used to update the cached Attrib instance when dereferencing the iterator. More...
 

Private Attributes

boost::sregex_iterator m_it
 Wrapped boost::sregex_iterator instance. More...
 
bool m_expandVars = false
 
Attrib m_attrib
 Cached Attrib instance. More...
 

Detailed Description

Iterator to loop over the tag/value pairs in the attribute string.

Definition at line 50 of file AttribStringParser.h.

Constructor & Destructor Documentation

◆ Iterator() [1/4]

Gaudi::Utils::AttribStringParser::Iterator::Iterator ( )
default

◆ Iterator() [2/4]

Gaudi::Utils::AttribStringParser::Iterator::Iterator ( const boost::sregex_iterator &  it,
bool  expand_vars 
)
inline

Definition at line 53 of file AttribStringParser.h.

53  : m_it( it ), m_expandVars( expand_vars ) {
54  // i_setAttrib();
55  }

◆ Iterator() [3/4]

Gaudi::Utils::AttribStringParser::Iterator::Iterator ( const Iterator &  other)
inline

Definition at line 56 of file AttribStringParser.h.

56 : Iterator( other.m_it, other.m_expandVars ) {}

◆ Iterator() [4/4]

Gaudi::Utils::AttribStringParser::Iterator::Iterator ( Iterator &&  other)
inline

Definition at line 57 of file AttribStringParser.h.

57 : m_it( std::move( other.m_it ) ), m_expandVars( other.m_expandVars ) {}

Member Function Documentation

◆ i_setAttrib()

void Gaudi::Utils::AttribStringParser::Iterator::i_setAttrib ( )
inlineprivate

Helper method used to update the cached Attrib instance when dereferencing the iterator.

Definition at line 82 of file AttribStringParser.h.

82  {
83  static const boost::sregex_iterator endmark;
84  if ( m_it != endmark ) {
85  // if we have a match, we cache the values
86  m_attrib = Attrib{ ( *m_it )[1], ( *m_it )[2] };
87  if ( m_expandVars && m_attrib.value.find( "${" ) != std::string::npos ) {
88  static const boost::regex varexp{ "\\$\\{([^}]+)\\}" };
89  auto i = 1;
90  while ( i ) {
91  i = 0;
92  m_attrib.value = boost::regex_replace(
93  m_attrib.value, varexp,
94  [&i]( const boost::smatch& m ) -> std::string {
95  const std::string name = m[1];
96  const char* cname = name.c_str();
97  if ( System::isEnvSet( cname ) ) {
98  ++i;
99  return System::getEnv( cname );
100  }
101  return m[0]; // do not expand unknown vars
102  },
103  boost::match_default | boost::format_all );
104  }
105  }
106  } else {
107  // otherwise we clean the cache
108  m_attrib = Attrib();
109  }
110  }

◆ operator!=()

Definition at line 72 of file AttribStringParser.h.

72 { return m_it != other.m_it; }

◆ operator*()

reference Gaudi::Utils::AttribStringParser::Iterator::operator* ( )
inline

Definition at line 67 of file AttribStringParser.h.

67  {
68  i_setAttrib();
69  return m_attrib;
70  }

◆ operator++() [1/2]

Iterator Gaudi::Utils::AttribStringParser::Iterator::operator++ ( )
inline

Definition at line 62 of file AttribStringParser.h.

62  {
63  auto old = *this;
64  ++m_it;
65  return old;
66  }

◆ operator++() [2/2]

Iterator Gaudi::Utils::AttribStringParser::Iterator::operator++ ( int  )
inline

Definition at line 58 of file AttribStringParser.h.

58  {
59  ++m_it;
60  return *this;
61  }

◆ operator==()

bool Gaudi::Utils::AttribStringParser::Iterator::operator== ( const Iterator &  other)
inline

Definition at line 71 of file AttribStringParser.h.

71 { return m_it == other.m_it; }

Member Data Documentation

◆ m_attrib

Attrib Gaudi::Utils::AttribStringParser::Iterator::m_attrib
private

Cached Attrib instance.

Definition at line 79 of file AttribStringParser.h.

◆ m_expandVars

bool Gaudi::Utils::AttribStringParser::Iterator::m_expandVars = false
private

Definition at line 77 of file AttribStringParser.h.

◆ m_it

boost::sregex_iterator Gaudi::Utils::AttribStringParser::Iterator::m_it
private

Wrapped boost::sregex_iterator instance.

Definition at line 76 of file AttribStringParser.h.


The documentation for this class was generated from the following file:
std::string
STL class.
std::move
T move(T... args)
std::string::find
T find(T... args)
Gaudi::Utils::AttribStringParser::Iterator::m_it
boost::sregex_iterator m_it
Wrapped boost::sregex_iterator instance.
Definition: AttribStringParser.h:76
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:108
Gaudi::Utils::AttribStringParser::Attrib::value
std::string value
Definition: AttribStringParser.h:45
Gaudi::Utils::AttribStringParser::Iterator::m_attrib
Attrib m_attrib
Cached Attrib instance.
Definition: AttribStringParser.h:79
Gaudi::Utils::AttribStringParser::Iterator::Iterator
Iterator()=default
Gaudi::Utils::AttribStringParser::Iterator::m_expandVars
bool m_expandVars
Definition: AttribStringParser.h:77
Gaudi::Utils::AttribStringParser::Iterator::i_setAttrib
void i_setAttrib()
Helper method used to update the cached Attrib instance when dereferencing the iterator.
Definition: AttribStringParser.h:82