The Gaudi Framework  v33r0 (d5ea422b)
Gaudi::Parsers::PropertyValue Class Referencefinal

#include <src/JobOptionsSvc/PropertyValue.h>

Collaboration diagram for Gaudi::Parsers::PropertyValue:

Public Types

typedef std::variant< std::string, std::vector< std::string >, std::map< std::string, std::string > > Value
 
typedef std::vector< std::stringVectorOfStrings
 
typedef std::map< std::string, std::stringMapOfStrings
 

Public Member Functions

 PropertyValue (Value value, bool is_reference=false)
 
 PropertyValue (Value value, const Position &position, bool is_reference=false)
 
const Positionposition () const
 
std::stringString ()
 
const std::stringString () const
 
VectorOfStringsVector ()
 
const VectorOfStringsVector () const
 
MapOfStringsMap ()
 
const MapOfStringsMap () const
 
std::string ToString () const
 
bool HasPosition () const
 
bool IsSimple () const
 
bool IsVector () const
 
bool IsMap () const
 
bool IsReference () const
 
PropertyValueoperator+= (const PropertyValue &right)
 
const PropertyValue operator+ (const PropertyValue &right)
 
PropertyValueoperator-= (const PropertyValue &right)
 
const PropertyValue operator- (const PropertyValue &right)
 

Private Attributes

Value value_
 
Position position_
 
bool is_reference_
 

Detailed Description

Definition at line 29 of file PropertyValue.h.

Member Typedef Documentation

◆ MapOfStrings

typedef std::map<std::string, std::string> Gaudi::Parsers::PropertyValue::MapOfStrings

Definition at line 34 of file PropertyValue.h.

◆ Value

typedef std::variant<std::string, std::vector<std::string>, std::map<std::string, std::string> > Gaudi::Parsers::PropertyValue::Value

Definition at line 32 of file PropertyValue.h.

◆ VectorOfStrings

typedef std::vector<std::string> Gaudi::Parsers::PropertyValue::VectorOfStrings

Definition at line 33 of file PropertyValue.h.

Constructor & Destructor Documentation

◆ PropertyValue() [1/2]

Gaudi::Parsers::PropertyValue::PropertyValue ( Value  value,
bool  is_reference = false 
)
inlineexplicit

Definition at line 37 of file PropertyValue.h.

38  : value_( std::move( value ) ), is_reference_( is_reference ) {}
T move(T... args)

◆ PropertyValue() [2/2]

Gaudi::Parsers::PropertyValue::PropertyValue ( Value  value,
const Position position,
bool  is_reference = false 
)
inline

Definition at line 39 of file PropertyValue.h.

40  : value_( std::move( value ) ), position_( position ), is_reference_( is_reference ) {}
T move(T... args)
const Position & position() const
Definition: PropertyValue.h:42

Member Function Documentation

◆ HasPosition()

bool Gaudi::Parsers::PropertyValue::HasPosition ( ) const
inline

Definition at line 54 of file PropertyValue.h.

54 { return position_.Exists(); }
bool Exists() const
Definition: Position.h:33

◆ IsMap()

bool Gaudi::Parsers::PropertyValue::IsMap ( ) const

Definition at line 31 of file PropertyValue.cpp.

31 { return std::holds_alternative<std::map<std::string, std::string>>( value_ ); }

◆ IsReference()

bool Gaudi::Parsers::PropertyValue::IsReference ( ) const
inline

Definition at line 58 of file PropertyValue.h.

◆ IsSimple()

bool Gaudi::Parsers::PropertyValue::IsSimple ( ) const

Definition at line 27 of file PropertyValue.cpp.

27 { return std::holds_alternative<std::string>( value_ ); }

◆ IsVector()

bool Gaudi::Parsers::PropertyValue::IsVector ( ) const

Definition at line 29 of file PropertyValue.cpp.

29 { return std::holds_alternative<std::vector<std::string>>( value_ ); }

◆ Map() [1/2]

MapOfStrings& Gaudi::Parsers::PropertyValue::Map ( )
inline

Definition at line 50 of file PropertyValue.h.

50 { return std::get<MapOfStrings>( value_ ); }

◆ Map() [2/2]

const MapOfStrings& Gaudi::Parsers::PropertyValue::Map ( ) const
inline

Definition at line 51 of file PropertyValue.h.

51 { return std::get<MapOfStrings>( value_ ); }

◆ operator+()

const gp::PropertyValue Gaudi::Parsers::PropertyValue::operator+ ( const PropertyValue right)

Definition at line 50 of file PropertyValue.cpp.

50  {
51  return PropertyValue{*this} += right;
52 }
PropertyValue(Value value, bool is_reference=false)
Definition: PropertyValue.h:37
T right(T... args)

◆ operator+=()

gp::PropertyValue & Gaudi::Parsers::PropertyValue::operator+= ( const PropertyValue right)

Definition at line 33 of file PropertyValue.cpp.

