Poco

class Any

Library: Foundation
Package: Core
Header: Poco/Any.h

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.

Member Summary

Member Functions: empty, operator =, swap, type

Constructors

Any inline

Any();

Creates an empty any type.

Any inline

template < typename ValueType > Any(
    const ValueType & value
);

Creates an any which stores the init parameter inside.

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

Any inline

Any(
    const Any & other
);

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

Destructor

~Any inline

~Any();

Member Functions

empty inline

bool empty() const;

returns true if the Any is empty

operator = inline

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

Assignment operator for all types != Any.

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

operator = inline

Any & operator = (
    const Any & rhs
);

Assignment operator for Any.

swap inline

Any & swap(
    Any & rhs
);

Swaps the content of the two Anys.

type inline

const std::type_info & 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 AnyCast/RefAnyCast.