The Gaudi Framework  v32r2 (46d42edc)
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 19 of file PropertyValue.h.

Member Typedef Documentation

◆ MapOfStrings

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

Definition at line 24 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 22 of file PropertyValue.h.

◆ VectorOfStrings

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

Definition at line 23 of file PropertyValue.h.

Constructor & Destructor Documentation

◆ PropertyValue() [1/2]

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

Definition at line 27 of file PropertyValue.h.

28  : 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 29 of file PropertyValue.h.

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

Member Function Documentation

◆ HasPosition()

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

Definition at line 44 of file PropertyValue.h.

44 { return position_.Exists(); }
bool Exists() const
Definition: Position.h:23

◆ IsMap()

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

Definition at line 21 of file PropertyValue.cpp.

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

◆ IsReference()

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

Definition at line 48 of file PropertyValue.h.

◆ IsSimple()

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

Definition at line 17 of file PropertyValue.cpp.

17 { 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<std::vector<std::string>>( value_ ); }

◆ Map() [1/2]

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

Definition at line 40 of file PropertyValue.h.

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

◆ Map() [2/2]

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

Definition at line 41 of file PropertyValue.h.

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

◆ operator+()

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

Definition at line 40 of file PropertyValue.cpp.

40  {
41  return PropertyValue{*this} += right;
42 }
PropertyValue(Value value, bool is_reference=false)
Definition: PropertyValue.h:27
T right(T... args)

◆ operator+=()

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

Definition at line 23 of file PropertyValue.cpp.

23  {
24 
26  std::visit(
27  Gaudi::overload( []( std::string&, const auto& ) { throw PropertyValueException::WrongLValue(); },
28  []( std::vector<std::string>& lhs, const std::string& rhs ) { lhs.push_back( rhs ); },
29  []( std::vector<std::string>& lhs, const std::vector<std::string>& rhs ) {
30  lhs.insert( lhs.end(), rhs.begin(), rhs.end() );
31  },
33  lhs.insert( rhs.begin(), rhs.end() );
34  },
35  []( auto&, const auto& ) { throw PropertyValueException::WrongRValue(); } ),
36  value_, right.value_ );
37  return *this;
38 }
T right(T... args)
T end(T... args)
STL class.
T push_back(T... args)
static PropertyValueException WrongRValue()
Definition: PropertyValue.h:72
T insert(T... args)
T begin(T... args)
auto overload(lambda_ts &&... lambdas)
Definition: compose.h:28
static PropertyValueException WrongLValue()
Definition: PropertyValue.h:68

◆ operator-()

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

Definition at line 62 of file PropertyValue.cpp.

62  {
63  return PropertyValue{*this} -= right;
64 }
PropertyValue(Value value, bool is_reference=false)
Definition: PropertyValue.h:27
T right(T... args)

◆ operator-=()

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

Definition at line 44 of file PropertyValue.cpp.

44  {
46  std::visit(
48  const std::string& rhs ) { lhs.erase( std::find( lhs.begin(), lhs.end(), rhs ) ); },
49  []( std::vector<std::string>& lhs, const std::vector<std::string>& rhs ) {
50  for ( const auto& item : rhs ) lhs.erase( std::find( lhs.begin(), lhs.end(), item ) );
51  },
52  []( std::map<std::string, std::string>& lhs, const std::string& rhs ) { lhs.erase( rhs ); },
54  for ( const auto& item : rhs ) lhs.erase( item );
55  },
56  []( std::string&, const auto& ) { throw PropertyValueException::WrongLValue(); },
57  []( auto&, const auto& ) { throw PropertyValueException::WrongRValue(); } ),
58  value_, right.value_ );
59  return *this;
60 }
T right(T... args)
T end(T... args)
STL class.
static PropertyValueException WrongRValue()
Definition: PropertyValue.h:72
T erase(T... args)
T find(T... args)
T begin(T... args)
auto overload(lambda_ts &&... lambdas)
Definition: compose.h:28
static PropertyValueException WrongLValue()
Definition: PropertyValue.h:68

◆ position()

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

Definition at line 32 of file PropertyValue.h.

32 { return position_; }

◆ String() [1/2]

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

Definition at line 34 of file PropertyValue.h.

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

◆ String() [2/2]

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

Definition at line 35 of file PropertyValue.h.

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

◆ ToString()

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

Definition at line 66 of file PropertyValue.cpp.

66  {
67  if ( IsReference() ) {
68  const auto& value = std::get<std::vector<std::string>>( value_ );
69  if ( value.at( 0 ) != "" ) {
70  return "@" + value.at( 0 ) + "." + value.at( 1 );
71  } else {
72  return "@" + value.at( 0 );
73  }
74  }
75  return std::visit( Gaudi::overload( []( const std::string& v ) { return v; },
76  []( const std::vector<std::string>& v ) {
77  return '[' + boost::algorithm::join( v, ", " ) + ']';
78  },
79  []( const std::map<std::string, std::string>& v ) {
80  std::string result = "{";
81  std::string delim = "";
82  for ( const auto& in : v ) {
83  result += delim + in.first + ":" + in.second;
84  delim = ", ";
85  }
86  return result + "}";
87  } ),
88  value_ );
89 }
STL class.
auto overload(lambda_ts &&... lambdas)
Definition: compose.h:28

◆ Vector() [1/2]

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

Definition at line 37 of file PropertyValue.h.

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

◆ Vector() [2/2]

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

Definition at line 38 of file PropertyValue.h.

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

Member Data Documentation

◆ is_reference_

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

Definition at line 61 of file PropertyValue.h.

◆ position_

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

Definition at line 60 of file PropertyValue.h.

◆ value_

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

Definition at line 59 of file PropertyValue.h.


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