Apply the formatting specified in .clang-format file.
$ clang-format --version
clang-format version 7.0.0 (tags/google/stable/2018-01-11)
$ clang-format -i --style=file $(find . -name '*.cpp' -o -name '*.h')
diff --git a/include/json/allocator.h b/include/json/allocator.h
index 9c7e573..d5f987e 100644
--- a/include/json/allocator.h
+++ b/include/json/allocator.h
@@ -12,86 +12,77 @@
#pragma pack(push, 8)
namespace Json {
-template<typename T>
-class SecureAllocator {
- public:
- // Type definitions
- using value_type = T;
- using pointer = T*;
- using const_pointer = const T*;
- using reference = T&;
- using const_reference = const T&;
- using size_type = std::size_t;
- using difference_type = std::ptrdiff_t;
+template <typename T> class SecureAllocator {
+public:
+ // Type definitions
+ using value_type = T;
+ using pointer = T*;
+ using const_pointer = const T*;
+ using reference = T&;
+ using const_reference = const T&;
+ using size_type = std::size_t;
+ using difference_type = std::ptrdiff_t;
- /**
- * Allocate memory for N items using the standard allocator.
- */
- pointer allocate(size_type n) {
- // allocate using "global operator new"
- return static_cast<pointer>(::operator new(n * sizeof(T)));
- }
+ /**
+ * Allocate memory for N items using the standard allocator.
+ */
+ pointer allocate(size_type n) {
+ // allocate using "global operator new"
+ return static_cast<pointer>(::operator new(n * sizeof(T)));
+ }
- /**
- * Release memory which was allocated for N items at pointer P.
- *
- * The memory block is filled with zeroes before being released.
- * The pointer argument is tagged as "volatile" to prevent the
- * compiler optimizing out this critical step.
- */
- void deallocate(volatile pointer p, size_type n) {
- std::memset(p, 0, n * sizeof(T));
- // free using "global operator delete"
- ::operator delete(p);
- }
+ /**
+ * Release memory which was allocated for N items at pointer P.
+ *
+ * The memory block is filled with zeroes before being released.
+ * The pointer argument is tagged as "volatile" to prevent the
+ * compiler optimizing out this critical step.
+ */
+ void deallocate(volatile pointer p, size_type n) {
+ std::memset(p, 0, n * sizeof(T));
+ // free using "global operator delete"
+ ::operator delete(p);
+ }
- /**
- * Construct an item in-place at pointer P.
- */
- template<typename... Args>
- void construct(pointer p, Args&&... args) {
- // construct using "placement new" and "perfect forwarding"
- ::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
- }
+ /**
+ * Construct an item in-place at pointer P.
+ */
+ template <typename... Args> void construct(pointer p, Args&&... args) {
+ // construct using "placement new" and "perfect forwarding"
+ ::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
+ }
- size_type max_size() const {
- return size_t(-1) / sizeof(T);
- }
+ size_type max_size() const { return size_t(-1) / sizeof(T); }
- pointer address( reference x ) const {
- return std::addressof(x);
- }
+ pointer address(reference x) const { return std::addressof(x); }
- const_pointer address( const_reference x ) const {
- return std::addressof(x);
- }
+ const_pointer address(const_reference x) const { return std::addressof(x); }
- /**
- * Destroy an item in-place at pointer P.
- */
- void destroy(pointer p) {
- // destroy using "explicit destructor"
- p->~T();
- }
+ /**
+ * Destroy an item in-place at pointer P.
+ */
+ void destroy(pointer p) {
+ // destroy using "explicit destructor"
+ p->~T();
+ }
- // Boilerplate
- SecureAllocator() {}
- template<typename U> SecureAllocator(const SecureAllocator<U>&) {}
- template<typename U> struct rebind { using other = SecureAllocator<U>; };
+ // Boilerplate
+ SecureAllocator() {}
+ template <typename U> SecureAllocator(const SecureAllocator<U>&) {}
+ template <typename U> struct rebind { using other = SecureAllocator<U>; };
};
-
-template<typename T, typename U>
+template <typename T, typename U>
bool operator==(const SecureAllocator<T>&, const SecureAllocator<U>&) {
- return true;
+ return true;
}
-template<typename T, typename U>
+template <typename T, typename U>
bool operator!=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
- return false;
+ return false;
}
-} //namespace Json
+} // namespace Json
#pragma pack(pop)
diff --git a/include/json/assertions.h b/include/json/assertions.h
index 1cca28d..482c4ca 100644
--- a/include/json/assertions.h
+++ b/include/json/assertions.h
@@ -6,8 +6,8 @@
#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
#define CPPTL_JSON_ASSERTIONS_H_INCLUDED
-#include <stdlib.h>
#include <sstream>
+#include <stdlib.h>
#if !defined(JSON_IS_AMALGAMATION)
#include "config.h"
@@ -20,30 +20,35 @@
#if JSON_USE_EXCEPTION
// @todo <= add detail about condition in exception
-# define JSON_ASSERT(condition) \
- {if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
-
-# define JSON_FAIL_MESSAGE(message) \
+#define JSON_ASSERT(condition) \
{ \
- JSONCPP_OSTRINGSTREAM oss; oss << message; \
+ if (!(condition)) { \
+ Json::throwLogicError("assert json failed"); \
+ } \
+ }
+
+#define JSON_FAIL_MESSAGE(message) \
+ { \
+ JSONCPP_OSTRINGSTREAM oss; \
+ oss << message; \
Json::throwLogicError(oss.str()); \
abort(); \
}
#else // JSON_USE_EXCEPTION
-# define JSON_ASSERT(condition) assert(condition)
+#define JSON_ASSERT(condition) assert(condition)
// The call to assert() will show the failure message in debug builds. In
// release builds we abort, for a core-dump or debugger.
-# define JSON_FAIL_MESSAGE(message) \
+#define JSON_FAIL_MESSAGE(message) \
{ \
- JSONCPP_OSTRINGSTREAM oss; oss << message; \
+ JSONCPP_OSTRINGSTREAM oss; \
+ oss << message; \
assert(false && oss.str().c_str()); \
abort(); \
}
-
#endif
#define JSON_ASSERT_MESSAGE(condition, message) \
diff --git a/include/json/config.h b/include/json/config.h
index 7d34692..33a84f5 100644
--- a/include/json/config.h
+++ b/include/json/config.h
@@ -6,8 +6,8 @@
#ifndef JSON_CONFIG_H_INCLUDED
#define JSON_CONFIG_H_INCLUDED
#include <stddef.h>
-#include <string> //typedef String
#include <stdint.h> //typedef int64_t, uint64_t
+#include <string> //typedef String
/// If defined, indicates that json library is embedded in CppTL library.
//# define JSON_IN_CPPTL 1
@@ -60,21 +60,21 @@
// #define JSON_NO_INT64 1
#if defined(_MSC_VER) // MSVC
-# if _MSC_VER <= 1200 // MSVC 6
- // Microsoft Visual Studio 6 only support conversion from __int64 to double
- // (no conversion from unsigned __int64).
-# define JSON_USE_INT64_DOUBLE_CONVERSION 1
- // Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
- // characters in the debug information)
- // All projects I've ever seen with VS6 were using this globally (not bothering
- // with pragma push/pop).
-# pragma warning(disable : 4786)
-# endif // MSVC 6
+#if _MSC_VER <= 1200 // MSVC 6
+// Microsoft Visual Studio 6 only support conversion from __int64 to double
+// (no conversion from unsigned __int64).
+#define JSON_USE_INT64_DOUBLE_CONVERSION 1
+// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
+// characters in the debug information)
+// All projects I've ever seen with VS6 were using this globally (not bothering
+// with pragma push/pop).
+#pragma warning(disable : 4786)
+#endif // MSVC 6
-# if _MSC_VER >= 1500 // MSVC 2008
- /// Indicates that the following function is deprecated.
-# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
-# endif
+#if _MSC_VER >= 1500 // MSVC 2008
+ /// Indicates that the following function is deprecated.
+#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
+#endif
#endif // defined(_MSC_VER)
@@ -82,25 +82,25 @@
// is intended to override the base-class version. This makes the code more
// manageable and fixes a set of common hard-to-find bugs.
#if __cplusplus >= 201103L
-# define JSONCPP_OVERRIDE override
-# define JSONCPP_NOEXCEPT noexcept
-# define JSONCPP_OP_EXPLICIT explicit
+#define JSONCPP_OVERRIDE override
+#define JSONCPP_NOEXCEPT noexcept
+#define JSONCPP_OP_EXPLICIT explicit
#elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900
-# define JSONCPP_OVERRIDE override
-# define JSONCPP_NOEXCEPT throw()
-# if _MSC_VER >= 1800 // MSVC 2013
-# define JSONCPP_OP_EXPLICIT explicit
-# else
-# define JSONCPP_OP_EXPLICIT
-# endif
-#elif defined(_MSC_VER) && _MSC_VER >= 1900
-# define JSONCPP_OVERRIDE override
-# define JSONCPP_NOEXCEPT noexcept
-# define JSONCPP_OP_EXPLICIT explicit
+#define JSONCPP_OVERRIDE override
+#define JSONCPP_NOEXCEPT throw()
+#if _MSC_VER >= 1800 // MSVC 2013
+#define JSONCPP_OP_EXPLICIT explicit
#else
-# define JSONCPP_OVERRIDE
-# define JSONCPP_NOEXCEPT throw()
-# define JSONCPP_OP_EXPLICIT
+#define JSONCPP_OP_EXPLICIT
+#endif
+#elif defined(_MSC_VER) && _MSC_VER >= 1900
+#define JSONCPP_OVERRIDE override
+#define JSONCPP_NOEXCEPT noexcept
+#define JSONCPP_OP_EXPLICIT explicit
+#else
+#define JSONCPP_OVERRIDE
+#define JSONCPP_NOEXCEPT throw()
+#define JSONCPP_OP_EXPLICIT
#endif
#ifndef JSON_HAS_RVALUE_REFERENCES
@@ -112,12 +112,12 @@
#ifdef __clang__
#if __has_feature(cxx_rvalue_references)
#define JSON_HAS_RVALUE_REFERENCES 1
-#endif // has_feature
+#endif // has_feature
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
#define JSON_HAS_RVALUE_REFERENCES 1
-#endif // GXX_EXPERIMENTAL
+#endif // GXX_EXPERIMENTAL
#endif // __clang__ || __GNUC__
@@ -128,15 +128,15 @@
#endif
#ifdef __clang__
-# if __has_extension(attribute_deprecated_with_message)
-# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
-# endif
+#if __has_extension(attribute_deprecated_with_message)
+#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
+#endif
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
-# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
-# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
-# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
-# define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
-# endif // GNUC version
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
+#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
+#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
+#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
+#endif // GNUC version
#endif // __clang__ || __GNUC__
#if !defined(JSONCPP_DEPRECATED)
@@ -144,16 +144,16 @@
#endif // if !defined(JSONCPP_DEPRECATED)
#if __GNUC__ >= 6
-# define JSON_USE_INT64_DOUBLE_CONVERSION 1
+#define JSON_USE_INT64_DOUBLE_CONVERSION 1
#endif
#if !defined(JSON_IS_AMALGAMATION)
-# include "version.h"
+#include "version.h"
-# if JSONCPP_USING_SECURE_MEMORY
-# include "allocator.h" //typedef Allocator
-# endif
+#if JSONCPP_USING_SECURE_MEMORY
+#include "allocator.h" //typedef Allocator
+#endif
#endif // if !defined(JSON_IS_AMALGAMATION)
@@ -172,23 +172,28 @@
#else // if defined(_MSC_VER) // Other platforms, use long long
typedef int64_t Int64;
typedef uint64_t UInt64;
-#endif // if defined(_MSC_VER)
+#endif // if defined(_MSC_VER)
typedef Int64 LargestInt;
typedef UInt64 LargestUInt;
#define JSON_HAS_INT64
#endif // if defined(JSON_NO_INT64)
#if JSONCPP_USING_SECURE_MEMORY
-#define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
-#define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
-#define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
-#define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
-#define JSONCPP_ISTREAM std::istream
+#define JSONCPP_STRING \
+ std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
+#define JSONCPP_OSTRINGSTREAM \
+ std::basic_ostringstream<char, std::char_traits<char>, \
+ Json::SecureAllocator<char> >
+#define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char> >
+#define JSONCPP_ISTRINGSTREAM \
+ std::basic_istringstream<char, std::char_traits<char>, \
+ Json::SecureAllocator<char> >
+#define JSONCPP_ISTREAM std::istream
#else
-#define JSONCPP_STRING std::string
+#define JSONCPP_STRING std::string
#define JSONCPP_OSTRINGSTREAM std::ostringstream
-#define JSONCPP_OSTREAM std::ostream
+#define JSONCPP_OSTREAM std::ostream
#define JSONCPP_ISTRINGSTREAM std::istringstream
-#define JSONCPP_ISTREAM std::istream
+#define JSONCPP_ISTREAM std::istream
#endif // if JSONCPP_USING_SECURE_MEMORY
} // end namespace Json
diff --git a/include/json/json.h b/include/json/json.h
index 3d2798a..19f14c2 100644
--- a/include/json/json.h
+++ b/include/json/json.h
@@ -7,9 +7,9 @@
#define JSON_JSON_H_INCLUDED
#include "autolink.h"
-#include "value.h"
-#include "reader.h"
-#include "writer.h"
#include "features.h"
+#include "reader.h"
+#include "value.h"
+#include "writer.h"
#endif // JSON_JSON_H_INCLUDED
diff --git a/include/json/reader.h b/include/json/reader.h
index dc1da1f..d8f1be1 100644
--- a/include/json/reader.h
+++ b/include/json/reader.h
@@ -12,9 +12,9 @@
#endif // if !defined(JSON_IS_AMALGAMATION)
#include <deque>
#include <iosfwd>
+#include <istream>
#include <stack>
#include <string>
-#include <istream>
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
// be used by...
@@ -52,13 +52,13 @@
/** \brief Constructs a Reader allowing all features
* for parsing.
*/
- JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
+ JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
Reader();
/** \brief Constructs a Reader allowing the specified feature set
* for parsing.
*/
- JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
+ JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
Reader(const Features& features);
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
@@ -151,7 +151,9 @@
* \return \c true if the error was successfully added, \c false if either
* Value offset exceeds the document size.
*/
- bool pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra);
+ bool pushError(const Value& value,
+ const JSONCPP_STRING& message,
+ const Value& extra);
/** \brief Return whether there are any errors.
* \return \c true if there are no errors to report \c false if
@@ -218,7 +220,8 @@
Location& current,
Location end,
unsigned int& unicode);
- bool addError(const JSONCPP_STRING& message, Token& token, Location extra = 0);
+ bool
+ addError(const JSONCPP_STRING& message, Token& token, Location extra = 0);
bool recoverFromError(TokenType skipUntilToken);
bool addErrorAndRecover(const JSONCPP_STRING& message,
Token& token,
@@ -247,7 +250,7 @@
JSONCPP_STRING commentsBefore_;
Features features_;
bool collectComments_;
-}; // Reader
+}; // Reader
/** Interface for reading JSON from a char array.
*/
@@ -256,7 +259,8 @@
virtual ~CharReader() {}
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
document.
- * The document must be a UTF-8 encoded string containing the document to read.
+ * The document must be a UTF-8 encoded string containing the document to
+ read.
*
* \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the
document to read.
@@ -271,9 +275,10 @@
* \return \c true if the document was successfully parsed, \c false if an
error occurred.
*/
- virtual bool parse(
- char const* beginDoc, char const* endDoc,
- Value* root, JSONCPP_STRING* errs) = 0;
+ virtual bool parse(char const* beginDoc,
+ char const* endDoc,
+ Value* root,
+ JSONCPP_STRING* errs) = 0;
class JSON_API Factory {
public:
@@ -282,8 +287,8 @@
* \throw std::exception if something goes wrong (e.g. invalid settings)
*/
virtual CharReader* newCharReader() const = 0;
- }; // Factory
-}; // CharReader
+ }; // Factory
+}; // CharReader
/** \brief Build a CharReader implementation.
@@ -313,7 +318,8 @@
- `"strictRoot": false or true`
- true if root must be either an array or an object value
- `"allowDroppedNullPlaceholders": false or true`
- - true if dropped null placeholders are allowed. (See StreamWriterBuilder.)
+ - true if dropped null placeholders are allowed. (See
+ StreamWriterBuilder.)
- `"allowNumericKeys": false or true`
- true if numeric object keys are allowed.
- `"allowSingleQuotes": false or true`
@@ -327,9 +333,10 @@
- If true, `parse()` returns false when extra non-whitespace trails
the JSON value in the input string.
- `"rejectDupKeys": false or true`
- - If true, `parse()` returns false when a key is duplicated within an object.
+ - If true, `parse()` returns false when a key is duplicated within an
+ object.
- `"allowSpecialFloats": false or true`
- - If true, special float values (NaNs and infinities) are allowed
+ - If true, special float values (NaNs and infinities) are allowed
and their values are lossfree restorable.
You can examine 'settings_` yourself
@@ -368,13 +375,13 @@
};
/** Consume entire stream and use its begin/end.
- * Someday we might have a real StreamReader, but for now this
- * is convenient.
- */
-bool JSON_API parseFromStream(
- CharReader::Factory const&,
- JSONCPP_ISTREAM&,
- Value* root, std::string* errs);
+ * Someday we might have a real StreamReader, but for now this
+ * is convenient.
+ */
+bool JSON_API parseFromStream(CharReader::Factory const&,
+ JSONCPP_ISTREAM&,
+ Value* root,
+ std::string* errs);
/** \brief Read from 'sin' into 'root'.
diff --git a/include/json/value.h b/include/json/value.h
index 3474cd8..06a6c0c 100644
--- a/include/json/value.h
+++ b/include/json/value.h
@@ -9,9 +9,9 @@
#if !defined(JSON_IS_AMALGAMATION)
#include "forwards.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
+#include <exception>
#include <string>
#include <vector>
-#include <exception>
#ifndef JSON_USE_CPPTL_SMALLMAP
#include <map>
@@ -22,17 +22,17 @@
#include <cpptl/forwards.h>
#endif
-//Conditional NORETURN attribute on the throw functions would:
+// Conditional NORETURN attribute on the throw functions would:
// a) suppress false positives from static code analysis
// b) possibly improve optimization opportunities.
#if !defined(JSONCPP_NORETURN)
-# if defined(_MSC_VER)
-# define JSONCPP_NORETURN __declspec(noreturn)
-# elif defined(__GNUC__)
-# define JSONCPP_NORETURN __attribute__ ((__noreturn__))
-# else
-# define JSONCPP_NORETURN
-# endif
+#if defined(_MSC_VER)
+#define JSONCPP_NORETURN __declspec(noreturn)
+#elif defined(__GNUC__)
+#define JSONCPP_NORETURN __attribute__((__noreturn__))
+#else
+#define JSONCPP_NORETURN
+#endif
#endif
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
@@ -57,6 +57,7 @@
Exception(JSONCPP_STRING const& msg);
~Exception() JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
char const* what() const JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
+
protected:
JSONCPP_STRING msg_;
};
@@ -183,6 +184,7 @@
*/
class JSON_API Value {
friend class ValueIteratorBase;
+
public:
typedef std::vector<JSONCPP_STRING> Members;
typedef ValueIterator iterator;
@@ -200,8 +202,10 @@
// Required for boost integration, e. g. BOOST_TEST
typedef std::string value_type;
- static const Value& null; ///< We regret this reference to a global instance; prefer the simpler Value().
- static const Value& nullRef; ///< just a kludge for binary-compatibility; same as null
+ static const Value& null; ///< We regret this reference to a global instance;
+ ///< prefer the simpler Value().
+ static const Value& nullRef; ///< just a kludge for binary-compatibility; same
+ ///< as null
static Value const& nullSingleton(); ///< Prefer this to null or nullRef.
/// Minimum signed integer value that can be stored in a Json::Value.
@@ -241,11 +245,7 @@
#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
class CZString {
public:
- enum DuplicationPolicy {
- noDuplication = 0,
- duplicate,
- duplicateOnCopy
- };
+ enum DuplicationPolicy { noDuplication = 0, duplicate, duplicateOnCopy };
CZString(ArrayIndex index);
CZString(char const* str, unsigned length, DuplicationPolicy allocate);
CZString(CZString const& other);
@@ -262,7 +262,7 @@
bool operator<(CZString const& other) const;
bool operator==(CZString const& other) const;
ArrayIndex index() const;
- //const char* c_str() const; ///< \deprecated
+ // const char* c_str() const; ///< \deprecated
char const* data() const;
unsigned length() const;
bool isStaticString() const;
@@ -271,11 +271,11 @@
void swap(CZString& other);
struct StringStorage {
- unsigned policy_: 2;
- unsigned length_: 30; // 1GB max
+ unsigned policy_ : 2;
+ unsigned length_ : 30; // 1GB max
};
- char const* cstr_; // actually, a prefixed string, unless policy is noDup
+ char const* cstr_; // actually, a prefixed string, unless policy is noDup
union {
ArrayIndex index_;
StringStorage storage_;
@@ -332,7 +332,8 @@
* \endcode
*/
Value(const StaticString& value);
- Value(const JSONCPP_STRING& value); ///< Copy data() til size(). Embedded zeroes too.
+ Value(const JSONCPP_STRING& value); ///< Copy data() til size(). Embedded
+ ///< zeroes too.
#ifdef JSON_USE_CPPTL
Value(const CppTL::ConstString& value);
#endif
@@ -346,7 +347,8 @@
~Value();
/// Deep copy, then swap(other).
- /// \note Over-write existing comments. To preserve comments, use #swapPayload().
+ /// \note Over-write existing comments. To preserve comments, use
+ /// #swapPayload().
Value& operator=(Value other);
/// Swap everything.
@@ -372,14 +374,14 @@
const char* asCString() const; ///< Embedded zeroes could cause you trouble!
#if JSONCPP_USING_SECURE_MEMORY
- unsigned getCStringLength() const; //Allows you to understand the length of the CString
+ unsigned getCStringLength() const; // Allows you to understand the length of
+ // the CString
#endif
JSONCPP_STRING asString() const; ///< Embedded zeroes are possible.
/** Get raw char* of string-value.
* \return false if !string. (Seg-fault if str or end are NULL.)
*/
- bool getString(
- char const** begin, char const** end) const;
+ bool getString(char const** begin, char const** end) const;
#ifdef JSON_USE_CPPTL
CppTL::ConstString asConstString() const;
#endif
@@ -490,7 +492,8 @@
/** \brief Access an object value by name, create a null member if it does not
exist.
- * If the object has no entry for that name, then the member name used to store
+ * If the object has no entry for that name, then the member name used to
+ store
* the new entry is not duplicated.
* Example of use:
* \code
@@ -513,7 +516,8 @@
/// Return the member named key if it exist, defaultValue otherwise.
/// \note deep copy
/// \note key may contain embedded nulls.
- Value get(const char* begin, const char* end, const Value& defaultValue) const;
+ Value
+ get(const char* begin, const char* end, const Value& defaultValue) const;
/// Return the member named key if it exist, defaultValue otherwise.
/// \note deep copy
/// \param key may contain embedded nulls.
@@ -646,12 +650,14 @@
LargestUInt uint_;
double real_;
bool bool_;
- char* string_; // actually ptr to unsigned, followed by str, unless !allocated_
+ char* string_; // actually ptr to unsigned, followed by str, unless
+ // !allocated_
ObjectValues* map_;
} value_;
ValueType type_ : 8;
- unsigned int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
- // If not allocated_, string_ must be null-terminated.
+ unsigned int allocated_ : 1; // Notes: if declared as bool, bitfield is
+ // useless. If not allocated_, string_ must be
+ // null-terminated.
CommentInfo* comments_;
// [start, limit) byte offsets in the source JSON text from which this Value
@@ -673,11 +679,7 @@
PathArgument(const JSONCPP_STRING& key);
private:
- enum Kind {
- kindNone = 0,
- kindIndex,
- kindKey
- };
+ enum Kind { kindNone = 0, kindIndex, kindKey };
JSONCPP_STRING key_;
ArrayIndex index_;
Kind kind_;
@@ -745,7 +747,8 @@
/// Value.
Value key() const;
- /// Return the index of the referenced Value, or -1 if it is not an arrayValue.
+ /// Return the index of the referenced Value, or -1 if it is not an
+ /// arrayValue.
UInt index() const;
/// Return the member name of the referenced Value, or "" if it is not an
@@ -755,7 +758,8 @@
/// Return the member name of the referenced Value. "" if it is not an
/// objectValue.
- /// \deprecated This cannot be used for UTF-8 strings, since there can be embedded nulls.
+ /// \deprecated This cannot be used for UTF-8 strings, since there can be
+ /// embedded nulls.
JSONCPP_DEPRECATED("Use `key = name();` instead.")
char const* memberName() const;
/// Return the member name of the referenced Value, or NULL if it is not an
@@ -796,8 +800,8 @@
public:
typedef const Value value_type;
- //typedef unsigned int size_t;
- //typedef int difference_type;
+ // typedef unsigned int size_t;
+ // typedef int difference_type;
typedef const Value& reference;
typedef const Value* pointer;
typedef ValueConstIterator SelfType;
@@ -806,9 +810,10 @@
ValueConstIterator(ValueIterator const& other);
private:
-/*! \internal Use by Value to create an iterator.
- */
+ /*! \internal Use by Value to create an iterator.
+ */
explicit ValueConstIterator(const Value::ObjectValues::iterator& current);
+
public:
SelfType& operator=(const ValueIteratorBase& other);
@@ -857,9 +862,10 @@
ValueIterator(const ValueIterator& other);
private:
-/*! \internal Use by Value to create an iterator.
- */
+ /*! \internal Use by Value to create an iterator.
+ */
explicit ValueIterator(const Value::ObjectValues::iterator& current);
+
public:
SelfType& operator=(const SelfType& other);
diff --git a/include/json/version.h b/include/json/version.h
index 06c6187..027f731 100644
--- a/include/json/version.h
+++ b/include/json/version.h
@@ -1,14 +1,16 @@
// DO NOT EDIT. This file (and "version") is generated by CMake.
// Run CMake configure step to update it.
#ifndef JSON_VERSION_H_INCLUDED
-# define JSON_VERSION_H_INCLUDED
+#define JSON_VERSION_H_INCLUDED
-# define JSONCPP_VERSION_STRING "1.8.4"
-# define JSONCPP_VERSION_MAJOR 1
-# define JSONCPP_VERSION_MINOR 8
-# define JSONCPP_VERSION_PATCH 4
-# define JSONCPP_VERSION_QUALIFIER
-# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
+#define JSONCPP_VERSION_STRING "1.8.4"
+#define JSONCPP_VERSION_MAJOR 1
+#define JSONCPP_VERSION_MINOR 8
+#define JSONCPP_VERSION_PATCH 4
+#define JSONCPP_VERSION_QUALIFIER
+#define JSONCPP_VERSION_HEXA \
+ ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \
+ (JSONCPP_VERSION_PATCH << 8))
#ifdef JSONCPP_USING_SECURE_MEMORY
#undef JSONCPP_USING_SECURE_MEMORY
diff --git a/include/json/writer.h b/include/json/writer.h
index 767b3bd..30424b0 100644
--- a/include/json/writer.h
+++ b/include/json/writer.h
@@ -9,9 +9,9 @@
#if !defined(JSON_IS_AMALGAMATION)
#include "value.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <vector>
-#include <string>
#include <ostream>
+#include <string>
+#include <vector>
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
// be used by...
@@ -41,15 +41,15 @@
*/
class JSON_API StreamWriter {
protected:
- JSONCPP_OSTREAM* sout_; // not owned; will not delete
+ JSONCPP_OSTREAM* sout_; // not owned; will not delete
public:
StreamWriter();
virtual ~StreamWriter();
/** Write Value into document as configured in sub-class.
Do not take ownership of sout, but maintain a reference during function.
\pre sout != NULL
- \return zero on success (For now, we always return zero, so check the stream instead.)
- \throw std::exception possibly, depending on configuration
+ \return zero on success (For now, we always return zero, so check the
+ stream instead.) \throw std::exception possibly, depending on configuration
*/
virtual int write(Value const& root, JSONCPP_OSTREAM* sout) = 0;
@@ -62,14 +62,14 @@
* \throw std::exception if something goes wrong (e.g. invalid settings)
*/
virtual StreamWriter* newStreamWriter() const = 0;
- }; // Factory
-}; // StreamWriter
+ }; // Factory
+}; // StreamWriter
/** \brief Write into stringstream, then return string, for convenience.
* A StreamWriter will be created from the factory, used, and then deleted.
*/
-JSONCPP_STRING JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);
-
+JSONCPP_STRING JSON_API writeString(StreamWriter::Factory const& factory,
+ Value const& root);
/** \brief Build a StreamWriter implementation.
@@ -104,8 +104,8 @@
browser can handle the output just fine.
- "useSpecialFloats": false or true
- If true, outputs non-finite floating point values in the following way:
- NaN values as "NaN", positive infinity as "Infinity", and negative infinity
- as "-Infinity".
+ NaN values as "NaN", positive infinity as "Infinity", and negative
+ infinity as "-Infinity".
- "precision": int
- Number of precision digits for formatting of real values.
- "precisionType": "significant"(default) or "decimal"
@@ -163,9 +163,10 @@
*/
#if defined(_MSC_VER)
#pragma warning(push)
-#pragma warning(disable:4996) // Deriving from deprecated class
+#pragma warning(disable : 4996) // Deriving from deprecated class
#endif
-class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter : public Writer {
+class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter
+ : public Writer {
public:
FastWriter();
~FastWriter() JSONCPP_OVERRIDE {}
@@ -222,9 +223,10 @@
*/
#if defined(_MSC_VER)
#pragma warning(push)
-#pragma warning(disable:4996) // Deriving from deprecated class
+#pragma warning(disable : 4996) // Deriving from deprecated class
#endif
-class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledWriter : public Writer {
+class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
+ StyledWriter : public Writer {
public:
StyledWriter();
~StyledWriter() JSONCPP_OVERRIDE {}
@@ -290,13 +292,14 @@
*/
#if defined(_MSC_VER)
#pragma warning(push)
-#pragma warning(disable:4996) // Deriving from deprecated class
+#pragma warning(disable : 4996) // Deriving from deprecated class
#endif
-class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledStreamWriter {
+class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
+ StyledStreamWriter {
public:
-/**
- * \param indentation Each level will be indented by this amount extra.
- */
+ /**
+ * \param indentation Each level will be indented by this amount extra.
+ */
StyledStreamWriter(JSONCPP_STRING indentation = "\t");
~StyledStreamWriter() {}
@@ -343,8 +346,10 @@
#endif // if defined(JSON_HAS_INT64)
JSONCPP_STRING JSON_API valueToString(LargestInt value);
JSONCPP_STRING JSON_API valueToString(LargestUInt value);
-JSONCPP_STRING JSON_API valueToString(double value, unsigned int precision = Value::defaultRealPrecision,
- PrecisionType precisionType = PrecisionType::significantDigits);
+JSONCPP_STRING JSON_API
+valueToString(double value,
+ unsigned int precision = Value::defaultRealPrecision,
+ PrecisionType precisionType = PrecisionType::significantDigits);
JSONCPP_STRING JSON_API valueToString(bool value);
JSONCPP_STRING JSON_API valueToQuotedString(const char* value);