Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Gaudi::Parsers::PropertyValue Class Referencefinal

#include <src/JobOptionsSvc/PropertyValue.h>

Collaboration diagram for Gaudi::Parsers::PropertyValue:

Public Types

typedef boost::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 20 of file PropertyValue.h.

Member Typedef Documentation

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

Definition at line 25 of file PropertyValue.h.

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

Definition at line 23 of file PropertyValue.h.

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

Definition at line 24 of file PropertyValue.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file PropertyValue.h.

29  : value_( std::move( value ) ), is_reference_( is_reference ) {}
T move(T...args)
Gaudi::Parsers::PropertyValue::PropertyValue ( Value  value,
const Position position,
bool  is_reference = false 
)
inline

Definition at line 30 of file PropertyValue.h.

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

Member Function Documentation

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

Definition at line 45 of file PropertyValue.h.

45 { return position_.Exists(); }
bool Exists() const
Definition: Position.h:23
bool Gaudi::Parsers::PropertyValue::IsMap ( ) const

Definition at line 19 of file PropertyValue.cpp.

19 { return boost::get<std::map<std::string, std::string>>( &value_ ) != NULL; }
bool Gaudi::Parsers::PropertyValue::IsReference ( ) const
inline

Definition at line 49 of file PropertyValue.h.

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

Definition at line 15 of file PropertyValue.cpp.

15 { return boost::get<std::string>( &value_ ) != NULL; }
bool Gaudi::Parsers::PropertyValue::IsVector ( ) const

Definition at line 17 of file PropertyValue.cpp.

17 { return boost::get<std::vector<std::string>>( &value_ ) != NULL; }
MapOfStrings& Gaudi::Parsers::PropertyValue::Map ( )
inline

Definition at line 41 of file PropertyValue.h.

41 { return boost::get<MapOfStrings>( value_ ); }
const MapOfStrings& Gaudi::Parsers::PropertyValue::Map ( ) const
inline

Definition at line 42 of file PropertyValue.h.

42 { return boost::get<MapOfStrings>( value_ ); }
const gp::PropertyValue Gaudi::Parsers::PropertyValue::operator+ ( const PropertyValue right)

Definition at line 48 of file PropertyValue.cpp.

48  {
49  return PropertyValue{*this} += right;
50 }
PropertyValue(Value value, bool is_reference=false)
Definition: PropertyValue.h:28
T right(T...args)
gp::PropertyValue & Gaudi::Parsers::PropertyValue::operator+= ( const PropertyValue right)

Definition at line 21 of file PropertyValue.cpp.

21  {
22 
24 
25  if ( IsVector() ) {
26  if ( right.IsSimple() ) {
27  boost::get<VectorOfStrings>( value_ ).push_back( boost::get<std::string>( right.value_ ) );
28  return *this;
29  }
30  if ( right.IsVector() ) {
31  VectorOfStrings& vec = boost::get<VectorOfStrings>( value_ );
32  for ( const auto& item : boost::get<VectorOfStrings>( right.value_ ) ) { vec.push_back( item ); }
33  return *this;
34  }
36  }
37 
38  if ( IsMap() ) {
39  if ( !right.IsMap() ) { throw PropertyValueException::WrongRValue(); }
40  MapOfStrings& map = boost::get<MapOfStrings>( value_ );
41  const MapOfStrings& rmap = boost::get<MapOfStrings>( right.value_ );
42  for ( const auto& item : rmap ) { map.insert( item ); }
43  return *this;
44  }
45  return *this;
46 }
std::vector< std::string > VectorOfStrings
Definition: PropertyValue.h:24
std::map< std::string, std::string > MapOfStrings
Definition: PropertyValue.h:25
T right(T...args)
void push_back(Container &c, const Value &v, std::true_type)
T push_back(T...args)
struct GAUDI_API map
Parametrisation class for map-like implementation.
static PropertyValueException WrongRValue()
Definition: PropertyValue.h:73
T insert(T...args)
static PropertyValueException WrongLValue()
Definition: PropertyValue.h:69
const gp::PropertyValue Gaudi::Parsers::PropertyValue::operator- ( const PropertyValue right)

Definition at line 87 of file PropertyValue.cpp.

87  {
88  return PropertyValue{*this} -= right;
89 }
PropertyValue(Value value, bool is_reference=false)
Definition: PropertyValue.h:28
T right(T...args)
gp::PropertyValue & Gaudi::Parsers::PropertyValue::operator-= ( const PropertyValue right)

Definition at line 52 of file PropertyValue.cpp.

52  {
54 
55  if ( IsVector() ) {
56  VectorOfStrings& vec = Vector();
57  if ( right.IsSimple() ) {
58  vec.erase( std::find( vec.begin(), vec.end(), right.String() ) );
59  return *this;
60  }
61 
62  if ( right.IsVector() ) {
63  const VectorOfStrings& rvec = right.Vector();
64  for ( const auto& item : rvec ) { vec.erase( std::find( vec.begin(), vec.end(), item ) ); }
65  return *this;
66  }
68  }
69 
70  if ( IsMap() ) {
71  MapOfStrings& map = Map();
72  if ( right.IsSimple() ) {
73  map.erase( right.String() );
74  return *this;
75  }
76 
77  if ( right.IsVector() ) {
78  const VectorOfStrings& rvec = right.Vector();
79  for ( const auto& item : rvec ) { map.erase( item ); }
80  return *this;
81  }
83  }
85 }
std::vector< std::string > VectorOfStrings
Definition: PropertyValue.h:24
std::map< std::string, std::string > MapOfStrings
Definition: PropertyValue.h:25
T right(T...args)
struct GAUDI_API map
Parametrisation class for map-like implementation.
static PropertyValueException WrongRValue()
Definition: PropertyValue.h:73
VectorOfStrings & Vector()
Definition: PropertyValue.h:38
T find(T...args)
static PropertyValueException WrongLValue()
Definition: PropertyValue.h:69
const Position& Gaudi::Parsers::PropertyValue::position ( ) const
inline

Definition at line 33 of file PropertyValue.h.

33 { return position_; }
std::string& Gaudi::Parsers::PropertyValue::String ( )
inline

Definition at line 35 of file PropertyValue.h.

35 { return boost::get<std::string>( value_ ); }
const std::string& Gaudi::Parsers::PropertyValue::String ( ) const
inline

Definition at line 36 of file PropertyValue.h.

36 { return boost::get<std::string>( value_ ); }
std::string Gaudi::Parsers::PropertyValue::ToString ( ) const

Definition at line 91 of file PropertyValue.cpp.

91  {
92  if ( IsReference() ) {
93  const std::vector<std::string>* value = boost::get<std::vector<std::string>>( &value_ );
94  assert( value != NULL );
95  if ( value->at( 0 ) != "" ) {
96  return "@" + value->at( 0 ) + "." + value->at( 1 );
97  } else {
98  return "@" + value->at( 0 );
99  }
100  }
101  if ( const std::string* value = boost::get<std::string>( &value_ ) ) {
102  return *value;
103  } else if ( const std::vector<std::string>* value = boost::get<std::vector<std::string>>( &value_ ) ) {
104  std::string result = "[";
105  std::string delim = "";
106  for ( const auto& in : *value ) {
107  result += delim + in;
108  delim = ", ";
109  }
110  return result + "]";
111  } else if ( const std::map<std::string, std::string>* value =
113  std::string result = "{";
114  std::string delim = "";
115  for ( const auto& in : *value ) {
116  result += delim + in.first + ":" + in.second;
117  delim = ", ";
118  }
119  return result + "}";
120  }
121  assert( false );
122  // @todo Check the validity of this logic
123  return std::string(); // avoid compilation warning
124 }
STL class.
T at(T...args)
VectorOfStrings& Gaudi::Parsers::PropertyValue::Vector ( )
inline

Definition at line 38 of file PropertyValue.h.

38 { return boost::get<VectorOfStrings>( value_ ); }
const VectorOfStrings& Gaudi::Parsers::PropertyValue::Vector ( ) const
inline

Definition at line 39 of file PropertyValue.h.

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

Member Data Documentation

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

Definition at line 62 of file PropertyValue.h.

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

Definition at line 61 of file PropertyValue.h.

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

Definition at line 60 of file PropertyValue.h.


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