Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# osgIntrospection::Value Class Reference

List of all members.

## Public Member Functions
| Value ()
| Default constructor.
| Value (void *v)
| Direct initialization constructor for void pointers.
| Value (const void *v)
| Direct initialization constructor for const void pointers.
template<typename T> | Value (T *v)
| Direct initialization constructor template for non-const pointers.
template<typename T> | Value (const T *v)
| Direct initialization constructor template for non-const pointers.
template<typename T> | Value (const T &v)
| Direct initialization constructor template for all types that are not handled by any of the constructors above.
| Value (const Value &copy)
| Copy constructor.
| ~Value ()
| Destructor.
Value & | operator= (const Value &copy)
| Assignment operator. Behaves like the copy constructor.
bool | isTypedPointer () const
| Returns whether the value is a pointer and it points to something whose type is different than void.
bool | isEmpty () const
| Returns whether this Value is empty.
bool | isNullPointer () const
| Returns whether the value is a null pointer.
const Type & | getType () const
| Returns the exact type of the value held.
const Type & | getInstanceType () const
| If the value is a pointer to a non-void type, this method returns the actual type of the dereferenced pointer.
bool | operator== (const Value &other) const
| Equal to operator.
bool | operator<= (const Value &other) const
| Less than or equal to operator.
bool | operator!= (const Value &other) const
| Inequality test operator. Returns !operator==(other).
bool | operator> (const Value &other) const
| Greater than operator. Returns !operator<=(other).
bool | operator< (const Value &other) const
| Less than operator. Returns !operator==(other) && operator<=(other).
bool | operator>= (const Value &other) const
| Greater than or equal to operator. Returns operator==(other) || !operator<=(other).
Value | convertTo (const Type &outtype) const
| Tries to convert this instance to a Value of the given type.
Value | tryConvertTo (const Type &outtype) const
| Tries to convert this instance to a Value of the given type.
std::string | toString () const
| Tries to get a string representation of the underlying value.
void | swap (Value &v)
| Swaps the content of this Value with another Value.
## Friends
template<typename T> T | variant_cast (const Value &v)
| Tries to convert an instance of Value to an object of type T.
template<typename T> bool | requires_conversion (const Value &v)
| Returns true if the Value passed as parameter can't be casted to the specified type without a (potentially slow) conversion.
template<typename T> T * | extract_raw_data (Value &v)
| Returns a typed pointer to the data contained in a Value instance.
template<typename T> const T * | extract_raw_data (const Value &v)
| Returns a typed pointer to the data contained in a const Value instance.

## Constructor & Destructor Documentation

osgIntrospection::Value::Value | ( |  | ) | `[inline]`

| Default constructor. Initializes internal structures so that the Type returned by getType() is typeof(void), and the value is empty so that isEmpty() returns true. Be careful when using empty values, as some operations on them may throw an exception.

osgIntrospection::Value::Value | ( | void * | v | ) | `[inline]`

| Direct initialization constructor for void pointers. Although one of the constructor templates below could certainly handle void pointers as well, we need to treat them separately because void* can't be dereferenced.

osgIntrospection::Value::Value | ( | const void * | v | ) | `[inline]`

| Direct initialization constructor for const void pointers. Although one of the constructor templates below could certainly handle void pointers as well, we need to treat them separately because void* can't be dereferenced.

template<typename T>
osgIntrospection::Value::Value | ( | T * | v | ) |

| Direct initialization constructor template for non-const pointers. By initializing an instance of Value through this constructor, internal structures will be configured to handle polymorphic types. This means you'll be able to call getInstanceType() to get the actual type of the dereferenced value.

template<typename T>
osgIntrospection::Value::Value | ( | const T * | v | ) |

| Direct initialization constructor template for non-const pointers. By initializing an instance of Value through this constructor, internal structures will be configured to handle polymorphic types. This means you'll be able to call getInstanceType() to get the actual type of the dereferenced value.

template<typename T>
osgIntrospection::Value::Value | ( | const T & | v | ) |

| Direct initialization constructor template for all types that are not handled by any of the constructors above. Calling getInstanceType() on an instance constructed this way returns the same as getType().

osgIntrospection::Value::Value | ( | const Value & | copy | ) | `[inline]`

| Copy constructor. The underlying value's type must have consistent copy semantics.

osgIntrospection::Value::~Value | ( |  | ) | `[inline]`

