Medical Imaging Interaction Toolkit  2024.06.00
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 ( )
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()

bool us::Any::Empty ( ) const
inline

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

◆ operator=() [2/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().

◆ 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 mitk::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.

◆ ToString()

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

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


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