template class Poco::Dynamic::VarHolderImpl

Overview

Template based implementation of a VarHolder. More…

#include <Any.h>

template <typename T>
class VarHolderImpl: public Poco::Dynamic::VarHolder
{
public:
    // construction

    VarHolderImpl(const T& val);

    // methods

    virtual
    const std::type_info&
    type() const;

    virtual
    VarHolder*
    clone(Placeholder<VarHolder>* pHolder = 0) const;

    const T&
    value() const;
};

Inherited Members

public:
    // typedefs

    typedef Var ArrayValueType;

    // methods

    virtual
    VarHolder*
    clone(Placeholder<VarHolder>* pHolder = 0) const = 0;

    virtual
    const std::type_info&
    type() const = 0;

    virtual
    void
    convert(Int8& val) const;

    virtual
    void
    convert(Int16& val) const;

    virtual
    void
    convert(Int32& val) const;

    virtual
    void
    convert(Int64& val) const;

    virtual
    void
    convert(UInt8& val) const;

    virtual
    void
    convert(UInt16& val) const;

    virtual
    void
    convert(UInt32& val) const;

    virtual
    void
    convert(UInt64& val) const;

    virtual
    void
    convert(DateTime& val) const;

    virtual
    void
    convert(LocalDateTime& val) const;

    virtual
    void
    convert(Timestamp& val) const;

    void
    convert(long& val) const;

    void
    convert(unsigned long& val) const;

    virtual
    void
    convert(bool& val) const;

    virtual
    void
    convert(float& val) const;

    virtual
    void
    convert(double& val) const;

    virtual
    void
    convert(char& val) const;

    virtual
    void
    convert(std::string& val) const;

    virtual
    void
    convert(Poco::UTF16String& val) const;

    virtual
    bool
    isArray() const;

    virtual
    bool
    isVector() const;

    virtual
    bool
    isList() const;

    virtual
    bool
    isDeque() const;

    virtual
    bool
    isStruct() const;

    virtual
    bool
    isInteger() const;

    virtual
    bool
    isSigned() const;

    virtual
    bool
    isNumeric() const;

    virtual
    bool
    isBoolean() const;

    virtual
    bool
    isString() const;

    virtual
    std::size_t
    size() const;

protected:
    // methods

    template <typename T>
    VarHolder*
    cloneHolder(
        Placeholder<VarHolder>* pVarHolder,
        const T& val
        ) const;

    template <
        typename F,
        typename T
        >
    void
    convertToSmaller(
        const F& from,
        T& to
        ) const;

    template <
        typename F,
        typename T
        >
    void
    convertToSmallerUnsigned(
        const F& from,
        T& to
        ) const;

    template <
        typename F,
        typename T
        >
    void
    convertSignedToUnsigned(
        const F& from,
        T& to
        ) const;

    template <
        typename F,
        typename T
        >
    void
    convertSignedFloatToUnsigned(
        const F& from,
        T& to
        ) const;

    template <
        typename F,
        typename T
        >
    void
    convertUnsignedToSigned(
        const F& from,
        T& to
        ) const;

Detailed Documentation

Template based implementation of a VarHolder.

This class provides type storage for user-defined types that do not have VarHolderImpl specialization.

The actual conversion work happens in the template specializations of this class.

VarHolderImpl throws following exceptions: BadCastException (if the requested conversion is not implemented) RangeException (if an attempt is made to assign a numeric value outside of the target min/max limits SyntaxException (if an attempt is made to convert a string containing non-numeric characters to number)

In order to support efficient direct extraction of the held value, all specializations must additionally implement a public member function:

const T& value() const

returning a const reference to the actual stored value.

Methods

virtual
const std::type_info&
type() const

Implementation must return the type information (typeid) for the stored content.

virtual
VarHolder*
clone(Placeholder<VarHolder>* pHolder = 0) const

Implementation must implement this function to deep-copy the VarHolder.

If small object optimization is enabled (i.e. if POCO_NO_SOO is not defined), VarHolder will be instantiated in-place if it’s size is smaller than POCO_SMALL_OBJECT_SIZE.