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

BSON -> JSON Dump. More...

#include <JSONDump.hpp>

Details:

BSON -> JSON Dump.

Provides an std::ostream comparable output operator for dumping a JSON representation of the given BSON object. JSONDump implements interface IBSONObjectVisitor and uses the BSON object parsing events to output the BSON object's JSON representation.

See Also
IBSONObjectVisitor, BSONObjectParser, IBSONRenderer

Definition at line 49 of file JSONDump.hpp.

Inheritance diagram for mongotype::JSONDump:
Collaboration diagram for mongotype::JSONDump:

Public Member Functions

 JSONDump (Parameters &pparams, const char *pindentStr=" ")
 Construct a BSON object dumper. More...
 
virtual ~JSONDump ()
 
virtual void setOutputStream (std::ostream &os)
 
virtual void begin (const char *prefix)
 
virtual void end (const char *suffix)
 
virtual void render (const BSONObj &object, int docIndex, int docCount)
 
- Public Member Functions inherited from mongotype::IBSONRenderer
virtual ~IBSONRenderer ()
 

Protected Member Functions

virtual void onParseStart ()
 Parser Construction Event. More...
 
virtual void onParseEnd ()
 Parser Destruction Event. More...
 
virtual void onObjectStart (const BSONParserStack &stack)
 BSON Object Precursor Event. More...
 
virtual void onObjectEnd (const BSONParserStack &stack)
 BSON Object Successor Event. More...
 
virtual void onArrayStart (const BSONParserStack &stack)
 BSON Array Precursor Event. More...
 
virtual void onArrayEnd (const BSONParserStack &stack)
 BSON Array Successor Event. More...
 
virtual void onElement (const BSONParserStack &stack)
 BSON Element Event. More...
 
- Protected Member Functions inherited from mongotype::IBSONObjectVisitor
virtual ~IBSONObjectVisitor ()
 

Private Member Functions

void tstr (const char *token)
 
void tstr (string &token)
 
void istr (const char *token, int level)
 
void istr (string &token, int level)
 
void emitComma (const BSONParserStack &stack)
 
void emitKey (const BSONParserStack &stack)
 
void nextLine (const BSONParserStack &stack)
 

Private Attributes

Parametersparams
 
string indentStr
 
function< ostream &()> getOStream
 

Constructor & Destructor Documentation

mongotype::JSONDump::JSONDump ( Parameters pparams,
const char *  pindentStr = " " 
)
inline

Construct a BSON object dumper.

Parameters
[in]pparamsThe command line parameters object.
[in]pindentStrThe string used to indent the text output. The indent text is prepended to the output lines once for each indent level.

Definition at line 166 of file JSONDump.hpp.

virtual mongotype::JSONDump::~JSONDump ( )
inlinevirtual

Definition at line 169 of file JSONDump.hpp.

Member Function Documentation

virtual void mongotype::JSONDump::begin ( const char *  prefix)
inlinevirtual

Implements mongotype::IBSONRenderer.

Definition at line 181 of file JSONDump.hpp.

References tstr().

Here is the call graph for this function:

void mongotype::JSONDump::emitComma ( const BSONParserStack stack)
inlineprivate
void mongotype::JSONDump::emitKey ( const BSONParserStack stack)
inlineprivate

Definition at line 99 of file JSONDump.hpp.

References mongotype::BSONParserStack::depth(), mongotype::BSONParserStackItem::getKey(), mongotype::BSONParserStackItem::getType(), istr(), mongotype::BSONParserStack::item(), and mongotype::BSONParserStack::top().

Referenced by nextLine().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void mongotype::JSONDump::end ( const char *  suffix)
inlinevirtual

Implements mongotype::IBSONRenderer.

Definition at line 188 of file JSONDump.hpp.

References tstr().

Here is the call graph for this function:

void mongotype::JSONDump::istr ( const char *  token,
int  level 
)
inlineprivate

Definition at line 69 of file JSONDump.hpp.

References indentStr, and tstr().

Referenced by emitKey(), istr(), onArrayEnd(), and onObjectEnd().

Here is the call graph for this function:

Here is the caller graph for this function:

void mongotype::JSONDump::istr ( string &  token,
int  level 
)
inlineprivate

Definition at line 80 of file JSONDump.hpp.

References istr().

Here is the call graph for this function:

void mongotype::JSONDump::nextLine ( const BSONParserStack stack)
inlineprivate

Emit a comma and/or object label based on output state.

Definition at line 118 of file JSONDump.hpp.

References emitComma(), emitKey(), mongotype::Parameters::isStackDebug(), params, mongotype::BSONParserStack::toString(), and tstr().

