From 198cc350c57f59f9fb4e11f73eff1d2ccd984003 Mon Sep 17 00:00:00 2001 From: Christopher Dunn Date: Thu, 29 Jan 2015 12:57:02 -0600 Subject: [PATCH] drop scoped enum, for pre-C++11 compatibility --- include/json/writer.h | 15 +++++++++------ src/lib_json/json_writer.cpp | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/json/writer.h b/include/json/writer.h index c4fd6ed..4b8a89c 100644 --- a/include/json/writer.h +++ b/include/json/writer.h @@ -41,11 +41,14 @@ class JSON_API StreamWriter { protected: std::ostream& sout_; // not owned; will not delete public: - /// Decide whether to write comments. - enum class CommentStyle { - None, ///< Drop all comments. - Most, ///< Recover odd behavior of previous versions (not implemented yet). - All ///< Keep all comments. + /// Scoped enums are not available until C++11. + struct CommentStyle { + /// Decide whether to write comments. + enum Enum { + None, ///< Drop all comments. + Most, ///< Recover odd behavior of previous versions (not implemented yet). + All ///< Keep all comments. + }; }; /// Keep a reference, but do not take ownership of `sout`. @@ -92,7 +95,7 @@ public: /** \brief How to write comments. * Default: All */ - StreamWriter::CommentStyle cs_; + StreamWriter::CommentStyle::Enum cs_; /** \brief Write in human-friendly style. If "", then skip all indentation and newlines. diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp index 6e0a429..6bb3901 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -673,7 +673,7 @@ struct BuiltStyledStreamWriter : public StreamWriter BuiltStyledStreamWriter( std::ostream* sout, std::string const& indentation, - StreamWriter::CommentStyle cs, + StreamWriter::CommentStyle::Enum cs, std::string const& colonSymbol, std::string const& nullSymbol, std::string const& endingLineFeedSymbol); @@ -697,7 +697,7 @@ private: std::string indentString_; int rightMargin_; std::string indentation_; - CommentStyle cs_; + CommentStyle::Enum cs_; std::string colonSymbol_; std::string nullSymbol_; std::string endingLineFeedSymbol_; @@ -707,7 +707,7 @@ private: BuiltStyledStreamWriter::BuiltStyledStreamWriter( std::ostream* sout, std::string const& indentation, - StreamWriter::CommentStyle cs, + StreamWriter::CommentStyle::Enum cs, std::string const& colonSymbol, std::string const& nullSymbol, std::string const& endingLineFeedSymbol)