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

Stack of BSONParserStackItem for storing the BSONObjectParser parse context. More...

#include <BSONObjectParser.hpp>

Details:

Stack of BSONParserStackItem for storing the BSONObjectParser parse context.

Stores the current state of the parsed BSON objects in a FILO data structure.

Note
"TOS" == "Top Of Stack"
"FILO" == "First-In-Last-Out"

Definition at line 237 of file BSONObjectParser.hpp.

Collaboration diagram for mongotype::BSONParserStack:

Public Member Functions

int depth () const
 
const BSONParserStackItemitem (int index) const
 
const BSONParserStackItemtop () const
 Return the TOS item, leaving it in place. More...
 
void push (const BSONObj &object, const string &key=string(), int elementIndex=0, int elementCount=1, int arrayIndex=-1, int arrayCount=0)
 Wrap the mongo::BSONObj object in a dynamically allocated BSONParserStackItem and push the resultant BSONParserStackItem to the stack. More...
 
void push (BSONParserStackItem::ItemType type, const BSONElement &element, const string &key=string(), int elementIndex=0, int elementCount=1, int arrayIndex=-1, int arrayCount=0)
 Wrap the mongo::BSONElement element/array in a dynamically allocated BSONParserStackItem and push the resultant BSONParserStackItem to the stack. More...
 
void drop ()
 Drop the TOS. More...
 
string toString () const
 

Protected Member Functions

const BSONParserStackItempop ()
 Pop the TOS item. More...
 
void push (const BSONParserStackItem *item)
 Push the item. More...
 

Private Types

typedef std::deque
< std::unique_ptr< const
BSONParserStackItem > > 
Stack
 

Private Member Functions

void throwCount (int count) const
 

Private Attributes

Stack stack
 

Member Typedef Documentation

typedef std::deque<std::unique_ptr<const BSONParserStackItem> > mongotype::BSONParserStack::Stack
private

Definition at line 238 of file BSONObjectParser.hpp.

Member Function Documentation

int mongotype::BSONParserStack::depth ( ) const
inline
void mongotype::BSONParserStack::drop ( )
inline

Drop the TOS.

Note
TOS item is destroyed.

Definition at line 340 of file BSONObjectParser.hpp.

References pop().

Referenced by mongotype::BSONObjectParser::parseElementRecursive(), and mongotype::BSONObjectParser::parseObjectRecursive().

Here is the call graph for this function:

Here is the caller graph for this function:

const BSONParserStackItem& mongotype::BSONParserStack::item ( int  index) const
inline
Parameters
[in]indexZero based index of the stack item where zero is the first item pushed. If negative the items are referenced from the top of the stack, ie.:
  • -1 item at top of stack.
  • -2 1st item below top of stack.
  • -3 2ed item below top of stack.
  • etc...
Returns
The pointer to the read-only stack item.
Exceptions
std::logic_errorOn stack underflow.
Note
Item ownership unaffected.

Definition at line 287 of file BSONObjectParser.hpp.

References depth(), stack, and throwCount().

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

Here is the call graph for this function:

Here is the caller graph for this function:

const BSONParserStackItem* mongotype::BSONParserStack::pop ( )
inlineprotected

Pop the TOS item.

Returns
The pointer to the read-only stack item.
Exceptions
std::logic_errorOn stack underflow.
Note
Releases item ownership to caller, i.e., the called is now responsible for freeing the returned item.

Definition at line 260 of file BSONObjectParser.hpp.

References stack, and throwCount().

Referenced by drop().

Here is the call graph for this function:

Here is the caller graph for this function:

void mongotype::BSONParserStack::push ( const BSONParserStackItem item)
inlineprotected

Push the item.

Parameters
[in]itemThe reference to the item to be stored on the stack.
Note
Takes item ownership from caller, i.e., if not first popped the contained item(s) will be destroyed and freed when the BSONParserStack instance is destroyed .

Definition at line 272 of file BSONObjectParser.hpp.

References stack.

Referenced by mongotype::BSONObjectParser::parseElementRecursive(), mongotype::BSONObjectParser::parseObjectRecursive(), and push().

