*/
bool Value::IsEmpty(void) const
{
- return (m_Value.type() == typeid(boost::blank));
+ return (GetType() == ValueEmpty);
}
/**
*/
bool Value::IsObject(void) const
{
- return !IsEmpty() && (m_Value.type() == typeid(Object::Ptr));
+ return !IsEmpty() && (GetType() == ValueObject);
}
Value::operator double(void) const
{
- if (m_Value.type() != typeid(double)) {
- return boost::lexical_cast<double>(m_Value);
- } else {
- return boost::get<double>(m_Value);
- }
+ const double *value = boost::get<double>(&m_Value);
+
+ if (value)
+ return *value;
+
+ return boost::lexical_cast<double>(m_Value);
}
Value::operator String(void) const
return object;
}
-bool IsEmpty(void) const;
+ bool IsEmpty(void) const;
bool IsScalar(void) const;
bool IsObject(void) const;
ValueType GetType(void) const;
private:
- mutable boost::variant<boost::blank, double, String, Object::Ptr> m_Value;
+ boost::variant<boost::blank, double, String, Object::Ptr> m_Value;
};
static Value Empty;