All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Gaudi::Parsers::PropertyValue Class Reference

#include <src/JobOptionsSvc/PropertyValue.h>

Collaboration diagram for Gaudi::Parsers::PropertyValue:

Public Types

typedef boost::scoped_ptr
< PropertyValue
ScopedPtr
 
typedef boost::scoped_ptr
< const PropertyValue
ConstScopedPtr
 
typedef boost::variant
< std::string, std::vector
< std::string >, std::map
< std::string, std::string > > 
Value
 
typedef std::vector< std::string > VectorOfStrings
 
typedef std::map< std::string,
std::string > 
MapOfStrings
 

Public Member Functions

 PropertyValue (const Value &value, bool is_reference=false)
 
 PropertyValue (const 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 21 of file PropertyValue.h.

Member Typedef Documentation

typedef boost::scoped_ptr<const PropertyValue> Gaudi::Parsers::PropertyValue::ConstScopedPtr

Definition at line 25 of file PropertyValue.h.

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

Definition at line 30 of file PropertyValue.h.

typedef boost::scoped_ptr<PropertyValue> Gaudi::Parsers::PropertyValue::ScopedPtr

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

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

Definition at line 29 of file PropertyValue.h.

Constructor & Destructor Documentation

Gaudi::Parsers::PropertyValue::PropertyValue ( const Value value,
bool  is_reference = false 
)
inlineexplicit
Gaudi::Parsers::PropertyValue::PropertyValue ( const Value value,
const Position position,
bool  is_reference = false 
)
inline

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:23
bool Gaudi::Parsers::PropertyValue::IsMap ( ) const

Definition at line 25 of file PropertyValue.cpp.

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

Definition at line 56 of file PropertyValue.h.

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

Definition at line 17 of file PropertyValue.cpp.

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

Definition at line 21 of file PropertyValue.cpp.

21  {
22  return boost::get<std::vector<std::string> >(&value_) != NULL;
23 }
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 68 of file PropertyValue.cpp.

68  {
69  return PropertyValue(*this) += right;
70 
71 }
PropertyValue(const Value &value, bool is_reference=false)
Definition: PropertyValue.h:33
gp::PropertyValue & Gaudi::Parsers::PropertyValue::operator+= ( const PropertyValue right)

Definition at line 30 of file PropertyValue.cpp.

30  {
31 
32  if (IsSimple() || IsReference()) {
34  }
35 
36  if (IsVector()) {
37  if (right.IsSimple()) {
38  boost::get<VectorOfStrings>(value_).push_back(
39  boost::get<std::string>(right.value_));
40  return *this;
41  }
42  if (right.IsVector()){
43  VectorOfStrings& vec = boost::get<VectorOfStrings>(value_);
44  BOOST_FOREACH(const std::string& item,
45  boost::get<VectorOfStrings>(right.value_)) {
46  vec.push_back(item);
47  }
48  return *this;
49  }
51  }
52 
53  if (IsMap()) {
54  if (!right.IsMap()) {
56  }
57  MapOfStrings& map = boost::get<MapOfStrings>(value_);
58  const MapOfStrings& rmap = boost::get<MapOfStrings>(right.value_);
59  BOOST_FOREACH(const MapOfStrings::value_type& item, rmap) {
60  map.insert(item);
61  }
62  return *this;
63  }
64  return *this;
65 }
std::vector< std::string > VectorOfStrings
Definition: PropertyValue.h:29
std::map< std::string, std::string > MapOfStrings
Definition: PropertyValue.h:30
struct GAUDI_API map
Parametrisation class for map-like implementation.
static PropertyValueException WrongRValue()
Definition: PropertyValue.h:81
tuple item
print s1,s2
Definition: ana.py:146
static PropertyValueException WrongLValue()
Definition: PropertyValue.h:77
const gp::PropertyValue Gaudi::Parsers::PropertyValue::operator- ( const PropertyValue right)

Definition at line 116 of file PropertyValue.cpp.

116  {
117  return PropertyValue(*this) -= right;
118 }
PropertyValue(const Value &value, bool is_reference=false)
Definition: PropertyValue.h:33
gp::PropertyValue & Gaudi::Parsers::PropertyValue::operator-= ( const PropertyValue right)

Definition at line 74 of file PropertyValue.cpp.

74  {
75  if (IsSimple() || IsReference()) {
77  }
78 
79  if (IsVector()) {
80  VectorOfStrings& vec = Vector();
81  if (right.IsSimple()) {
82  vec.erase(std::find(vec.begin(), vec.end(), right.String()));
83  return *this;
84  }
85 
86  if (right.IsVector()) {
87  const VectorOfStrings& rvec = right.Vector();
88  BOOST_FOREACH(const std::string& item, rvec) {
89  vec.erase(std::find(vec.begin(), vec.end(), item));
90  }
91  return *this;
92  }
94  }
95 
96  if (IsMap()) {
97  MapOfStrings& map = Map();
98  if (right.IsSimple()) {
99  map.erase(right.String());
100  return *this;
101  }
102 
103  if (right.IsVector()) {
104  const VectorOfStrings& rvec = right.Vector();
105  BOOST_FOREACH(const std::string& item, rvec) {
106  map.erase(item);
107  }
108  return *this;
109  }
111  }
113 }
std::vector< std::string > VectorOfStrings
Definition: PropertyValue.h:29
std::map< std::string, std::string > MapOfStrings
Definition: PropertyValue.h:30
struct GAUDI_API map
Parametrisation class for map-like implementation.
static PropertyValueException WrongRValue()
Definition: PropertyValue.h:81
VectorOfStrings & Vector()
Definition: PropertyValue.h:44
tuple item
print s1,s2
Definition: ana.py:146
static PropertyValueException WrongLValue()
Definition: PropertyValue.h:77
const Position& Gaudi::Parsers::PropertyValue::position ( ) const
inline

Definition at line 39 of file PropertyValue.h.

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

Definition at line 41 of file PropertyValue.h.

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

Definition at line 42 of file PropertyValue.h.

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

Definition at line 120 of file PropertyValue.cpp.

120  {
121  if (IsReference()) {
122  const std::vector<std::string>*
123  value = boost::get<std::vector<std::string> >(&value_);
124  assert(value != NULL);
125  if (value->at(0) != "") {
126  return "@"+value->at(0)+"."+value->at(1);
127  } else {
128  return "@"+value->at(0);
129  }
130  }
131  if (const std::string* value = boost::get<std::string>(&value_)) {
132  return *value;
133  } else if (const std::vector<std::string>*
134  value = boost::get<std::vector<std::string> >(&value_)) {
135  std::string result = "[";
136  std::string delim = "";
137  BOOST_FOREACH(const std::string& in, *value) {
138  result += delim + in;
139  delim = ", ";
140  }
141  return result+"]";
142  } else if (const std::map<std::string, std::string>*
143  value = boost::get<std::map<std::string, std::string> >(&value_)) {
144  std::string result = "{";
145  std::string delim = "";
146  typedef std::pair<std::string, std::string> pair_t;
147  BOOST_FOREACH(const pair_t& in, *value) {
148  result += delim + in.first + ":" + in.second;
149  delim = ", ";
150  }
151  return result+"}";
152  }
153  assert(false);
154  // @todo Check the validity of this logic
155  return std::string(); // avoid compilation warning
156 }
VectorOfStrings& Gaudi::Parsers::PropertyValue::Vector ( )
inline

Definition at line 44 of file PropertyValue.h.

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

Definition at line 45 of file PropertyValue.h.

45  {
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: