mirror of https://github.com/Icinga/icinga2.git
Re-implemented integer support for the Variant class.
This commit is contained in:
parent
a17c614d96
commit
c0d7241eaf
|
@ -35,10 +35,22 @@ public:
|
|||
: m_Value()
|
||||
{ }
|
||||
|
||||
inline Variant(int value)
|
||||
: m_Value(static_cast<long>(value))
|
||||
{ }
|
||||
|
||||
inline Variant(long value)
|
||||
: m_Value(value)
|
||||
{ }
|
||||
|
||||
inline Variant(double value)
|
||||
: m_Value(value)
|
||||
{ }
|
||||
|
||||
inline Variant(bool value)
|
||||
: m_Value(static_cast<long>(value))
|
||||
{ }
|
||||
|
||||
inline Variant(const string& value)
|
||||
: m_Value(value)
|
||||
{ }
|
||||
|
@ -58,17 +70,29 @@ public:
|
|||
m_Value = object;
|
||||
}
|
||||
|
||||
operator long(void) const
|
||||
{
|
||||
if (m_Value.type() != typeid(long)) {
|
||||
return boost::lexical_cast<long>(m_Value);
|
||||
} else {
|
||||
return boost::get<long>(m_Value);
|
||||
}
|
||||
}
|
||||
|
||||
operator double(void) const
|
||||
{
|
||||
if (m_Value.type() != typeid(double)) {
|
||||
double result = boost::lexical_cast<double>(m_Value);
|
||||
m_Value = result;
|
||||
return result;
|
||||
return boost::lexical_cast<double>(m_Value);
|
||||
} else {
|
||||
return boost::get<double>(m_Value);
|
||||
}
|
||||
}
|
||||
|
||||
operator bool(void) const
|
||||
{
|
||||
return static_cast<long>(*this);
|
||||
}
|
||||
|
||||
operator string(void) const
|
||||
{
|
||||
if (m_Value.type() != typeid(string)) {
|
||||
|
@ -105,7 +129,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
mutable boost::variant<boost::blank, double, string, Object::Ptr> m_Value;
|
||||
mutable boost::variant<boost::blank, long, double, string, Object::Ptr> m_Value;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue