Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
us::Any Class Reference

#include <usAny.h>

Public Member Functions

 Any ()
 
template<typename ValueType >
 Any (const ValueType &value)
 
 Any (const Any &other)
 
 ~Any ()
 
AnySwap (Any &rhs)
 
template<typename ValueType >
Anyoperator= (const ValueType &rhs)
 
Anyoperator= (const Any &rhs)
 
bool Empty () const
 
std::string ToString () const
 
std::string ToJSON () const
 
const std::type_info & Type () const
 

Friends

template<typename ValueType >
ValueType * any_cast (Any *)
 
template<typename ValueType >
ValueType * unsafe_any_cast (Any *)
 

Detailed Description

An Any class represents a general type and is capable of storing any type, supporting type-safe extraction of the internally stored data.

Code taken from the Boost 1.46.1 library. Original copyright by Kevlin Henney. Modified for CppMicroServices.

Definition at line 163 of file usAny.h.

Constructor & Destructor Documentation

us::Any::Any ( )
inline

Creates an empty any type.

Definition at line 170 of file usAny.h.

template<typename ValueType >
us::Any::Any ( const ValueType &  value)
inline

Creates an Any which stores the init parameter inside.

Parameters
valueThe content of the Any

Example:

Any a(13);
Any a(string("12345"));

Definition at line 185 of file usAny.h.

us::Any::Any ( const Any other)
inline

Copy constructor, works with empty Anys and initialized Any values.

Parameters
otherThe Any to copy

Definition at line 194 of file usAny.h.

us::Any::~Any ( )
inline

Definition at line 198 of file usAny.h.

Member Function Documentation

template<typename ValueType >
Any& us::Any::operator= ( const ValueType &  rhs)
inline

Assignment operator for all types != Any.

Parameters
rhsThe value which should be assigned to this Any.

Example:

Any a = 13;
Any a = string("12345");

Definition at line 226 of file usAny.h.

References Swap().

Any& us::Any::operator= ( const Any rhs)
inline

Assignment operator for Any.

Parameters
rhsThe Any which should be assigned to this Any.

Definition at line 237 of file usAny.h.

References Swap().

Any& us::Any::Swap ( Any rhs)
inline

Swaps the content of the two Anys.

Parameters
rhsThe Any to swap this Any with.

Definition at line 208 of file usAny.h.

References swap().

Referenced by operator=().

std::string us::Any::ToJSON ( ) const
inline

Returns a JSON representation for the content.

Custom types should specialize the any_value_to_json template function for meaningful output.

Definition at line 267 of file usAny.h.

Referenced by us::any_value_to_json().

std::string us::Any::ToString ( ) const
inline
const std::type_info& us::Any::Type ( ) const
inline

Returns the type information of the stored content. If the Any is empty typeid(void) is returned. It is suggested to always query an Any for its type info before trying to extract data via an any_cast/ref_any_cast.

Definition at line 278 of file usAny.h.

Referenced by us::any_cast(), GetAnyWidget(), us::ServiceReferenceBase::operator<(), QmitkInvalidAnyWidget::QmitkInvalidAnyWidget(), and us::ServiceRegistrationBase::SetProperties().

Friends And Related Function Documentation

template<typename ValueType >
ValueType* any_cast ( Any operand)
friend

any_cast operator used to extract the ValueType from an Any*. Will return a pointer to the stored value.

Example Usage:

MyType* pTmp = any_cast<MyType*>(pAny)

Will return NULL if the cast fails, i.e. types don't match.

Definition at line 377 of file usAny.h.

template<typename ValueType >
ValueType* unsafe_any_cast ( Any operand)
friend

Definition at line 482 of file usAny.h.


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