33  {
34 
36  std::visit(
37  Gaudi::overload( []( std::string&, const auto& ) { throw PropertyValueException::WrongLValue(); },
38  []( std::vector<std::string>& lhs, const std::string& rhs ) { lhs.push_back( rhs ); },
39  []( std::vector<std::string>& lhs, const std::vector<std::string>& rhs ) {
40  lhs.insert( lhs.end(), rhs.begin(), rhs.end() );
41  },
43  lhs.insert( rhs.begin(), rhs.end() );
44  },
45  []( auto&, const auto& ) { throw PropertyValueException::WrongRValue(); } ),
46  value_, right.value_ );
47  return *this;
48 }
T right(T... args)
T end(T... args)
STL class.
T push_back(T... args)
static PropertyValueException WrongRValue()
Definition: PropertyValue.h:82
T insert(T... args)
T begin(T... args)
auto overload(lambda_ts &&... lambdas)
Definition: compose.h:38
static PropertyValueException WrongLValue()
Definition: PropertyValue.h:78

◆ operator-()

const gp::PropertyValue Gaudi::Parsers::PropertyValue::operator- ( const PropertyValue right)

Definition at line 72 of file PropertyValue.cpp.

72  {
73  return PropertyValue{*this} -= right;
74 }
PropertyValue(Value value, bool is_reference=false)
Definition: PropertyValue.h:37
T right(T... args)

◆ operator-=()

gp::PropertyValue & Gaudi::Parsers::PropertyValue::operator-= ( const PropertyValue right)

Definition at line 54 of file PropertyValue.cpp.

54  {
56  std::visit(
58  const std::string& rhs ) { lhs.erase( std::find( lhs.begin(), lhs.end(), rhs ) ); },
59  []( std::vector<std::string>& lhs, const std::vector<std::string>& rhs ) {
60  for ( const auto& item : rhs ) lhs.erase( std::find( lhs.begin(), lhs.end(), item ) );
61  },
62  []( std::map<std::string, std::string>& lhs, const std::string& rhs ) { lhs.erase( rhs ); },
64  for ( const auto& item : rhs ) lhs.erase( item );
65  },
66  []( std::string&, const auto& ) { throw PropertyValueException::WrongLValue(); },
67  []( auto&, const auto& ) { throw PropertyValueException::WrongRValue(); } ),
68  value_, right.value_ );
69  return *this;
70 }
T right(T... args)
T end(T... args)
STL class.
static PropertyValueException WrongRValue()
Definition: PropertyValue.h:82
T erase(T... args)
T find(T... args)
T begin(T... args)
auto overload(lambda_ts &&... lambdas)
Definition: compose.h:38
static PropertyValueException WrongLValue()
Definition: PropertyValue.h:78

◆ position()

const Position& Gaudi::Parsers::PropertyValue::position ( ) const
inline

Definition at line 42 of file PropertyValue.h.

42 { return position_; }

◆ String() [1/2]

std::string& Gaudi::Parsers::PropertyValue::String ( )
inline

Definition at line 44 of file PropertyValue.h.

44 { return std::get<std::string>( value_ ); }

◆ String() [2/2]

const std::string& Gaudi::Parsers::PropertyValue::String ( ) const
inline

Definition at line 45 of file PropertyValue.h.

45 { return std::get<std::string>( value_ ); }

◆ ToString()

std::string Gaudi::Parsers::PropertyValue::ToString ( ) const

Definition at line 76 of file PropertyValue.cpp.

76  {
77  if ( IsReference() ) {
78  const auto& value = std::get<std::vector<std::string>>( value_ );
79  if ( value.at( 0 ) != "" ) {
80  return "@" + value.at( 0 ) + "." + value.at( 1 );
81  } else {
82  return "@" + value.at( 0 );
83  }
84  }
85  return std::visit( Gaudi::overload( []( const std::string& v ) { return v; },
86  []( const std::vector<std::string>& v ) {
87  return '[' + boost::algorithm::join( v, ", " ) + ']';
88  },
89  []( const std::map<std::string, std::string>& v ) {
90  std::string result = "{";
91  std::string delim = "";
92  for ( const auto& in : v ) {
93  result += delim + in.first + ":" + in.second;
94  delim = ", ";
95  }
96  return result + "}";
97  } ),
98  value_ );
99 }
STL class.
auto overload(lambda_ts &&... lambdas)
Definition: compose.h:38

◆ Vector() [1/2]

VectorOfStrings& Gaudi::Parsers::PropertyValue::Vector ( )
inline

Definition at line 47 of file PropertyValue.h.

47 { return std::get<VectorOfStrings>( value_ ); }

◆ Vector() [2/2]

const VectorOfStrings& Gaudi::Parsers::PropertyValue::Vector ( ) const
inline

Definition at line 48 of file PropertyValue.h.

48 { return std::get<VectorOfStrings>( value_ ); }

Member Data Documentation

◆ is_reference_

bool Gaudi::Parsers::PropertyValue::is_reference_
private

Definition at line 71 of file PropertyValue.h.

◆ position_

Position Gaudi::Parsers::PropertyValue::position_
private

Definition at line 70 of file PropertyValue.h.

◆ value_

Value Gaudi::Parsers::PropertyValue::value_
private

Definition at line 69 of file PropertyValue.h.


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