Move old FastWriter stuff out of new Builder
diff --git a/doc/jsoncpp.dox b/doc/jsoncpp.dox
index 2c19664..2dcdbff 100644
--- a/doc/jsoncpp.dox
+++ b/doc/jsoncpp.dox
@@ -94,6 +94,9 @@
// If you like the defaults, you can insert directly into a stream.
std::cout << root;
+// If desired, remember to add a linefeed and flush.
+std::cout << std::endl;
+
// Of course, you can write to `std::ostringstream` if you prefer. Or
// use `writeString()` for convenience.
std::string document = Json::writeString( root, builder );
diff --git a/include/json/writer.h b/include/json/writer.h
index 25bc812..176876e 100644
--- a/include/json/writer.h
+++ b/include/json/writer.h
@@ -36,7 +36,7 @@
std::shared_ptr<StreamWriter> writer(
builder.newStreamWriter(&std::cout));
writer->write(value);
- std::cout.flush();
+ std::cout << std::endl; // add lf and flush
\endcode
*/
class JSON_API StreamWriter {
@@ -77,24 +77,6 @@
Default: "\t"
*/
Builder& withIndentation(std::string indentation);
- /** \brief Drop the "null" string from the writer's output for nullValues.
- * 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
- * browser can handle the output just fine.
- */
- Builder& withDropNullPlaceholders(bool v);
- /** \brief Do not add \n at end of document.
- * Normally, we add an extra newline, just because.
- */
- Builder& withOmitEndingLineFeed(bool v);
- /** \brief Add a space after ':'.
- * If indentation is non-empty, we surround colon with whitespace,
- * e.g. " : "
- * This will add back the trailing space when there is no indentation.
- * This seems dubious when the entire document is on a single line,
- * but we leave this here to repduce the behavior of the old `FastWriter`.
- */
- Builder& withEnableYAMLCompatibility(bool v);
/// Do not take ownership of sout, but maintain a reference.
StreamWriter* newStreamWriter(std::ostream* sout) const;
diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp
index a24b3f5..11c564b 100644
--- a/src/lib_json/json_writer.cpp
+++ b/src/lib_json/json_writer.cpp
@@ -963,25 +963,16 @@
typedef StreamWriter::CommentStyle CommentStyle;
CommentStyle cs_;
std::string indentation_;
- bool dropNullPlaceholders_;
- bool omitEndingLineFeed_;
- bool enableYAMLCompatibility_;
public:
StreamWriterBuilder();
virtual ~StreamWriterBuilder();
virtual void setCommentStyle(CommentStyle cs);
virtual void setIndentation(std::string indentation);
- virtual void setDropNullPlaceholders(bool v);
- virtual void setOmitEndingLineFeed(bool v);
- virtual void setEnableYAMLCompatibility(bool v);
virtual StreamWriter* newStreamWriter(std::ostream* sout) const;
};
StreamWriterBuilder::StreamWriterBuilder()
: cs_(CommentStyle::All)
, indentation_("\t")
- , dropNullPlaceholders_(false)
- , omitEndingLineFeed_(false)
- , enableYAMLCompatibility_(false)
{
}
StreamWriterBuilder::~StreamWriterBuilder()
@@ -996,36 +987,14 @@
indentation_ = v;
if (indentation_.empty()) cs_ = CommentStyle::None;
}
-void StreamWriterBuilder::setDropNullPlaceholders(bool v)
-{
- dropNullPlaceholders_ = v;
-}
-void StreamWriterBuilder::setOmitEndingLineFeed(bool v)
-{
- omitEndingLineFeed_ = v;
-}
-void StreamWriterBuilder::setEnableYAMLCompatibility(bool v)
-{
- enableYAMLCompatibility_ = v;
-}
StreamWriter* StreamWriterBuilder::newStreamWriter(std::ostream* stream) const
{
std::string colonSymbol = " : ";
if (indentation_.empty()) {
- if (enableYAMLCompatibility_) {
- colonSymbol = ": ";
- } else {
- colonSymbol = ":";
- }
+ colonSymbol = ":";
}
std::string nullSymbol = "null";
- if (dropNullPlaceholders_) {
- nullSymbol = "";
- }
- std::string endingLineFeedSymbol = "\n";
- if (omitEndingLineFeed_) {
- endingLineFeedSymbol = "";
- }
+ std::string endingLineFeedSymbol = "";
return new BuiltStyledStreamWriter(stream,
indentation_, cs_,
colonSymbol, nullSymbol, endingLineFeedSymbol);
@@ -1068,21 +1037,6 @@
own_->setIndentation(v);
return *this;
}
-StreamWriter::Builder& StreamWriter::Builder::withDropNullPlaceholders(bool v)
-{
- own_->setDropNullPlaceholders(v);
- return *this;
-}
-StreamWriter::Builder& StreamWriter::Builder::withOmitEndingLineFeed(bool v)
-{
- own_->setOmitEndingLineFeed(v);
- return *this;
-}
-StreamWriter::Builder& StreamWriter::Builder::withEnableYAMLCompatibility(bool v)
-{
- own_->setEnableYAMLCompatibility(v);
- return *this;
-}
StreamWriter* StreamWriter::Builder::newStreamWriter(
std::ostream* sout) const
{