Modify code comments in write.h (#987)

* modify code comments in write.h

* update
This commit is contained in:
dota17 2019-09-17 01:40:35 +08:00 committed by Jordan Bayles
parent d622250c3e
commit abcd3f7b1f

View File

@ -27,17 +27,17 @@ namespace Json {
class Value; class Value;
/** /**
*
Usage: * Usage:
\code * \code
using namespace Json; * using namespace Json;
void writeToStdout(StreamWriter::Factory const& factory, Value const& value) { * void writeToStdout(StreamWriter::Factory const& factory, Value const& value) {
std::unique_ptr<StreamWriter> const writer( * std::unique_ptr<StreamWriter> const writer(
factory.newStreamWriter()); * factory.newStreamWriter());
writer->write(value, &std::cout); * writer->write(value, &std::cout);
std::cout << std::endl; // add lf and flush * std::cout << std::endl; // add lf and flush
} * }
\endcode * \endcode
*/ */
class JSON_API StreamWriter { class JSON_API StreamWriter {
protected: protected:
@ -45,12 +45,12 @@ protected:
public: public:
StreamWriter(); StreamWriter();
virtual ~StreamWriter(); virtual ~StreamWriter();
/** Write Value into document as configured in sub-class. /** Write Value into document as configured in sub-class.
Do not take ownership of sout, but maintain a reference during function. * Do not take ownership of sout, but maintain a reference during function.
\pre sout != NULL * \pre sout != NULL
\return zero on success (For now, we always return zero, so check the * \return zero on success (For now, we always return zero, so check the
stream instead.) \throw std::exception possibly, depending on configuration * stream instead.) \throw std::exception possibly, depending on configuration
*/ */
virtual int write(Value const& root, OStream* sout) = 0; virtual int write(Value const& root, OStream* sout) = 0;
/** \brief A simple abstract factory. /** \brief A simple abstract factory.
@ -73,48 +73,48 @@ String JSON_API writeString(StreamWriter::Factory const& factory,
/** \brief Build a StreamWriter implementation. /** \brief Build a StreamWriter implementation.
Usage: * Usage:
\code * \code
using namespace Json; * using namespace Json;
Value value = ...; * Value value = ...;
StreamWriterBuilder builder; * StreamWriterBuilder builder;
builder["commentStyle"] = "None"; * builder["commentStyle"] = "None";
builder["indentation"] = " "; // or whatever you like * builder["indentation"] = " "; // or whatever you like
std::unique_ptr<Json::StreamWriter> writer( * std::unique_ptr<Json::StreamWriter> writer(
builder.newStreamWriter()); * builder.newStreamWriter());
writer->write(value, &std::cout); * writer->write(value, &std::cout);
std::cout << std::endl; // add lf and flush * std::cout << std::endl; // add lf and flush
\endcode * \endcode
*/ */
class JSON_API StreamWriterBuilder : public StreamWriter::Factory { class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
public: public:
// Note: We use a Json::Value so that we can add data-members to this class // Note: We use a Json::Value so that we can add data-members to this class
// without a major version bump. // without a major version bump.
/** Configuration of this builder. /** Configuration of this builder.
Available settings (case-sensitive): * Available settings (case-sensitive):
- "commentStyle": "None" or "All" * - "commentStyle": "None" or "All"
- "indentation": "<anything>". * - "indentation": "<anything>".
- Setting this to an empty string also omits newline characters. * - Setting this to an empty string also omits newline characters.
- "enableYAMLCompatibility": false or true * - "enableYAMLCompatibility": false or true
- slightly change the whitespace around colons * - slightly change the whitespace around colons
- "dropNullPlaceholders": false or true * - "dropNullPlaceholders": false or true
- Drop the "null" string from the writer's output for nullValues. * - Drop the "null" string from the writer's output for nullValues.
Strictly speaking, this is not valid JSON. But when the output is being * Strictly speaking, this is not valid JSON. But when the output is being
fed to a browser's JavaScript, it makes for smaller output and the * fed to a browser's JavaScript, it makes for smaller output and the
browser can handle the output just fine. * browser can handle the output just fine.
- "useSpecialFloats": false or true * - "useSpecialFloats": false or true
- If true, outputs non-finite floating point values in the following way: * - If true, outputs non-finite floating point values in the following way:
NaN values as "NaN", positive infinity as "Infinity", and negative * NaN values as "NaN", positive infinity as "Infinity", and negative
infinity as "-Infinity". * infinity as "-Infinity".
- "precision": int * - "precision": int
- Number of precision digits for formatting of real values. * - Number of precision digits for formatting of real values.
- "precisionType": "significant"(default) or "decimal" * - "precisionType": "significant"(default) or "decimal"
- Type of precision for formatting of real values. * - Type of precision for formatting of real values.
You can examine 'settings_` yourself * You can examine 'settings_` yourself
to see the defaults. You can also write and read them just like any * to see the defaults. You can also write and read them just like any
JSON Value. * JSON Value.
\sa setDefaults() * \sa setDefaults()
*/ */
Json::Value settings_; Json::Value settings_;