drop scoped enum, for pre-C++11 compatibility

This commit is contained in:
Christopher Dunn 2015-01-29 12:57:02 -06:00
parent 5e8595c0e2
commit 198cc350c5
2 changed files with 12 additions and 9 deletions

View File

@ -41,11 +41,14 @@ class JSON_API StreamWriter {
protected: protected:
std::ostream& sout_; // not owned; will not delete std::ostream& sout_; // not owned; will not delete
public: public:
/// Decide whether to write comments. /// Scoped enums are not available until C++11.
enum class CommentStyle { struct CommentStyle {
None, ///< Drop all comments. /// Decide whether to write comments.
Most, ///< Recover odd behavior of previous versions (not implemented yet). enum Enum {
All ///< Keep all comments. 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`. /// Keep a reference, but do not take ownership of `sout`.
@ -92,7 +95,7 @@ public:
/** \brief How to write comments. /** \brief How to write comments.
* Default: All * Default: All
*/ */
StreamWriter::CommentStyle cs_; StreamWriter::CommentStyle::Enum cs_;
/** \brief Write in human-friendly style. /** \brief Write in human-friendly style.
If "", then skip all indentation and newlines. If "", then skip all indentation and newlines.

View File

@ -673,7 +673,7 @@ struct BuiltStyledStreamWriter : public StreamWriter
BuiltStyledStreamWriter( BuiltStyledStreamWriter(
std::ostream* sout, std::ostream* sout,
std::string const& indentation, std::string const& indentation,
StreamWriter::CommentStyle cs, StreamWriter::CommentStyle::Enum cs,
std::string const& colonSymbol, std::string const& colonSymbol,
std::string const& nullSymbol, std::string const& nullSymbol,
std::string const& endingLineFeedSymbol); std::string const& endingLineFeedSymbol);
@ -697,7 +697,7 @@ private:
std::string indentString_; std::string indentString_;
int rightMargin_; int rightMargin_;
std::string indentation_; std::string indentation_;
CommentStyle cs_; CommentStyle::Enum cs_;
std::string colonSymbol_; std::string colonSymbol_;
std::string nullSymbol_; std::string nullSymbol_;
std::string endingLineFeedSymbol_; std::string endingLineFeedSymbol_;
@ -707,7 +707,7 @@ private:
BuiltStyledStreamWriter::BuiltStyledStreamWriter( BuiltStyledStreamWriter::BuiltStyledStreamWriter(
std::ostream* sout, std::ostream* sout,
std::string const& indentation, std::string const& indentation,
StreamWriter::CommentStyle cs, StreamWriter::CommentStyle::Enum cs,
std::string const& colonSymbol, std::string const& colonSymbol,
std::string const& nullSymbol, std::string const& nullSymbol,
std::string const& endingLineFeedSymbol) std::string const& endingLineFeedSymbol)