Gaudi Framework, version v23r5

Home   Generated: Wed Nov 28 2012
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PropertyValue.h
Go to the documentation of this file.
1 // $Id:$
2 #ifndef JOBOPTIONSVC_PROPERTY_VALUE_H_
3 #define JOBOPTIONSVC_PROPERTY_VALUE_H_
4 // ============================================================================
5 // Includes:
6 // ============================================================================
7 // STD & STL:
8 // ============================================================================
9 #include <string>
10 #include <vector>
11 #include <map>
12 #include <stdexcept>
13 // ============================================================================
14 #include <boost/variant.hpp>
15 #include <boost/scoped_ptr.hpp>
16 #include <boost/shared_ptr.hpp>
17 // ============================================================================
18 #include "Position.h"
19 // ============================================================================
20 namespace Gaudi { namespace Parsers {
21 // ============================================================================
23 // ----------------------------------------------------------------------------
24  public:
25  typedef boost::shared_ptr<PropertyValue> SharedPtr;
26  typedef boost::shared_ptr<const PropertyValue> ConstSharedPtr;
27  typedef boost::scoped_ptr<PropertyValue> ScopedPtr;
28  typedef boost::scoped_ptr<const PropertyValue> ConstScopedPtr;
29 
30  typedef boost::variant<std::string, std::vector<std::string>,
34 
35 // ----------------------------------------------------------------------------
36  explicit PropertyValue(const Value& value,
37  bool is_reference=false): value_(value), is_reference_(is_reference) {}
38  PropertyValue(const Value& value, const Position& position,
39  bool is_reference=false): value_(value), position_(position),
41 // ----------------------------------------------------------------------------
42  const Position& position() const { return position_;}
43 // ----------------------------------------------------------------------------
44  std::string& String() { return boost::get<std::string>(value_);}
45  const std::string& String() const { return boost::get<std::string>(value_);}
46 
47  VectorOfStrings& Vector() { return boost::get<VectorOfStrings>(value_);}
48  const VectorOfStrings& Vector() const {
49  return boost::get<VectorOfStrings>(value_);}
50 
51  MapOfStrings& Map() { return boost::get<MapOfStrings>(value_);}
52  const MapOfStrings& Map() const { return boost::get<MapOfStrings>(value_);}
53 // ----------------------------------------------------------------------------
54  std::string ToString() const;
55  bool HasPosition() const {return position_.Exists();}
56  bool IsSimple() const;
57  bool IsVector() const;
58  bool IsMap() const;
59  bool IsReference() const { return is_reference_;};
60  // ----------------------------------------------------------------------------
61  // Operators:
62  // ----------------------------------------------------------------------------
63 
64  PropertyValue& operator += (const PropertyValue& right);
65  const PropertyValue operator + (const PropertyValue& right);
66  PropertyValue& operator -= (const PropertyValue& right);
67  const PropertyValue operator - (const PropertyValue& right);
68  //bool operator == (const PropertyValue& right) const;
69  private:
73 // ----------------------------------------------------------------------------
74 }; // class PropertyValue
75 // ============================================================================
77  public:
79  std::runtime_error(message){}
81  return PropertyValueException("Cannot apply +=/-= operation to left value.");
82  }
83 
85  return PropertyValueException("Cannot apply +=/-= operation to right value.");
86  }
87 
88 };
89 
91  public:
93  const std::string& message): std::runtime_error(message),
94  position_(position){}
95  const Position& position() const { return position_;}
96 
98  const std::string& name) {
99  return PositionalPropertyValueException(position,
100  "Could not find property "+name+".");
101  }
102 
104  const Position& position,
105  const std::string& name) {
106  return PositionalPropertyValueException(position,
107  "Could not find property '"+name+"'.");
108  }
109 
111  const Position& position,
112  const std::string& name) {
113  return PositionalPropertyValueException(position,
114  "Could not find unit '"+name+"'.");
115  }
116 
118  private:
120 };
121 // ============================================================================
122 } /* Gaudi */ } /* Parsers */
123 // ============================================================================
124 #endif // JOBOPTIONSVC_PROPERTY_VALUE_H_

Generated at Wed Nov 28 2012 12:17:12 for Gaudi Framework, version v23r5 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004