The Gaudi Framework  v29r0 (ff2e7097)
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 22 of file PropertyValue.h.

Member Typedef Documentation

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

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

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

Definition at line 27 of file PropertyValue.h.

Constructor & Destructor Documentation

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

Definition at line 31 of file PropertyValue.h.

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

Definition at line 35 of file PropertyValue.h.

36  : value_( std::move( value ) ), position_( position ), is_reference_( is_reference )
37  {
38  }
const Position & position() const
Definition: PropertyValue.h:40
T move(T...args)

Member Function Documentation

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

Definition at line 52 of file PropertyValue.h.

52 { return position_.Exists(); }
bool Exists() const
Definition: Position.h:28
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 56 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 48 of file PropertyValue.h.

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

Definition at line 49 of file PropertyValue.h.

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

Definition at line 57 of file PropertyValue.cpp.

58 {
59  return PropertyValue( *this ) += right;
60 }
PropertyValue(Value value, bool is_reference=false)
Definition: PropertyValue.h:31
T right(T...args)
gp::PropertyValue & Gaudi::Parsers::PropertyValue::operator+= ( const PropertyValue right)

Definition at line 21 of file PropertyValue.cpp.

22 {
23 
24  if ( IsSimple() || IsReference() ) {
26  }
27 
28  if ( IsVector() ) {
29  if ( right.IsSimple() ) {
30  boost::get<VectorOfStrings>( value_ ).push_back( boost::get<std::string>( right.value_ ) );
31  return *this;
32  }
33  if ( right.IsVector() ) {
34  VectorOfStrings& vec = boost::get<VectorOfStrings>( value_ );
35  for ( const auto& item : boost::get<VectorOfStrings>( right.value_ ) ) {
36  vec.push_back( item );
37  }
38  return *this;
39  }
41  }
42 
43  if ( IsMap() ) {
44  if ( !right.IsMap() ) {
46  }
47  MapOfStrings& map = boost::get<MapOfStrings>( value_ );
48  const MapOfStrings& rmap = boost::get<MapOfStrings>( right.value_ );
49  for ( const auto& item : rmap ) {
50  map.insert( item );
51  }
52  return *this;
53  }
54  return *this;
55 }
std::vector< std::string > VectorOfStrings
Definition: PropertyValue.h:27
std::map< std::string, std::string > MapOfStrings
Definition: PropertyValue.h:28
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:82
T insert(T...args)
static PropertyValueException WrongLValue()
Definition: PropertyValue.h:77
const gp::PropertyValue Gaudi::Parsers::PropertyValue::operator- ( const PropertyValue right)

Definition at line 104 of file PropertyValue.cpp.

105 {
106  return PropertyValue( *this ) -= right;
107 }
PropertyValue(Value value, bool is_reference=false)
Definition: PropertyValue.h:31
T right(T...args)
gp::PropertyValue & Gaudi::Parsers::PropertyValue::operator-= ( const PropertyValue right)

Definition at line 62 of file PropertyValue.cpp.

63 {
64  if ( IsSimple() || IsReference() ) {
66  }
67 
68  if ( IsVector() ) {
69  VectorOfStrings& vec = Vector();
70  if ( right.IsSimple() ) {
71  vec.erase( std::find( vec.begin(), vec.end(), right.String() ) );
72  return *this;
73  }
74 
75  if ( right.IsVector() ) {
76  const VectorOfStrings& rvec = right.Vector();
77  for ( const auto& item : rvec ) {
78  vec.erase( std::find( vec.begin(), vec.end(), item ) );
79  }
80  return *this;
81  }
83  }
84 
85  if ( IsMap() ) {
86  MapOfStrings& map = Map();
87  if ( right.IsSimple() ) {
88  map.erase( right.String() );
89  return *this;
90  }
91 
92  if ( right.IsVector() ) {
93  const VectorOfStrings& rvec = right.Vector();
94  for ( const auto& item : rvec ) {
95  map.erase( item );
96  }
97  return *this;
98  }
100  }
102 }
std::vector< std::string > VectorOfStrings
Definition: PropertyValue.h:27
std::map< std::string, std::string > MapOfStrings
Definition: PropertyValue.h:28
T right(T...args)
struct GAUDI_API map
Parametrisation class for map-like implementation.
static PropertyValueException WrongRValue()
Definition: PropertyValue.h:82
VectorOfStrings & Vector()
Definition: PropertyValue.h:45
T find(T...args)
static PropertyValueException WrongLValue()
Definition: PropertyValue.h:77
const Position& Gaudi::Parsers::PropertyValue::position ( ) const
inline

Definition at line 40 of file PropertyValue.h.

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

Definition at line 42 of file PropertyValue.h.

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

Definition at line 43 of file PropertyValue.h.

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

Definition at line 109 of file PropertyValue.cpp.

110 {
111  if ( IsReference() ) {
112  const std::vector<std::string>* value = boost::get<std::vector<std::string>>( &value_ );
113  assert( value != NULL );
114  if ( value->at( 0 ) != "" ) {
115  return "@" + value->at( 0 ) + "." + value->at( 1 );
116  } else {
117  return "@" + value->at( 0 );
118  }
119  }
120  if ( const std::string* value = boost::get<std::string>( &value_ ) ) {
121  return *value;
122  } else if ( const std::vector<std::string>* value = boost::get<std::vector<std::string>>( &value_ ) ) {
123  std::string result = "[";
124  std::string delim = "";
125  for ( const auto& in : *value ) {
126  result += delim + in;
127  delim = ", ";
128  }
129  return result + "]";
130  } else if ( const std::map<std::string, std::string>* value =
132  std::string result = "{";
133  std::string delim = "";
134  for ( const auto& in : *value ) {
135  result += delim + in.first + ":" + in.second;
136  delim = ", ";
137  }
138  return result + "}";
139  }
140  assert( false );
141  // @todo Check the validity of this logic
142  return std::string(); // avoid compilation warning
143 }
STL class.
T at(T...args)
VectorOfStrings& Gaudi::Parsers::PropertyValue::Vector ( )
inline

Definition at line 45 of file PropertyValue.h.

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

Definition at line 46 of file PropertyValue.h.

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

Member Data Documentation

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

Definition at line 69 of file PropertyValue.h.

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

Definition at line 68 of file PropertyValue.h.

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

Definition at line 67 of file PropertyValue.h.


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