Medical Imaging Interaction Toolkit  2022.10.99-122321bb
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

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

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)

Creates an Any which stores the init parameter inside.

valueThe content of the Any


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

Definition at line 185 of file usAny.h.

◆ Any() [3/3]

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

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

otherThe Any to copy

Definition at line 194 of file usAny.h.

◆ ~Any()

us::Any::~Any ( )

Definition at line 198 of file usAny.h.

Member Function Documentation

◆ Empty()

bool us::Any::Empty ( ) const

returns true if the Any is empty

Definition at line 246 of file usAny.h.

◆ operator=() [1/2]

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

Assignment operator for Any.

rhsThe Any which should be assigned to this Any.

Definition at line 237 of file usAny.h.

References Swap().

◆ operator=() [2/2]

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

Assignment operator for all types != Any.

rhsThe value which should be assigned to this Any.


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

Definition at line 226 of file usAny.h.

References Swap().

◆ Swap()

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

Swaps the content of the two Anys.

rhsThe Any to swap this Any with.

Definition at line 208 of file usAny.h.

References mitk::swap().

Referenced by operator=().

◆ ToJSON()

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

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.

◆ ToString()

std::string us::Any::ToString ( ) const

Returns a string representation for the content.

Custom types should either provide a std::ostream& operator<<(std::ostream& os, const CustomType& ct) function or specialize the any_value_to_string template function for meaningful output.

Definition at line 257 of file usAny.h.

◆ Type()

const std::type_info& us::Any::Type ( ) const

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

The documentation for this class was generated from the following file:
Definition: usAny.h:170