mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-06-08 17:30:13 +02:00
Merge pull request #33 from donmilham/master
added option to FastWriter which omits the trailing new line character
This commit is contained in:
commit
b02ff20bd3
@ -54,6 +54,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
void dropNullPlaceholders();
|
void dropNullPlaceholders();
|
||||||
|
|
||||||
|
void omitEndingLineFeed();
|
||||||
|
|
||||||
public: // overridden from Writer
|
public: // overridden from Writer
|
||||||
virtual std::string write(const Value &root);
|
virtual std::string write(const Value &root);
|
||||||
|
|
||||||
@ -63,6 +65,7 @@ private:
|
|||||||
std::string document_;
|
std::string document_;
|
||||||
bool yamlCompatiblityEnabled_;
|
bool yamlCompatiblityEnabled_;
|
||||||
bool dropNullPlaceholders_;
|
bool dropNullPlaceholders_;
|
||||||
|
bool omitEndingLineFeed_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
|
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
|
||||||
|
@ -180,16 +180,19 @@ Writer::~Writer() {}
|
|||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FastWriter::FastWriter()
|
FastWriter::FastWriter()
|
||||||
: yamlCompatiblityEnabled_(false), dropNullPlaceholders_(false) {}
|
: yamlCompatiblityEnabled_(false), dropNullPlaceholders_(false), omitEndingLineFeed_(false) {}
|
||||||
|
|
||||||
void FastWriter::enableYAMLCompatibility() { yamlCompatiblityEnabled_ = true; }
|
void FastWriter::enableYAMLCompatibility() { yamlCompatiblityEnabled_ = true; }
|
||||||
|
|
||||||
void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }
|
void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }
|
||||||
|
|
||||||
|
void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }
|
||||||
|
|
||||||
std::string FastWriter::write(const Value &root) {
|
std::string FastWriter::write(const Value &root) {
|
||||||
document_ = "";
|
document_ = "";
|
||||||
writeValue(root);
|
writeValue(root);
|
||||||
document_ += "\n";
|
if (!omitEndingLineFeed_)
|
||||||
|
document_ += "\n";
|
||||||
return document_;
|
return document_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user