# 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: get, isType, toString

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

## Types

### Ptr

typedef SharedPtr < Array > Ptr;

## Constructors

### Array

Array();

Creates an empty Array.

## Destructor

### ~Array

virtual ~Array();

Destroys the Array.

## Member Functions

### get

template < typename T > T get(
int 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

template < typename T > T get(
int 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(
int pos
) const;

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

### isType

template < typename T > bool isType(
int pos
) const;

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

### toString

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

Returns a string representation of the Array.

See also: Poco::MongoDB::Document::toString()