The Gaudi Framework  master (d98a2936)
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::string & String ()
 
const std::string & String () 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 22 of file PropertyValue.h.

Member Typedef Documentation

◆ MapOfStrings

using Gaudi::Parsers::PropertyValue::MapOfStrings = std::map<std::string, std::string, std::less<> >

Definition at line 25 of file PropertyValue.h.

◆ Value

Definition at line 26 of file PropertyValue.h.

◆ VectorOfStrings

using Gaudi::Parsers::PropertyValue::VectorOfStrings = std::vector<std::string>

Definition at line 24 of file PropertyValue.h.

Constructor & Destructor Documentation

◆ PropertyValue() [1/2]

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

Definition at line 29 of file PropertyValue.h.

30  : 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 31 of file PropertyValue.h.

32  : value_( std::move( value ) ), position_( position ), is_reference_( is_reference ) {}

Member Function Documentation

◆ HasPosition()

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

Definition at line 46 of file PropertyValue.h.

46 { return position_.Exists(); }

◆ IsMap()

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

Definition at line 20 of file PropertyValue.cpp.

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

◆ IsReference()

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

Definition at line 50 of file PropertyValue.h.

50 { return is_reference_; };

◆ IsSimple()

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

Definition at line 18 of file PropertyValue.cpp.

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

◆ IsVector()

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

Definition at line 19 of file PropertyValue.cpp.

19 { return std::holds_alternative<VectorOfStrings>( value_ ); }

◆ Map() [1/2]

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

Definition at line 42 of file PropertyValue.h.

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

◆ Map() [2/2]

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

Definition at line 43 of file PropertyValue.h.

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

◆ operator+()

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

Definition at line 35 of file PropertyValue.cpp.

35  {
36  return PropertyValue{ *this } += right;
37 }

◆ operator+=()

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

Definition at line 21 of file PropertyValue.cpp.

21  {
22 
24  std::visit(
26  []( std::string&, const auto& ) { throw PropertyValueException::WrongLValue(); },
27  []( VectorOfStrings& lhs, const std::string& rhs ) { lhs.push_back( rhs ); },
28  []( VectorOfStrings& lhs, const VectorOfStrings& rhs ) { lhs.insert( lhs.end(), rhs.begin(), rhs.end() ); },
29  []( MapOfStrings& lhs, const MapOfStrings& rhs ) { lhs.insert( rhs.begin(), rhs.end() ); },
30  []( auto&, const auto& ) { throw PropertyValueException::WrongRValue(); } ),
31  value_, right.value_ );
32  return *this;
33 }

◆ operator-()

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

Definition at line 56 of file PropertyValue.cpp.

56  {
57  return PropertyValue{ *this } -= right;
58 }

◆ operator-=()

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

Definition at line 39 of file PropertyValue.cpp.

39  {
41  std::visit( Gaudi::overload( []( VectorOfStrings& lhs,
42  const std::string& rhs ) { lhs.erase( std::find( lhs.begin(), lhs.end(), rhs ) ); },
43  []( VectorOfStrings& lhs, const VectorOfStrings& rhs ) {
44  for ( const auto& item : rhs ) lhs.erase( std::find( lhs.begin(), lhs.end(), item ) );
45  },
46  []( MapOfStrings& lhs, const std::string& rhs ) { lhs.erase( rhs ); },
47  []( MapOfStrings& lhs, const VectorOfStrings& rhs ) {
48  for ( const auto& item : rhs ) lhs.erase( item );
49  },
50  []( std::string&, const auto& ) { throw PropertyValueException::WrongLValue(); },
51  []( auto&, const auto& ) { throw PropertyValueException::WrongRValue(); } ),
52  value_, right.value_ );
53  return *this;
54 }

◆ position()

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

Definition at line 34 of file PropertyValue.h.

34 { return position_; }

◆ String() [1/2]

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

Definition at line 36 of file PropertyValue.h.

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

◆ String() [2/2]

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

Definition at line 37 of file PropertyValue.h.

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

◆ ToString()

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

Definition at line 60 of file PropertyValue.cpp.

60  {
61  if ( IsReference() ) {
62  const auto& value = std::get<VectorOfStrings>( value_ );
63  if ( value.at( 0 ) != "" ) {
64  return "@" + value.at( 0 ) + "." + value.at( 1 );
65  } else {
66  return "@" + value.at( 0 );
67  }
68  }
69  return std::visit(
70  []( const auto& v ) {
71  // make sure to be consistent by explicitly re-using `GaudiUtils::operator<<`
72  using GaudiUtils::operator<<;
73  std::ostringstream s{};
74  s << v;
75  return s.str();
76  },
77  value_ );
78 }

◆ Vector() [1/2]

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

Definition at line 39 of file PropertyValue.h.

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

◆ Vector() [2/2]

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

Definition at line 40 of file PropertyValue.h.

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

Member Data Documentation

◆ is_reference_

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

Definition at line 60 of file PropertyValue.h.

◆ position_

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

Definition at line 59 of file PropertyValue.h.

◆ value_

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

Definition at line 58 of file PropertyValue.h.


The documentation for this class was generated from the following files:
gaudirun.s
string s
Definition: gaudirun.py:346
Gaudi::Parsers::Position::Exists
bool Exists() const
Definition: Position.h:27
Gaudi::Parsers::PropertyValue::VectorOfStrings
std::vector< std::string > VectorOfStrings
Definition: PropertyValue.h:24
Gaudi::Parsers::PropertyValueException::WrongRValue
static PropertyValueException WrongRValue()
Definition: PropertyValue.h:70
Gaudi::Parsers::PropertyValue::value_
Value value_
Definition: PropertyValue.h:58
Gaudi::Parsers::PropertyValue::MapOfStrings
std::map< std::string, std::string, std::less<> > MapOfStrings
Definition: PropertyValue.h:25
Gaudi::Parsers::PropertyValue::position_
Position position_
Definition: PropertyValue.h:59
Gaudi::Parsers::PropertyValue::IsReference
bool IsReference() const
Definition: PropertyValue.h:50
Gaudi::Parsers::PropertyValue::position
const Position & position() const
Definition: PropertyValue.h:34
Gaudi::Parsers::PropertyValueException::WrongLValue
static PropertyValueException WrongLValue()
Definition: PropertyValue.h:66
Properties.v
v
Definition: Properties.py:122
Gaudi::Parsers::PropertyValue::is_reference_
bool is_reference_
Definition: PropertyValue.h:60
Gaudi::overload
auto overload(lambda_ts &&... lambdas)
Definition: compose.h:37
Gaudi::Parsers::PropertyValue::PropertyValue
PropertyValue(Value value, bool is_reference=false)
Definition: PropertyValue.h:29