| Destructor. Frees internal resources but it does NOT delete the value held. For example, this function will produce a memory leak: void f() { Value v(new int); }

## Member Function Documentation

Value osgIntrospection::Value::convertTo | ( | const Type & | outtype | ) | const

| Tries to convert this instance to a Value of the given type. The conversion is performed by rendering to a temporary stream in the source format and trying to read back from the stream in the destination format. If either the source or destination types, or both, don't have a ReaderWriter object, the conversion fails and an exception is thrown. If the conversion can't be completed for other reasons, other exceptions may be thrown.

const Type & osgIntrospection::Value::getInstanceType | ( |  | ) | const`[inline]`

| If the value is a pointer to a non-void type, this method returns the actual type of the dereferenced pointer. Please note it is not the same as getType().getPointedType(), because the latter would return the non-polymorphic type. If the value is not a pointer, this method behaves like getType().

const Type & osgIntrospection::Value::getType | ( |  | ) | const`[inline]`

| Returns the exact type of the value held.

bool osgIntrospection::Value::isEmpty | ( |  | ) | const`[inline]`

| Returns whether this Value is empty.

bool osgIntrospection::Value::isNullPointer | ( |  | ) | const`[inline]`

| Returns whether the value is a null pointer.

bool osgIntrospection::Value::isTypedPointer | ( |  | ) | const`[inline]`

| Returns whether the value is a pointer and it points to something whose type is different than void.

bool osgIntrospection::Value::operator!= | ( | const Value & | other | ) | const

| Inequality test operator. Returns !operator==(other).

bool osgIntrospection::Value::operator< | ( | const Value & | other | ) | const

| Less than operator. Returns !operator==(other) && operator<=(other).

bool osgIntrospection::Value::operator<= | ( | const Value & | other | ) | const

| Less than or equal to operator.

Value & osgIntrospection::Value::operator= | ( | const Value & | copy | ) | `[inline]`

| Assignment operator. Behaves like the copy constructor.

bool osgIntrospection::Value::operator== | ( | const Value & | other | ) | const

| Equal to operator.

bool osgIntrospection::Value::operator> | ( | const Value & | other | ) | const

| Greater than operator. Returns !operator<=(other).

bool osgIntrospection::Value::operator>= | ( | const Value & | other | ) | const

| Greater than or equal to operator. Returns operator==(other) || !operator<=(other).

void osgIntrospection::Value::swap | ( | Value & | v | ) |

| Swaps the content of this Value with another Value.

std::string osgIntrospection::Value::toString | ( |  | ) | const

| Tries to get a string representation of the underlying value. This requires the value's type to have a ReaderWriter object associated to it. If the conversion can't be completed, an exception is thrown.

Value osgIntrospection::Value::tryConvertTo | ( | const Type & | outtype | ) | const

| Tries to convert this instance to a Value of the given type. The conversion is performed by rendering to a temporary stream in the source format and trying to read back from the stream in the destination format. If either the source or destination types, or both, don't have a ReaderWriter object, the conversion fails and an empty Value is returned. Please note that unlike convertTo(), this method does not intentionally throw any exceptions.

## Friends And Related Function Documentation

template<typename T>
const T* extract_raw_data | ( | const Value & | v | ) | `[friend]`

| Returns a typed pointer to the data contained in a const Value instance. If the value's type is not identical to type T, a null pointer is returned.

template<typename T>
T* extract_raw_data | ( | Value & | v | ) | `[friend]`

| Returns a typed pointer to the data contained in a Value instance. If the value's type is not identical to type T, a null pointer is returned.

template<typename T>
bool requires_conversion | ( | const Value & | v | ) | `[friend]`

| Returns true if the Value passed as parameter can't be casted to the specified type without a (potentially slow) conversion. Returns false otherwise.

template<typename T>
T variant_cast | ( | const Value & | v | ) | `[friend]`

| Tries to convert an instance of Value to an object of type T. If T is a plain type or a pointer type (either const or non-const), and it matches the type of the value contained in v, then the actual value of type T is returned. If T is a [const] reference type, and its base (non reference) type matches the internal value's type, then a [const] reference to the internal value is returned. If none of the above conditions are met, a conversion is attempted as described in Value::convert() and then variant_cast is called again with the converted value as parameter. If the conversion can't be completed, an exception is thrown. Conversions that attempt to make a const pointer non-const will fail.

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

- Value