Here is the caller graph for this function:

void mongotype::BSONParserStack::push ( const BSONObj &  object,
const string &  key = string(),
int  elementIndex = 0,
int  elementCount = 1,
int  arrayIndex = -1,
int  arrayCount = 0 
)
inline

Wrap the mongo::BSONObj object in a dynamically allocated BSONParserStackItem and push the resultant BSONParserStackItem to the stack.

Parameters
[in]objectThe reference to the BSON object to be encapsulated in a BSONParserStackItem object and pushed on the stack.
[in]keyThe BSON key string of the contained mongo::BSONObj.
[in]elementIndexThe element index of the contained mongo::BSONObj See BSONParserStackItem::elementIndex.
[in]elementCountThe element count. See BSONParserStackItem::elementCount.
[in]arrayIndexThe array index of the contained mongo::BSONObj See BSONParserStackItem::arrayIndex.
[in]arrayCountThe array count. See BSONParserStackItem::arrayCount.
See Also
void BSONParserStack::push(const BSONParserStackItem* item)

Definition at line 317 of file BSONObjectParser.hpp.

References push().

Here is the call graph for this function:

void mongotype::BSONParserStack::push ( BSONParserStackItem::ItemType  type,
const BSONElement &  element,
const string &  key = string(),
int  elementIndex = 0,
int  elementCount = 1,
int  arrayIndex = -1,
int  arrayCount = 0 
)
inline

Wrap the mongo::BSONElement element/array in a dynamically allocated BSONParserStackItem and push the resultant BSONParserStackItem to the stack.

Parameters
[in]typeThe ItemType of this element. For valid values see BSONParserStackItem::BSONParserStackItem(ItemType ptype, const BSONElement* element, const string& pkey, int pelementIndex, int pelementCount, int parrayIndex, int parrayCount).
[in]elementThe reference to the BSON element to be encapsulated in a BSONParserStackItem object and pushed on the stack.
[in]keyThe BSON key string of the contained mongo::BSONObj.
[in]elementIndexThe element index of the contained mongo::BSONObj See BSONParserStackItem::elementIndex.
[in]elementCountThe element count. See BSONParserStackItem::elementCount.
[in]arrayIndexThe array index of the contained mongo::BSONObj See BSONParserStackItem::arrayIndex.
[in]arrayCountThe array count. See BSONParserStackItem::arrayCount.
See Also
void BSONParserStack::push(const BSONParserStackItem* item)

Definition at line 332 of file BSONObjectParser.hpp.

References push().

Here is the call graph for this function:

void mongotype::BSONParserStack::throwCount ( int  count) const
inlineprivate

Definition at line 246 of file BSONObjectParser.hpp.

References depth().

Referenced by item(), and pop().

Here is the call graph for this function:

Here is the caller graph for this function:

const BSONParserStackItem& mongotype::BSONParserStack::top ( ) const
inline

Return the TOS item, leaving it in place.

Returns
The pointer to the read-only stack item.
Exceptions
std::logic_errorOn stack underflow.
Note
Item ownership unaffected.

Definition at line 303 of file BSONObjectParser.hpp.

References depth(), and item().

Referenced by mongotype::JSONDump::emitComma(), mongotype::JSONDump::emitKey(), mongotype::BSONDotNotationDump::onArrayStart(), mongotype::BSONObjectTypeDump::onArrayStart(), mongotype::BSONDotNotationDump::onElement(), mongotype::BSONObjectTypeDump::onElement(), mongotype::JSONDump::onElement(), mongotype::BSONDotNotationDump::onObjectEnd(), mongotype::BSONDotNotationDump::onObjectStart(), and mongotype::BSONObjectTypeDump::onObjectStart().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 344 of file BSONObjectParser.hpp.

References depth(), item(), and mongotype::BSONParserStackItem::toString().

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

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

Stack mongotype::BSONParserStack::stack
private

Definition at line 240 of file BSONObjectParser.hpp.

Referenced by depth(), item(), pop(), and push().


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