Dv::Any Class Reference

An Any object can hold any kind of value. More...

#include <any.h>

Collaboration diagram for Dv::Any:
Collaboration graph
[legend]

List of all members.

Classes

struct  AbstractObject
struct  Object

Public Member Functions

 Any ()
 ~Any ()
 Any (const Any &a)
template<typename T >
 Any (const T &t)
 Constructor.
 Any (const char *s)
 Constructor for const char* objects.
const std::type_info & type () const
 Return type of value in Any object.
bool null () const
 Does this object contain a value?

Private Member Functions

template<typename T >
 Any (const T *)
 Forbid Any values containing pointers.

Private Attributes

AbstractObjectit_

Friends

template<typename U >
U * any_cast (const Any *any)
 Convert an Any object to its underlying value type.

Detailed Description

An Any object can hold any kind of value.

This class is inspired by boost::any_cast but without the typical boost bloat.

Definition at line 13 of file any.h.


Constructor & Destructor Documentation

Dv::Any::Any (  )  [inline]

Definition at line 15 of file any.h.

Dv::Any::~Any (  )  [inline]

Definition at line 16 of file any.h.

References it_.

Dv::Any::Any ( const Any a  )  [inline]

Definition at line 17 of file any.h.

template<typename T >
Dv::Any::Any ( const T &  t  )  [inline]

Constructor.

You can stuff an object of any type, except pointer types, in an Any object. However, const char* are converted to std::string values before storing them.

Parameters:
t value of a non-pointer type, or of type const char*

Definition at line 25 of file any.h.

Dv::Any::Any ( const char *  s  )  [inline]

Constructor for const char* objects.

Parameters:
s value to store in an Any object.

Definition at line 30 of file any.h.

template<typename T >
Dv::Any::Any ( const T *   )  [inline, private]

Forbid Any values containing pointers.

Use e.g. vectors. Except const char*, see above.


Member Function Documentation

const std::type_info& Dv::Any::type (  )  const [inline]

Return type of value in Any object.

This almost only be used for comparing with another typeid(T).

Returns:
type info on value in this object

Definition at line 36 of file any.h.

References it_, and Dv::Any::AbstractObject::type().

bool Dv::Any::null (  )  const [inline]

Does this object contain a value?

Returns:
true iff this object does not contain a value.

Definition at line 40 of file any.h.

References it_.


Friends And Related Function Documentation

template<typename U >
U* any_cast ( const Any any  )  [friend]

Convert an Any object to its underlying value type.

Parameters:
any pointer to an Any object to convert to type T
Returns:
pointer to underlying T-value or 0 if none (including if type mismatch)

Definition at line 47 of file any.h.


Member Data Documentation

Definition at line 74 of file any.h.

Referenced by null(), type(), and ~Any().


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

dvutil-1.0.10 [ 5 December, 2009]