Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions include/cereal/archives/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace cereal
static Options Default(){ return Options(); }

//! Default options with no indentation
static Options NoIndent(){ return Options( JSONWriter::kDefaultMaxDecimalPlaces, IndentChar::space, 0 ); }
static Options NoIndent(){ return Options( IndentChar::space, 0 ); }

//! The character to use for indenting
enum class IndentChar : char
Expand All @@ -139,13 +139,23 @@ namespace cereal
@param indentChar The type of character to indent with
@param indentLength The number of indentChar to use for indentation
(0 corresponds to no indentation) */
explicit Options( int precision = JSONWriter::kDefaultMaxDecimalPlaces,
explicit Options( int precision,
IndentChar indentChar = IndentChar::space,
unsigned int indentLength = 4 ) :
itsPrecision( precision ),
itsIndentChar( static_cast<char>(indentChar) ),
itsIndentLength( indentLength ) { }

//! Specify specific options for the JSONOutputArchive
/*! @param indentChar The type of character to indent with
@param indentLength The number of indentChar to use for indentation
(0 corresponds to no indentation) */
explicit Options( IndentChar indentChar = IndentChar::space,
unsigned int indentLength = 4 ) :
itsPrecision( JSONWriter::kDefaultMaxDecimalPlaces ),
itsIndentChar( static_cast<char>(indentChar) ),
itsIndentLength( indentLength ) { }

private:
friend class JSONOutputArchive;
int itsPrecision;
Expand Down