The Gaudi Framework  master (37c0b60a)
Gaudi::Parsers::PropertyValue Class Referencefinal

#include </builds/gaudi/Gaudi/GaudiCoreSvc/src/JobOptionsSvc/PropertyValue.h>

Collaboration diagram for Gaudi::Parsers::PropertyValue:

Public Types

using VectorOfStrings = std::vector< std::string >
 
using MapOfStrings = std::map< std::string, std::string, std::less<> >
 
using Value = std::variant< std::string, VectorOfStrings, MapOfStrings >
 

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

◆ Value

◆ VectorOfStrings

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 ) {}

◆ 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 ) {}

Member Function Documentation

◆ HasPosition()

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

Definition at line 54 of file PropertyValue.h.

54 { return position_.Exists(); }

◆ IsMap()

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

Definition at line 31 of file PropertyValue.cpp.

31 { return std::holds_alternative<MapOfStrings>( value_ ); }

◆ IsReference()

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

Definition at line 58 of file PropertyValue.h.

58 { return is_reference_; };

◆ 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<VectorOfStrings>( 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 47 of file PropertyValue.cpp.

47  {
48  return PropertyValue{ *this } += right;
49 }

◆ operator+=()

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

Definition at line 33 of file PropertyValue.cpp.

33  {
34 
36  std::visit(
38  []( std::string&, const auto& ) { throw PropertyValueException::WrongLValue(); },
39  []( VectorOfStrings& lhs, const std::string& rhs ) { lhs.push_back( rhs ); },
40  []( VectorOfStrings& lhs, const VectorOfStrings& rhs ) { lhs.insert( lhs.end(), rhs.begin(), rhs.end() ); },
41  []( MapOfStrings& lhs, const MapOfStrings& rhs ) { lhs.insert( rhs.begin(), rhs.end() ); },
42  []( auto&, const auto& ) { throw PropertyValueException::WrongRValue(); } ),
43  value_, right.value_ );
44  return *this;
45 }

◆ operator-()

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

Definition at line 69 of file PropertyValue.cpp.

69  {
70  return PropertyValue{ *this } -= right;
71 }

◆ operator-=()

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

Definition at line 51 of file PropertyValue.cpp.

51  {
53  std::visit(
55  const std::string& rhs ) { lhs.erase( std::find( lhs.begin(), lhs.end(), rhs ) ); },
56  []( std::vector<std::string>& lhs, const std::vector<std::string>& rhs ) {
57  for ( const auto& item : rhs ) lhs.erase( std::find( lhs.begin(), lhs.end(), item ) );
58  },
59  []( std::map<std::string, std::string>& lhs, const std::string& rhs ) { lhs.erase( rhs ); },
61  for ( const auto& item : rhs ) lhs.erase( item );
62  },
63  []( std::string&, const auto& ) { throw PropertyValueException::WrongLValue(); },
64  []( auto&, const auto& ) { throw PropertyValueException::WrongRValue(); } ),
65  value_, right.value_ );
66  return *this;
67 }

◆ 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 73 of file PropertyValue.cpp.

73  {
74  if ( IsReference() ) {
75  const auto& value = std::get<VectorOfStrings>( value_ );
76  if ( value.at( 0 ) != "" ) {
77  return "@" + value.at( 0 ) + "." + value.at( 1 );
78  } else {
79  return "@" + value.at( 0 );
80  }
81  }
82  return std::visit(
83  Gaudi::overload( []( const std::string& v ) { return v; },
84  []( const VectorOfStrings& v ) { return '[' + boost::algorithm::join( v, ", " ) + ']'; },
85  []( const MapOfStrings& v ) {
86  std::string result = "{";
87  std::string delim = "";
88  for ( const auto& in : v ) {
89  result += delim + in.first + ":" + in.second;
90  delim = ", ";
91  }
92  return result + "}";
93  } ),
94  value_ );
95 }

◆ 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:
std::string
STL class.
std::move
T move(T... args)
std::vector< std::string >
std::find
T find(T... args)
Gaudi::Parsers::Position::Exists
bool Exists() const
Definition: Position.h:33
Gaudi::Parsers::PropertyValue::VectorOfStrings
std::vector< std::string > VectorOfStrings
Definition: PropertyValue.h:32
Gaudi::Parsers::PropertyValueException::WrongRValue
static PropertyValueException WrongRValue()
Definition: PropertyValue.h:82
Gaudi::Parsers::PropertyValue::value_
Value value_
Definition: PropertyValue.h:69
Gaudi::Parsers::PropertyValue::MapOfStrings
std::map< std::string, std::string, std::less<> > MapOfStrings
Definition: PropertyValue.h:33
Gaudi::Parsers::PropertyValue::position_
Position position_
Definition: PropertyValue.h:70
std::vector::erase
T erase(T... args)
std::map< std::string, std::string >
Gaudi::Parsers::PropertyValue::IsReference
bool IsReference() const
Definition: PropertyValue.h:58
std::right
T right(T... args)
Gaudi::Parsers::PropertyValue::position
const Position & position() const
Definition: PropertyValue.h:42
std::vector::begin
T begin(T... args)
Gaudi::Parsers::PropertyValueException::WrongLValue
static PropertyValueException WrongLValue()
Definition: PropertyValue.h:78
Properties.v
v
Definition: Properties.py:122
std::vector::end
T end(T... args)
Gaudi::Parsers::PropertyValue::is_reference_
bool is_reference_
Definition: PropertyValue.h:71
Gaudi::overload
auto overload(lambda_ts &&... lambdas)
Definition: compose.h:38
Gaudi::Parsers::PropertyValue::PropertyValue
PropertyValue(Value value, bool is_reference=false)
Definition: PropertyValue.h:37