Poco::MongoDB

class Array

Library: MongoDB
Package: MongoDB
Header: Poco/MongoDB/Array.h

Description

This class represents a BSON Array.

Inheritance

Direct Base Classes: Document

All Base Classes: Document

Member Summary

Member Functions: add, get, isType, toString

Inherited Functions: add, addElement, addNewArray, addNewDocument, clear, elementNames, empty, exists, get, getInteger, isType, read, remove, size, toString, write

Types Aliases

Ptr

using Ptr = SharedPtr < Array >;

Constructors

Array

Array();

Creates an empty Array.

Destructor

~Array virtual

~Array() override;

Destroys the Array.

Member Functions

add inline

template < typename T > Document & add(
    T value
);

Creates an element with the name from the current pos and value and adds it to the array document.

The active document is returned to allow chaining of the add methods.

add inline

Document & add(
    const char * value
);

Creates an element with a name from the current pos and value and adds it to the array document.

The active document is returned to allow chaining of the add methods.

get inline

template < typename T > T get(
    std::size_t pos
) const;

Returns the element at the given index and tries to convert it to the template type. If the element is not found, a Poco::NotFoundException will be thrown. If the element cannot be converted a BadCastException will be thrown.

get inline

template < typename T > T get(
    std::size_t pos,
    const T & deflt
) const;

Returns the element at the given index and tries to convert it to the template type. If the element is not found, or has the wrong type, the deflt argument will be returned.

get

Element::Ptr get(
    std::size_t pos
) const;

Returns the element at the given index. An empty element will be returned if the element is not found.

isType inline

template < typename T > bool isType(
    std::size_t pos
) const;

Returns true if the type of the element equals the TypeId of ElementTrait, otherwise false.

toString virtual

std::string toString(
    int indent = 0
) const override;

Returns a string representation of the Array.