MongoType
MongoDB Collection Data Dump with BSON Types
|
MongoType is a command line utility designed to dump out the contents of a MongoDB collection with the associated BSON data types.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see http://www.gnu.org/licenses/ .
The main() functionality is relatively simple:
The mongotype namespace is where the majority of the code resides to avoid conflicts.
This is a catch-all function that:
The mongotype::Parameters class uses the boost::program_options library to do the command line parsing, supplying initialization, validation overload functions, and getter access functions. While technically not an immutable class it functions as such in MongoType once command line parsing is completed.
All the concrete style implementation classes implement mongotype::IBSONRenderer to provide a polymorphic begin-render-end rendering sequence to create the output. This interface allows the style classes to customize the output but present a common interface .aka. API.
All the concrete style implementation classes also implement mongotype::IBSONObjectVisitor to receive the events that are generated when a mongo::BSONObj object is parsed. This interface allows the style implementation classes to parse BSON objects via the common implementation class mongotype::BSONObjectParser.
The mechanics of decomposing BSON objects is encapsulated in the mongotype::BSONObjectParser class which relies on mongotype::IBSONObjectVisitor implementors described below. It supplies the instance method mongotype::BSONObjectParser::parse as the entry point to initiate parsing of a mongo::BSONObj object.
The following classes implement mongotype::IBSONRenderer and mongotype::IBSONObjectVisitor as described above: