MongoType
MongoDB Collection Data Dump with BSON Types
|
BSON -> JSON Dump. More...
#include <JSONDump.hpp>
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.
Definition at line 49 of file JSONDump.hpp.
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) |
![]() | |
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... | |
![]() | |
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 | |
Parameters & | params |
string | indentStr |
function< ostream &()> | getOStream |
|
inline |
Construct a BSON object dumper.
[in] | pparams | The command line parameters object. |
[in] | pindentStr | The 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.
|
inlinevirtual |
Definition at line 169 of file JSONDump.hpp.
|
inlinevirtual |
Implements mongotype::IBSONRenderer.
Definition at line 181 of file JSONDump.hpp.
References tstr().
|
inlineprivate |
Emit a comma.
Definition at line 87 of file JSONDump.hpp.
References mongotype::BSONParserStack::depth(), mongotype::BSONParserStackItem::getArrayIndex(), mongotype::BSONParserStackItem::getElementIndex(), mongotype::BSONParserStackItem::getType(), mongotype::BSONParserStack::item(), mongotype::BSONParserStack::top(), and tstr().
Referenced by nextLine().
|
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().
|
inlinevirtual |
Implements mongotype::IBSONRenderer.
Definition at line 188 of file JSONDump.hpp.
References tstr().
|
inlineprivate |
Definition at line 69 of file JSONDump.hpp.
References indentStr, and tstr().
Referenced by emitKey(), istr(), onArrayEnd(), and onObjectEnd().
|
inlineprivate |
Definition at line 80 of file JSONDump.hpp.
References istr().
|
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().
|
inlineprotectedvirtual |
BSON Array Successor Event.
[in] | stack | The 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().
|
inlineprotectedvirtual |
BSON Array Precursor Event.
[in] | stack | The 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().
|
inlineprotectedvirtual |
BSON Element Event.
[in] | stack | The 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().
|
inlineprotectedvirtual |
BSON Object Successor Event.
[in] | stack | The 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().
|
inlineprotectedvirtual |
BSON Object Precursor Event.
[in] | stack | The 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().
|
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.
|
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.
|
inlinevirtual |
Implements mongotype::IBSONRenderer.
Definition at line 196 of file JSONDump.hpp.
References mongotype::BSONObjectParser::parse(), and tstr().
|
inlinevirtual |
Implements mongotype::IBSONRenderer.
Definition at line 174 of file JSONDump.hpp.
References getOStream.
|
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().
|
inlineprivate |
Definition at line 65 of file JSONDump.hpp.
References tstr().
|
private |
Definition at line 54 of file JSONDump.hpp.
Referenced by setOutputStream(), and tstr().
|
private |
Definition at line 52 of file JSONDump.hpp.
Referenced by istr().
|
private |
Definition at line 51 of file JSONDump.hpp.
Referenced by nextLine(), and tstr().