Referenced by onArrayStart(), onElement(), and onObjectStart().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void mongotype::JSONDump::onArrayEnd ( const BSONParserStack stack)
inlineprotectedvirtual

BSON Array Successor Event.

Parameters
[in]stackThe BSONParserStack object containing the current parse context.

Invoked once per each non-terminal BSON array after parsing the contained BSON elements.

Implements mongotype::IBSONObjectVisitor.

Definition at line 148 of file JSONDump.hpp.

References mongotype::BSONParserStack::depth(), and istr().

Here is the call graph for this function:

virtual void mongotype::JSONDump::onArrayStart ( const BSONParserStack stack)
inlineprotectedvirtual

BSON Array Precursor Event.

Parameters
[in]stackThe BSONParserStack object containing the current parse context.

Invoked once per each non-terminal BSON array before parsing the contained BSON elements.

Implements mongotype::IBSONObjectVisitor.

Definition at line 143 of file JSONDump.hpp.

References nextLine(), and tstr().

Here is the call graph for this function:

virtual void mongotype::JSONDump::onElement ( const BSONParserStack stack)
inlineprotectedvirtual

BSON Element Event.

Parameters
[in]stackThe BSONParserStack object containing the current parse context.

Invoked once per each terminal BSON element that is not a BSON object or a BSON array.

Implements mongotype::IBSONObjectVisitor.

Definition at line 152 of file JSONDump.hpp.

References mongotype::BSONParserStackItem::getElement(), nextLine(), mongotype::BSONParserStack::top(), and tstr().

Here is the call graph for this function:

virtual void mongotype::JSONDump::onObjectEnd ( const BSONParserStack stack)
inlineprotectedvirtual

BSON Object Successor Event.

Parameters
[in]stackThe BSONParserStack object containing the current parse context.

Invoked once per each non-terminal BSON object after parsing the contained BSON elements.

Implements mongotype::IBSONObjectVisitor.

Definition at line 139 of file JSONDump.hpp.

References mongotype::BSONParserStack::depth(), and istr().

Here is the call graph for this function:

virtual void mongotype::JSONDump::onObjectStart ( const BSONParserStack stack)
inlineprotectedvirtual

BSON Object Precursor Event.

Parameters
[in]stackThe BSONParserStack object containing the current parse context.

Invoked once per each non-terminal BSON object before parsing the contained BSON elements.

Implements mongotype::IBSONObjectVisitor.

Definition at line 134 of file JSONDump.hpp.

References nextLine(), and tstr().

Here is the call graph for this function:

virtual void mongotype::JSONDump::onParseEnd ( )
inlineprotectedvirtual

Parser Destruction Event.

Invoked once each parse after all other events. Used to destroy the parse state.

Implements mongotype::IBSONObjectVisitor.

Definition at line 131 of file JSONDump.hpp.

virtual void mongotype::JSONDump::onParseStart ( )
inlineprotectedvirtual

Parser Construction Event.

Invoked once each parse before all other events. Used to construct the parse state.

Implements mongotype::IBSONObjectVisitor.

Definition at line 128 of file JSONDump.hpp.

virtual void mongotype::JSONDump::render ( const BSONObj &  object,
int  docIndex,
int  docCount 
)
inlinevirtual

Implements mongotype::IBSONRenderer.

Definition at line 196 of file JSONDump.hpp.

References mongotype::BSONObjectParser::parse(), and tstr().

Here is the call graph for this function:

virtual void mongotype::JSONDump::setOutputStream ( std::ostream &  os)
inlinevirtual

Implements mongotype::IBSONRenderer.

Definition at line 174 of file JSONDump.hpp.

References getOStream.

void mongotype::JSONDump::tstr ( const char *  token)
inlineprivate

Definition at line 60 of file JSONDump.hpp.

References getOStream, mongotype::Parameters::isDebug(), and params.

Referenced by begin(), emitComma(), end(), istr(), nextLine(), onArrayStart(), onElement(), onObjectStart(), render(), and tstr().

Here is the call graph for this function:

Here is the caller graph for this function:

void mongotype::JSONDump::tstr ( string &  token)
inlineprivate

Definition at line 65 of file JSONDump.hpp.

References tstr().

Here is the call graph for this function:

Member Data Documentation

function<ostream&()> mongotype::JSONDump::getOStream
private

Definition at line 54 of file JSONDump.hpp.

Referenced by setOutputStream(), and tstr().

string mongotype::JSONDump::indentStr
private

Definition at line 52 of file JSONDump.hpp.

Referenced by istr().

Parameters& mongotype::JSONDump::params
private

Definition at line 51 of file JSONDump.hpp.

Referenced by nextLine(), and tstr().


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