Poco::FastInfoset

template < class T >

class Vocabulary

Library: FastInfoset
Package: FastInfoset
Header: Poco/FastInfoset/Vocabulary.h

Description

A Vocabulary allows to map values to indices and vice versa. New values are automatically enqueued and assigned an index.

Member Summary

Member Functions: clone, exists, index, init, value

Types

DataVector

typedef std::vector < T > DataVector;

Constructors

Vocabulary inline

Vocabulary();

Creates the Vocabulary.

Destructor

~Vocabulary virtual inline

virtual ~Vocabulary();

Destroys the Vocabulary.

Member Functions

clone virtual

virtual Vocabulary * clone() const = 0;

Deep-copies the vocabulary

exists virtual

virtual Poco::UInt32 exists(
    const T & value,
    bool & valueExisted
) const = 0;

Returns the index for the given value. Sets valueExisted to false if the value did not exist and returns Utility::INVALIDINDEX

index virtual

virtual Poco::UInt32 index(
    const T & value,
    bool & valueExisted
) = 0;

Returns the index for the given value. Automatically appends the value and assigns it a new index if the value does not exist yet. Query valueExisted to find out if the value already existed.

init inline

void init(
    const DataVector & initialData
);

value virtual

virtual const T & value(
    Poco::UInt32 idx
) const = 0;

Returns the value for the given index. Throws an exception if the idx is out of range.