remark defaults via doxygen snippet
authorChristopher Dunn <cdunn2001@gmail.com>
Tue, 10 Feb 2015 00:16:24 +0000 (18:16 -0600)
committerChristopher Dunn <cdunn2001@gmail.com>
Tue, 10 Feb 2015 00:16:24 +0000 (18:16 -0600)
doc/jsoncpp.dox
include/json/reader.h
include/json/writer.h
src/lib_json/json_reader.cpp
src/lib_json/json_writer.cpp

index ed18809..563590c 100644 (file)
@@ -103,6 +103,22 @@ std::string errs;
 bool ok = Json::parseFromStream(rbuilder, std::cin, &root, &errs);
 \endcode
 
+Yes, compile-time configuration-checking would be helpful,
+but `Json::Value` lets you
+write and read the builder configuration, which is better! In other words,
+you can configure your JSON parser using JSON.
+
+CharReaders and StreamWriters are not thread-safe, but they are re-usable.
+\code
+Json::CharReaderBuilder rbuilder;
+cfg >> rbuilder.settings_;
+std::unique_ptr<Json::CharReader> const reader(rbuilder.newCharReader());
+reader->parse(start, stop, &value1, &errs);
+// ...
+reader->parse(start, stop, &value2, &errs);
+// etc.
+\endcode
+
 \section _pbuild Build instructions
 The build instructions are located in the file 
 <a HREF="https://github.com/open-source-parsers/jsoncpp/blob/master/README.md">README.md</a> in the top-directory of the project.
@@ -137,5 +153,7 @@ and recognized in your jurisdiction.
 
 \author Baptiste Lepilleur <blep@users.sourceforge.net> (originator)
 \version \include version
+We make strong guarantees about binary-compatibility, consistent with
+<a href="http://apr.apache.org/versioning.html">the Apache versioning scheme</a>.
 \sa version.h
 */
index 2736931..eb4ef97 100644 (file)
@@ -296,12 +296,14 @@ public:
   // Note: We use a Json::Value so that we can add data-members to this class
   // without a major version bump.
   /** Configuration of this builder.
+    These are case-sensitive.
     Available settings (case-sensitive):
     - "collectComments": false or true (default=true)
     - TODO: other features ...
-    But don't trust these docs. You can examine 'settings_` yourself
+    You can examine 'settings_` yourself
     to see the defaults. You can also write and read them just like any
     JSON Value.
+    \sa setDefaults(Json::Value*)
     */
   Json::Value settings_;
 
@@ -316,8 +318,16 @@ public:
   bool validate(Json::Value* invalid) const;
   /** Called by ctor, but you can use this to reset settings_.
    * \pre 'settings' != NULL (but Json::null is fine)
+   * \remark Defaults:
+   * \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
    */
   static void setDefaults(Json::Value* settings);
+  /** Same as old Features::strictMode().
+   * \pre 'settings' != NULL (but Json::null is fine)
+   * \remark Defaults:
+   * \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
+   */
+  static void strictMode(Json::Value* settings);
 };
 
 /** Consume entire stream and use its begin/end.
index 39f8cdc..2e074c1 100644 (file)
@@ -121,6 +121,8 @@ public:
   bool validate(Json::Value* invalid) const;
   /** Called by ctor, but you can use this to reset settings_.
    * \pre 'settings' != NULL (but Json::null is fine)
+   * \remark Defaults:
+   * \snippet src/lib_json/json_writer.cpp StreamWriterBuilderDefaults
    */
   static void setDefaults(Json::Value* settings);
 };
index 82c0a23..4a3ffda 100644 (file)
@@ -952,9 +952,25 @@ bool CharReaderBuilder::validate(Json::Value* invalid) const
   return valid;
 }
 // static
+void CharReaderBuilder::strictMode(Json::Value* settings)
+{
+//! [CharReaderBuilderStrictMode]
+  (*settings)["allowComments"] = false;
+  (*settings)["strictRoot"] = true;
+  (*settings)["allowDroppedNullPlaceholders"] = false;
+  (*settings)["allowNumericKeys"] = false;
+//! [CharReaderBuilderStrictMode]
+}
+// static
 void CharReaderBuilder::setDefaults(Json::Value* settings)
 {
+//! [CharReaderBuilderDefaults]
   (*settings)["collectComments"] = true;
+  (*settings)["allowComments"] = true;
+  (*settings)["strictRoot"] = false;
+  (*settings)["allowDroppedNullPlaceholders"] = false;
+  (*settings)["allowNumericKeys"] = false;
+//! [CharReaderBuilderDefaults]
 }
 
 //////////////////////////////////
index d0eadf5..bc9401b 100644 (file)
@@ -1008,8 +1008,10 @@ bool StreamWriterBuilder::validate(Json::Value* invalid) const
 // static
 void StreamWriterBuilder::setDefaults(Json::Value* settings)
 {
+  //! [StreamWriterBuilderDefaults]
   (*settings)["commentStyle"] = "All";
   (*settings)["indentation"] = "\t";
+  //! [StreamWriterBuilderDefaults]
 }
 
 /*