The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
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>

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

Public Types

using iterator_category = std::input_iterator_tag
using value_type = Attrib
using difference_type = std::ptrdiff_t
using pointer = value_type*
using reference = value_type&

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.

Private Attributes

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

Detailed Description

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

Definition at line 49 of file AttribStringParser.h.

Member Typedef Documentation

◆ difference_type

using Gaudi::Utils::AttribStringParser::Iterator::difference_type = std::ptrdiff_t

Definition at line 53 of file AttribStringParser.h.

◆ iterator_category

using Gaudi::Utils::AttribStringParser::Iterator::iterator_category = std::input_iterator_tag

Definition at line 51 of file AttribStringParser.h.

◆ pointer

using Gaudi::Utils::AttribStringParser::Iterator::pointer = value_type*

Definition at line 54 of file AttribStringParser.h.

◆ reference

using Gaudi::Utils::AttribStringParser::Iterator::reference = value_type&

Definition at line 55 of file AttribStringParser.h.

◆ value_type

using Gaudi::Utils::AttribStringParser::Iterator::value_type = Attrib

Definition at line 52 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 58 of file AttribStringParser.h.

58 : m_it( it ), m_expandVars( expand_vars ) {
59 // i_setAttrib();
60 }
boost::sregex_iterator m_it
Wrapped boost::sregex_iterator instance.

◆ Iterator() [3/4]

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

Definition at line 61 of file AttribStringParser.h.

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

◆ Iterator() [4/4]

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

Definition at line 62 of file AttribStringParser.h.

62: 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 87 of file AttribStringParser.h.

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

◆ operator!=()

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

Definition at line 77 of file AttribStringParser.h.

77{ return m_it != other.m_it; }

◆ operator*()

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

Definition at line 72 of file AttribStringParser.h.

72 {
74 return m_attrib;
75 }
void i_setAttrib()
Helper method used to update the cached Attrib instance when dereferencing the iterator.

◆ operator++() [1/2]

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

Definition at line 67 of file AttribStringParser.h.

67 {
68 auto old = *this;
69 ++m_it;
70 return old;
71 }

◆ operator++() [2/2]

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

Definition at line 63 of file AttribStringParser.h.

63 {
64 ++m_it;
65 return *this;
66 }

◆ operator==()

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

Definition at line 76 of file AttribStringParser.h.

76{ 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 84 of file AttribStringParser.h.

◆ m_expandVars

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

Definition at line 82 of file AttribStringParser.h.

◆ m_it

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

Wrapped boost::sregex_iterator instance.

Definition at line 81 of file AttribStringParser.h.


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