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

The BSON Parser. More...

#include <BSONObjectParser.hpp>

Details:

The BSON Parser.

This class is is used to tear apart a given BSON object and process its data content.

It is intended to be fully extensible as the internal methods are all declared protected.

Usage:

See Also
BSONObjectParser::parse, IBSONObjectVisitor, BSONParserStack, BSONParserStackItem

Definition at line 447 of file BSONObjectParser.hpp.

Collaboration diagram for mongotype::BSONObjectParser:

Public Member Functions

 BSONObjectParser (IBSONObjectVisitor &pvisitor)
 Construct a BSON Object parser. More...
 
virtual ~BSONObjectParser ()
 
virtual void parse (const BSONObj &object)
 Parse a BSON Object (BSONObj) More...
 

Protected Member Functions

virtual void parseElementRecursive (const BSONElement &element, string &key, int elementIndex=0, int elementCount=1, int arrayIndex=-1, int arrayCount=0)
 Recursively parse a BSONElement. More...
 
virtual void parseObjectRecursive (const BSONObj &object, string &key, int elementIndex=0, int elementCount=1, int arrayIndex=-1, int arrayCount=0)
 Recursively parse a BSON Object. More...
 

Protected Attributes

IBSONObjectVisitorvisitor
 
BSONParserStack stack
 

Constructor & Destructor Documentation

mongotype::BSONObjectParser::BSONObjectParser ( IBSONObjectVisitor pvisitor)
inline

Construct a BSON Object parser.

Parameters
[in]pvisitorThe instance of the IBSONObjectVisitor visitor subclass that will receive the parse events.

Construct a parser and register the parsing event handler/visitor.

Definition at line 548 of file BSONObjectParser.hpp.

virtual mongotype::BSONObjectParser::~BSONObjectParser ( )
inlinevirtual

Definition at line 549 of file BSONObjectParser.hpp.

Member Function Documentation

virtual void mongotype::BSONObjectParser::parse ( const BSONObj &  object)
inlinevirtual

Parse a BSON Object (BSONObj)

Parameters
[in]objectThe BSON object to parse.

Parse the given BSON object and invoke the event handlers of the IBSONObjectVisitor visitor subclass registered by constructor BSONObjectParser::BSONObjectParser(IBSONObjectVisitor& pvisitor).

Definition at line 560 of file BSONObjectParser.hpp.

References mongotype::IBSONObjectVisitor::onParseEnd(), mongotype::IBSONObjectVisitor::onParseStart(), parseObjectRecursive(), and visitor.

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

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void mongotype::BSONObjectParser::parseElementRecursive ( const BSONElement &  element,
string &  key,
int  elementIndex = 0,
int  elementCount = 1,
int  arrayIndex = -1,
int  arrayCount = 0 
)
inlineprotectedvirtual

Recursively parse a BSONElement.

Parameters
[in]elementThe element to recursively process.
[in]keyThe BSON key string of the 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.
  • If it is a BSON object (BSONObj) parse it via indirect recursion by calling parseObjectRecursive().
  • If it is a BSON array iterate through the contained BSONElement(s) and process via direct recursion by calling parseElementRecursive().
  • If it is neither an object nor an array simply invoke the visitors onElement virtual method to process the BSONElement.

Definition at line 472 of file BSONObjectParser.hpp.

References mongotype::BSONParserStack::drop(), mongotype::IBSONObjectVisitor::onArrayEnd(), mongotype::IBSONObjectVisitor::onArrayStart(), mongotype::IBSONObjectVisitor::onElement(), parseObjectRecursive(), mongotype::BSONParserStack::push(), stack, and visitor.

Referenced by parseObjectRecursive().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void mongotype::BSONObjectParser::parseObjectRecursive ( const BSONObj &  object,
string &  key,
int  elementIndex = 0,
int  elementCount = 1,
int  arrayIndex = -1,
int  arrayCount = 0 
)
inlineprotectedvirtual

Recursively parse a BSON Object.

Parameters
[in]objectThe BSON object to process.
[in]keyThe BSON key string of the 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.
  • arrayIndex == -1 if the element is not contained in an array.
  • arrayIndex >= 0 if the element is contained within an array.

Iterate through all the BSONElement(s) contained in the BSONObj and process them via indirect recursion by calling parseElementRecursive().

Definition at line 523 of file BSONObjectParser.hpp.

References mongotype::BSONParserStack::drop(), mongotype::IBSONObjectVisitor::onObjectEnd(), mongotype::IBSONObjectVisitor::onObjectStart(), parseElementRecursive(), mongotype::BSONParserStack::push(), stack, and visitor.

Referenced by parse(), and parseElementRecursive().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

BSONParserStack mongotype::BSONObjectParser::stack
protected

Definition at line 454 of file BSONObjectParser.hpp.

Referenced by parseElementRecursive(), and parseObjectRecursive().

IBSONObjectVisitor& mongotype::BSONObjectParser::visitor
protected

Visitor implementation that receives the parse events.

Definition at line 453 of file BSONObjectParser.hpp.

Referenced by parse(), parseElementRecursive(), and parseObjectRecursive().


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