Skip to content

Commit db75cdf

Browse files
committed
mv CommentStyle to .cpp
1 parent c41609b commit db75cdf

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

doc/jsoncpp.dox

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ features without losing binary-compatibility.
9292
\code
9393
// For convenience, use `writeString()` with a specialized builder.
9494
Json::StreamWriterBuilder wbuilder;
95-
wbuilder.settings_["indentation"] = "\t";
95+
wbuilder.settings_["indentation"] = "\t"; // simple Json::Value
9696
std::string document = Json::writeString(wbuilder, root);
9797

9898
// Here, using a specialized Builder, we discard comments and
9999
// record errors as we parse.
100100
Json::CharReaderBuilder rbuilder;
101-
rbuilder.settings_["collectComments"] = false;
101+
rbuilder.settings_["collectComments"] = false; // simple Json::Value
102102
std::string errs;
103103
bool ok = Json::parseFromStream(rbuilder, std::cin, &root, &errs);
104104
\endcode

include/json/writer.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@ class JSON_API StreamWriter {
4141
protected:
4242
std::ostream* sout_; // not owned; will not delete
4343
public:
44-
/// Scoped enums are not available until C++11.
45-
struct CommentStyle {
46-
/// Decide whether to write comments.
47-
enum Enum {
48-
None, ///< Drop all comments.
49-
Most, ///< Recover odd behavior of previous versions (not implemented yet).
50-
All ///< Keep all comments.
51-
};
52-
};
53-
5444
StreamWriter();
5545
virtual ~StreamWriter();
5646
/** Write Value into document as configured in sub-class.

src/lib_json/json_writer.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -676,11 +676,21 @@ bool StyledStreamWriter::hasCommentForValue(const Value& value) {
676676
//////////////////////////
677677
// BuiltStyledStreamWriter
678678

679+
/// Scoped enums are not available until C++11.
680+
struct CommentStyle {
681+
/// Decide whether to write comments.
682+
enum Enum {
683+
None, ///< Drop all comments.
684+
Most, ///< Recover odd behavior of previous versions (not implemented yet).
685+
All ///< Keep all comments.
686+
};
687+
};
688+
679689
struct BuiltStyledStreamWriter : public StreamWriter
680690
{
681691
BuiltStyledStreamWriter(
682692
std::string const& indentation,
683-
StreamWriter::CommentStyle::Enum cs,
693+
CommentStyle::Enum cs,
684694
std::string const& colonSymbol,
685695
std::string const& nullSymbol,
686696
std::string const& endingLineFeedSymbol);
@@ -713,7 +723,7 @@ struct BuiltStyledStreamWriter : public StreamWriter
713723
};
714724
BuiltStyledStreamWriter::BuiltStyledStreamWriter(
715725
std::string const& indentation,
716-
StreamWriter::CommentStyle::Enum cs,
726+
CommentStyle::Enum cs,
717727
std::string const& colonSymbol,
718728
std::string const& nullSymbol,
719729
std::string const& endingLineFeedSymbol)
@@ -963,11 +973,11 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const
963973

964974
std::string indentation = settings_["indentation"].asString();
965975
std::string cs_str = settings_["commentStyle"].asString();
966-
StreamWriter::CommentStyle::Enum cs = StreamWriter::CommentStyle::All;
976+
CommentStyle::Enum cs = CommentStyle::All;
967977
if (cs_str == "All") {
968-
cs = StreamWriter::CommentStyle::All;
978+
cs = CommentStyle::All;
969979
} else if (cs_str == "None") {
970-
cs = StreamWriter::CommentStyle::None;
980+
cs = CommentStyle::None;
971981
} else {
972982
return NULL;
973983
}
@@ -1031,7 +1041,7 @@ StreamWriter* OldCompressingStreamWriterBuilder::newStreamWriter() const
10311041
endingLineFeedSymbol = "";
10321042
}
10331043
return new BuiltStyledStreamWriter(
1034-
"", StreamWriter::CommentStyle::None,
1044+
"", CommentStyle::None,
10351045
colonSymbol, nullSymbol, endingLineFeedSymbol);
10361046
}
10371047

0 commit comments

Comments
 (0)