The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
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 ) {}
const Position & position() const

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

21{ 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 19 of file PropertyValue.cpp.

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

◆ IsVector()

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

Definition at line 20 of file PropertyValue.cpp.

20{ 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 36 of file PropertyValue.cpp.

36 {
37 return PropertyValue{ *this } += right;
38}
PropertyValue(Value value, bool is_reference=false)

◆ operator+=()

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

Definition at line 22 of file PropertyValue.cpp.

22 {
23
25 std::visit(
27 []( std::string&, const auto& ) { throw PropertyValueException::WrongLValue(); },
28 []( VectorOfStrings& lhs, const std::string& rhs ) { lhs.push_back( rhs ); },
29 []( VectorOfStrings& lhs, const VectorOfStrings& rhs ) { lhs.insert( lhs.end(), rhs.begin(), rhs.end() ); },
30 []( MapOfStrings& lhs, const MapOfStrings& rhs ) { lhs.insert( rhs.begin(), rhs.end() ); },
31 []( auto&, const auto& ) { throw PropertyValueException::WrongRValue(); } ),
32 value_, right.value_ );
33 return *this;
34}
static PropertyValueException WrongRValue()
static PropertyValueException WrongLValue()
std::vector< std::string > VectorOfStrings
std::map< std::string, std::string, std::less<> > MapOfStrings
auto overload(lambda_ts &&... lambdas)
Definition compose.h:37

◆ operator-()

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

Definition at line 57 of file PropertyValue.cpp.

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

◆ operator-=()

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

Definition at line 40 of file PropertyValue.cpp.

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

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

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

◆ 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: