MongoType
MongoDB Collection Data Dump with BSON Types
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mongotype::BSONParserStackItem Class Reference

Container class for const references to mongo::BSONObj and mongo::BSONElement. More...

#include <BSONObjectParser.hpp>

Details:

Container class for const references to mongo::BSONObj and mongo::BSONElement.

This class wraps the tagged union BSONParserStackItem::Item to store the objects and elements.

Definition at line 51 of file BSONObjectParser.hpp.

Collaboration diagram for mongotype::BSONParserStackItem:

Classes

union  Item
 

Public Types

enum  ItemType { OBJECT, ARRAY, ELEMENT }
 

Public Member Functions

 BSONParserStackItem (const BSONObj *object, const string &pkey, int pelementIndex, int pelementCount, int parrayIndex, int parrayCount)
 
 BSONParserStackItem (ItemType ptype, const BSONElement *element, const string &pkey, int pelementIndex, int pelementCount, int parrayIndex, int parrayCount)
 
ItemType getType () const
 
const BSONObj & getObject () const
 
const BSONElement & getElement () const
 
const BSONElement & getArray () const
 
const string & getKey () const
 
int getElementIndex () const
 
int getElementCount () const
 
int getArrayIndex () const
 
int getArrayCount () const
 
string toString () const
 

Private Member Functions

void validate (ItemType t) const
 

Private Attributes

ItemType type
 
union
mongotype::BSONParserStackItem::Item 
item
 
const string & key
 
int elementIndex
 
int elementCount
 
int arrayIndex
 
int arrayCount
 

Member Enumeration Documentation

The BSON type of the contained object.

Enumerator
OBJECT 

The contained object is mongo::BSONObj.

ARRAY 

The contained object is mongo::BSONElement array.

ELEMENT 

The contained object is mongo::BSONElement scalar.

Definition at line 56 of file BSONObjectParser.hpp.

Constructor & Destructor Documentation

mongotype::BSONParserStackItem::BSONParserStackItem ( const BSONObj *  object,
const string &  pkey,
int  pelementIndex,
int  pelementCount,
int  parrayIndex,
int  parrayCount 
)
inline

Construct a BSONParserStackItem containing a pointer to a mongo::BSONObj. The ItemType is implicitly set to OBJECT.

Parameters
[in]objectThe pointer to the mongo::BSONObj.
[in]pkeyThe BSON key string of the contained mongo::BSONObj.
[in]pelementIndexThe element index of the contained mongo::BSONObj See elementIndex.
[in]pelementCountThe element count. See elementCount.
[in]parrayIndexThe array index of the contained mongo::BSONObj See arrayIndex.
[in]parrayCountThe array count. See arrayCount.

Definition at line 145 of file BSONObjectParser.hpp.

mongotype::BSONParserStackItem::BSONParserStackItem ( ItemType  ptype,
const BSONElement *  element,
const string &  pkey,
int  pelementIndex,
int  pelementCount,
int  parrayIndex,
int  parrayCount 
)
inline

Construct a BSONParserStackItem containing a pointer to a mongo::BSONElement.

Parameters
[in]ptypeThe ItemType of this element. The valid types are:
[in]elementThe pointer to the mongo::BSONElement.
[in]pkeyThe BSON key string of the contained mongo::BSONObj.
[in]pelementIndexThe element index of the contained mongo::BSONObj See elementIndex.
[in]pelementCountThe element count. See elementCount.
[in]parrayIndexThe array index of the contained mongo::BSONObj See arrayIndex.
[in]parrayCountThe array count. See arrayCount.

Definition at line 159 of file BSONObjectParser.hpp.

Member Function Documentation

const BSONElement& mongotype::BSONParserStackItem::getArray ( ) const
inline

Definition at line 176 of file BSONObjectParser.hpp.

References ARRAY, mongotype::BSONParserStackItem::Item::element, item, and validate().

Referenced by mongotype::BSONDotNotationDump::onArrayStart().

Here is the call graph for this function:

Here is the caller graph for this function:

int mongotype::BSONParserStackItem::getArrayCount ( ) const
inline

Definition at line 197 of file BSONObjectParser.hpp.

References arrayCount.

Referenced by mongotype::BSONObjectTypeDump::onArrayStart().

Here is the caller graph for this function:

int mongotype::BSONParserStackItem::getArrayIndex ( ) const
inline
const BSONElement& mongotype::BSONParserStackItem::getElement ( ) const
inline

Definition at line 171 of file BSONObjectParser.hpp.

References ELEMENT, mongotype::BSONParserStackItem::Item::element, item, and validate().

Referenced by mongotype::BSONDotNotationDump::onElement(), mongotype::BSONObjectTypeDump::onElement(), and mongotype::JSONDump::onElement().

Here is the call graph for this function:

Here is the caller graph for this function:

int mongotype::BSONParserStackItem::getElementCount ( ) const
inline

Definition at line 189 of file BSONObjectParser.hpp.

References elementCount.

int mongotype::BSONParserStackItem::getElementIndex ( ) const
inline

Definition at line 185 of file BSONObjectParser.hpp.

References elementIndex.

Referenced by mongotype::JSONDump::emitComma().

Here is the caller graph for this function:

const string& mongotype::BSONParserStackItem::getKey ( ) const
inline

Definition at line 181 of file BSONObjectParser.hpp.

References key.

Referenced by mongotype::JSONDump::emitKey().

Here is the caller graph for this function:

const BSONObj& mongotype::BSONParserStackItem::getObject ( ) const
inline

Definition at line 166 of file BSONObjectParser.hpp.

References item, OBJECT, mongotype::BSONParserStackItem::Item::object, and validate().

Here is the call graph for this function:

ItemType mongotype::BSONParserStackItem::getType ( ) const
inline

Definition at line 162 of file BSONObjectParser.hpp.

References type.

Referenced by mongotype::JSONDump::emitComma(), and mongotype::JSONDump::emitKey().

Here is the caller graph for this function:

string mongotype::BSONParserStackItem::toString ( ) const
inline

Definition at line 201 of file BSONObjectParser.hpp.

References ARRAY, arrayCount, arrayIndex, ELEMENT, elementCount, elementIndex, key, OBJECT, and type.

Referenced by mongotype::BSONParserStack::toString().

Here is the caller graph for this function:

void mongotype::BSONParserStackItem::validate ( ItemType  t) const
inlineprivate

Throw an error if the wrong type of fetch from the union occurs.

Parameters
tThe ItemType being fetched.
Exceptions
std::logic_errorThrown if the passed type does not match the stored type.

Definition at line 129 of file BSONObjectParser.hpp.

References OBJECT, and type.

Referenced by getArray(), getElement(), and getObject().

Here is the caller graph for this function:

Member Data Documentation

int mongotype::BSONParserStackItem::arrayCount
private

The count of all BSON element(s) within the containing BSON array, or 0 if the BSON element is not contained within a BSON array.

  • arrayCount == 0 if object is not contained in an array, or ...
  • arrayCount > 0 if object is contained within an array.

Definition at line 121 of file BSONObjectParser.hpp.

Referenced by getArrayCount(), and toString().

int mongotype::BSONParserStackItem::arrayIndex
private

The zero based index of BSON element within the containing BSON array, or -1 if the BSON element is not contained within a BSON array.

  • arrayIndex == -1 if object is not contained in an array, or ...
  • arrayIndex >= 0 if object is contained within an array.

Definition at line 114 of file BSONObjectParser.hpp.

Referenced by getArrayIndex(), and toString().

int mongotype::BSONParserStackItem::elementCount
private

The count of all the BSON object(s)/array(s)/element(s) within the parent object.

Definition at line 107 of file BSONObjectParser.hpp.

Referenced by getElementCount(), and toString().

int mongotype::BSONParserStackItem::elementIndex
private

The zero based index of the BSON object/array/element within the parent object.

Definition at line 102 of file BSONObjectParser.hpp.

Referenced by getElementIndex(), and toString().

union mongotype::BSONParserStackItem::Item mongotype::BSONParserStackItem::item
private

Referenced by getArray(), getElement(), and getObject().

const string& mongotype::BSONParserStackItem::key
private

Key name of the BSON object/array/element, or the empty string if this is the root object.

Definition at line 97 of file BSONObjectParser.hpp.

Referenced by getKey(), and toString().

ItemType mongotype::BSONParserStackItem::type
private

The contained BSON object''s type.

Definition at line 66 of file BSONObjectParser.hpp.

Referenced by getType(), toString(), and validate().


The documentation for this class was generated from the following file: