Medical Imaging Interaction Toolkit  2018.4.99-9a29ffc6
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

◆ Any() [1/3]

us::Any::Any ( )
inline

Creates an empty any type.

Definition at line 170 of file usAny.h.

◆ Any() [2/3]

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.

◆ Any() [3/3]

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.

◆ ~Any()

us::Any::~Any ( )
inline

Definition at line 198 of file usAny.h.

Member Function Documentation

◆ Empty()

◆ operator=() [1/2]

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().

◆ operator=() [2/2]

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().

◆ 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=().

◆ ToJSON()

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().

◆ ToString()

◆ Type()

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.

References us::any_cast(), us::any_value_to_json(), us::any_value_to_string(), and us::unsafe_any_cast().

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

Friends And Related Function Documentation

◆ any_cast

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 nullptr if the cast fails, i.e. types don't match.

Definition at line 377 of file usAny.h.

◆ unsafe_any_cast

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: