Skip to content

Commit 198cc35

Browse files
committed
drop scoped enum, for pre-C++11 compatibility
1 parent 5e8595c commit 198cc35

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

include/json/writer.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ class JSON_API StreamWriter {
4141
protected:
4242
std::ostream& sout_; // not owned; will not delete
4343
public:
44-
/// Decide whether to write comments.
45-
enum class CommentStyle {
46-
None, ///< Drop all comments.
47-
Most, ///< Recover odd behavior of previous versions (not implemented yet).
48-
All ///< Keep all comments.
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+
};
4952
};
5053

5154
/// Keep a reference, but do not take ownership of `sout`.
@@ -92,7 +95,7 @@ class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
9295
/** \brief How to write comments.
9396
* Default: All
9497
*/
95-
StreamWriter::CommentStyle cs_;
98+
StreamWriter::CommentStyle::Enum cs_;
9699
/** \brief Write in human-friendly style.
97100
98101
If "", then skip all indentation and newlines.

src/lib_json/json_writer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ struct BuiltStyledStreamWriter : public StreamWriter
673673
BuiltStyledStreamWriter(
674674
std::ostream* sout,
675675
std::string const& indentation,
676-
StreamWriter::CommentStyle cs,
676+
StreamWriter::CommentStyle::Enum cs,
677677
std::string const& colonSymbol,
678678
std::string const& nullSymbol,
679679
std::string const& endingLineFeedSymbol);
@@ -697,7 +697,7 @@ struct BuiltStyledStreamWriter : public StreamWriter
697697
std::string indentString_;
698698
int rightMargin_;
699699
std::string indentation_;
700-
CommentStyle cs_;
700+
CommentStyle::Enum cs_;
701701
std::string colonSymbol_;
702702
std::string nullSymbol_;
703703
std::string endingLineFeedSymbol_;
@@ -707,7 +707,7 @@ struct BuiltStyledStreamWriter : public StreamWriter
707707
BuiltStyledStreamWriter::BuiltStyledStreamWriter(
708708
std::ostream* sout,
709709
std::string const& indentation,
710-
StreamWriter::CommentStyle cs,
710+
StreamWriter::CommentStyle::Enum cs,
711711
std::string const& colonSymbol,
712712
std::string const& nullSymbol,
713713
std::string const& endingLineFeedSymbol)

0 commit comments

Comments
 (0)