Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Poco::Any Class Reference

#include <Any.h>

+ Collaboration diagram for Poco::Any:

Classes

class  Holder
 
class  ValueHolder
 

Public Member Functions

 Any ()
 Creates an empty any type.
 
template<typename ValueType >
 Any (const ValueType &value)
 
 Any (const Any &other)
 Copy constructor, works with both empty and initialized Any values.
 
 ~Any ()
 
Anyswap (Any &other)
 
template<typename ValueType >
Anyoperator= (const ValueType &rhs)
 
Anyoperator= (const Any &rhs)
 Assignment operator for Any.
 
bool empty () const
 Returns true if the Any is empty.
 
const std::type_info & type () const
 

Private Member Functions

ValueHoldercontent () const
 
template<typename ValueType >
void construct (const ValueType &value)
 
void construct (const Any &other)
 
void destruct ()
 

Private Attributes

Placeholder< ValueHolder_valueHolder
 

Friends

template<typename ValueType >
ValueType * AnyCast (Any *)
 
template<typename ValueType >
ValueType * UnsafeAnyCast (Any *)
 
template<typename ValueType >
const ValueType & RefAnyCast (const Any &)
 
template<typename ValueType >
ValueType & RefAnyCast (Any &)
 
template<typename ValueType >
ValueType AnyCast (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.33.1 library. Original copyright by Kevlin Henney. Modified for Poco by Applied Informatics.

Modified for small object optimization support (optionally supported through conditional compilation) by Alex Fabijanic.

Definition at line 147 of file Any.h.

Constructor & Destructor Documentation

◆ Any() [1/3]

Poco::Any::Any ( )
inline

Creates an empty any type.

Definition at line 161 of file Any.h.

◆ Any() [2/3]

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

Creates an any which stores the init parameter inside.

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

Definition at line 167 of file Any.h.

◆ Any() [3/3]

Poco::Any::Any ( const Any & other)
inline

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

Definition at line 177 of file Any.h.

◆ ~Any()

Poco::Any::~Any ( )
inline

Destructor. If Any is locally held, calls ValueHolder destructor; otherwise, deletes the placeholder from the heap.

Definition at line 184 of file Any.h.

Member Function Documentation

◆ construct() [1/2]

void Poco::Any::construct ( const Any & other)
inlineprivate

Definition at line 331 of file Any.h.

◆ construct() [2/2]

template<typename ValueType >
void Poco::Any::construct ( const ValueType & value)
inlineprivate

Definition at line 317 of file Any.h.

◆ content()

ValueHolder * Poco::Any::content ( ) const
inlineprivate

Definition at line 311 of file Any.h.

◆ destruct()

void Poco::Any::destruct ( )
inlineprivate

Definition at line 339 of file Any.h.

◆ empty()

bool Poco::Any::empty ( ) const
inline

Returns true if the Any is empty.

Definition at line 252 of file Any.h.

◆ operator=() [1/2]

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

Assignment operator for Any.

Definition at line 241 of file Any.h.

◆ operator=() [2/2]

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

Assignment operator for all types != Any.

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

Definition at line 230 of file Any.h.

◆ swap()

Any & Poco::Any::swap ( Any & other)
inline

Swaps the content of the two Anys.

When small object optimization is enabled, swap only has no-throw guarantee when both (*this and other) objects are allocated on the heap.

Definition at line 197 of file Any.h.

◆ type()

const std::type_info & Poco::Any::type ( ) const
inline

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

Definition at line 259 of file Any.h.

Friends And Related Symbol Documentation

◆ AnyCast [1/2]

template<typename ValueType >
ValueType AnyCast ( Any & operand)
friend

AnyCast operator used to extract a copy of the ValueType from an Any&.

Example Usage: MyType tmp = AnyCast<MyType>(anAny). Will throw a BadCastException if the cast fails. Do not use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& tmp = ... Some compilers will accept this code although a copy is returned. Use the RefAnyCast in these cases.

Definition at line 509 of file Any.h.

◆ AnyCast [2/2]

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

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

Example Usage: MyType* pTmp = AnyCast<MyType*>(pAny). Will return NULL if the cast fails, i.e. types don't match.

Definition at line 481 of file Any.h.

◆ RefAnyCast [1/2]

template<typename ValueType >
ValueType & RefAnyCast ( Any & operand)
friend

AnyCast operator used to return a reference to the internal data.

Example Usage: MyType& tmp = RefAnyCast<MyType>(anAny);

Definition at line 582 of file Any.h.

◆ RefAnyCast [2/2]

template<typename ValueType >
const ValueType & RefAnyCast ( const Any & operand)
friend

AnyCast operator used to return a const reference to the internal data.

Example Usage: const MyType& tmp = RefAnyCast<MyType>(anAny);

Definition at line 557 of file Any.h.

◆ UnsafeAnyCast

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

The "unsafe" versions of AnyCast are not part of the public interface and may be removed at any time. They are required where we know what type is stored in the any and can't use typeid() comparison, e.g., when our types may travel across different shared libraries.

Definition at line 607 of file Any.h.

Member Data Documentation

◆ _valueHolder

Placeholder<ValueHolder> Poco::Any::_valueHolder
private

Definition at line 344 of file Any.h.


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