Gaudi Framework, version v24r2

Home   Generated: Wed Dec 4 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Private Attributes | List of all members
Gaudi::Parsers::PropertyValue Class Reference

#include <PropertyValue.h>

Collaboration diagram for Gaudi::Parsers::PropertyValue:
Collaboration graph
[legend]

Public Types

typedef boost::shared_ptr
< PropertyValue
SharedPtr
 
typedef boost::shared_ptr
< const PropertyValue
ConstSharedPtr
 
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::stringVectorOfStrings
 
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::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 boost::scoped_ptr<const PropertyValue> Gaudi::Parsers::PropertyValue::ConstScopedPtr

Definition at line 28 of file PropertyValue.h.

typedef boost::shared_ptr<const PropertyValue> Gaudi::Parsers::PropertyValue::ConstSharedPtr

Definition at line 26 of file PropertyValue.h.

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

Definition at line 33 of file PropertyValue.h.

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

Definition at line 27 of file PropertyValue.h.

typedef boost::shared_ptr<PropertyValue> Gaudi::Parsers::PropertyValue::SharedPtr

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 31 of file PropertyValue.h.

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

Definition at line 32 of file PropertyValue.h.

Constructor & Destructor Documentation

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

Definition at line 36 of file PropertyValue.h.

: value_(value), is_reference_(is_reference) {}
Gaudi::Parsers::PropertyValue::PropertyValue ( const Value value,
const Position position,
bool  is_reference = false 
)
inline

Definition at line 38 of file PropertyValue.h.

: value_(value), position_(position),
is_reference_(is_reference) {}

Member Function Documentation

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

Definition at line 55 of file PropertyValue.h.

{return position_.Exists();}
bool Gaudi::Parsers::PropertyValue::IsMap ( ) const

Definition at line 25 of file PropertyValue.cpp.

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

Definition at line 59 of file PropertyValue.h.

{ return is_reference_;};
bool Gaudi::Parsers::PropertyValue::IsSimple ( ) const

Definition at line 17 of file PropertyValue.cpp.

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

Definition at line 21 of file PropertyValue.cpp.

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

Definition at line 51 of file PropertyValue.h.

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

Definition at line 52 of file PropertyValue.h.

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

Definition at line 68 of file PropertyValue.cpp.

{
return PropertyValue(*this) += right;
}
gp::PropertyValue & Gaudi::Parsers::PropertyValue::operator+= ( const PropertyValue right)

Definition at line 30 of file PropertyValue.cpp.

{
if (IsSimple() || IsReference()) {
throw PropertyValueException::WrongLValue();
}
if (IsVector()) {
if (right.IsSimple()) {
boost::get<VectorOfStrings>(value_).push_back(
boost::get<std::string>(right.value_));
return *this;
}
if (right.IsVector()){
VectorOfStrings& vec = boost::get<VectorOfStrings>(value_);
BOOST_FOREACH(const std::string& item,
boost::get<VectorOfStrings>(right.value_)) {
vec.push_back(item);
}
return *this;
}
throw PropertyValueException::WrongRValue();
}
if (IsMap()) {
if (!right.IsMap()) {
throw PropertyValueException::WrongRValue();
}
MapOfStrings& map = boost::get<MapOfStrings>(value_);
const MapOfStrings& rmap = boost::get<MapOfStrings>(right.value_);
BOOST_FOREACH(const MapOfStrings::value_type& item, rmap) {
map.insert(item);
}
return *this;
}
return *this;
}
const gp::PropertyValue Gaudi::Parsers::PropertyValue::operator- ( const PropertyValue right)

Definition at line 116 of file PropertyValue.cpp.

{
return PropertyValue(*this) -= right;
}
gp::PropertyValue & Gaudi::Parsers::PropertyValue::operator-= ( const PropertyValue right)

Definition at line 74 of file PropertyValue.cpp.

{
if (IsSimple() || IsReference()) {
throw PropertyValueException::WrongLValue();
}
if (IsVector()) {
if (right.IsSimple()) {
vec.erase(std::find(vec.begin(), vec.end(), right.String()));
return *this;
}
if (right.IsVector()) {
const VectorOfStrings& rvec = right.Vector();
BOOST_FOREACH(const std::string& item, rvec) {
vec.erase(std::find(vec.begin(), vec.end(), item));
}
return *this;
}
throw PropertyValueException::WrongRValue();
}
if (IsMap()) {
if (right.IsSimple()) {
map.erase(right.String());
return *this;
}
if (right.IsVector()) {
const VectorOfStrings& rvec = right.Vector();
BOOST_FOREACH(const std::string& item, rvec) {
map.erase(item);
}
return *this;
}
throw PropertyValueException::WrongRValue();
}
throw PropertyValueException::WrongLValue();
}
const Position& Gaudi::Parsers::PropertyValue::position ( ) const
inline

Definition at line 42 of file PropertyValue.h.

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

Definition at line 44 of file PropertyValue.h.

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

Definition at line 45 of file PropertyValue.h.

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

Definition at line 120 of file PropertyValue.cpp.

{
if (IsReference()) {
value = boost::get<std::vector<std::string> >(&value_);
assert(value != NULL);
if (value->at(0) != "") {
return "@"+value->at(0)+"."+value->at(1);
} else {
return "@"+value->at(0);
}
}
if (const std::string* value = boost::get<std::string>(&value_)) {
return *value;
} else if (const std::vector<std::string>*
value = boost::get<std::vector<std::string> >(&value_)) {
std::string result = "[";
std::string delim = "";
BOOST_FOREACH(const std::string& in, *value) {
result += delim + in;
delim = ", ";
}
return result+"]";
std::string result = "{";
std::string delim = "";
BOOST_FOREACH(const pair_t& in, *value) {
result += delim + in.first + ":" + in.second;
delim = ", ";
}
return result+"}";
}
assert(false);
// @todo Check the validity of this logic
return std::string(); // avoid compilation warning
}
VectorOfStrings& Gaudi::Parsers::PropertyValue::Vector ( )
inline

Definition at line 47 of file PropertyValue.h.

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

Definition at line 48 of file PropertyValue.h.

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

Member Data Documentation

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

Definition at line 72 of file PropertyValue.h.

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

Definition at line 71 of file PropertyValue.h.

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

Definition at line 70 of file PropertyValue.h.


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

Generated at Wed Dec 4 2013 14:33:21 for Gaudi Framework, version v24r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004