From 11086dd6a7eba04289944367ca82cea71299ed70 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Mon, 15 Sep 2014 10:15:29 +1000 Subject: [PATCH] Enabled PointerBindsToType in clang-format options. --- .clang-format | 2 +- include/json/assertions.h | 4 +- include/json/reader.h | 64 +++--- include/json/value.h | 344 ++++++++++++++--------------- include/json/writer.h | 52 ++--- src/jsontestrunner/main.cpp | 48 ++-- src/lib_json/json_batchallocator.h | 40 ++-- src/lib_json/json_reader.cpp | 72 +++--- src/lib_json/json_tool.h | 4 +- src/lib_json/json_value.cpp | 178 +++++++-------- src/lib_json/json_writer.cpp | 86 ++++---- src/test_lib_json/jsontest.cpp | 70 +++--- src/test_lib_json/jsontest.h | 86 ++++---- src/test_lib_json/main.cpp | 30 +-- 14 files changed, 540 insertions(+), 540 deletions(-) diff --git a/.clang-format b/.clang-format index d6c0b0546..dd51247d5 100644 --- a/.clang-format +++ b/.clang-format @@ -27,7 +27,7 @@ PenaltyBreakString: 1000 PenaltyBreakFirstLessLess: 120 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 -PointerBindsToType: false +PointerBindsToType: true SpacesBeforeTrailingComments: 1 Cpp11BracedListStyle: false Standard: Cpp03 diff --git a/include/json/assertions.h b/include/json/assertions.h index d5d5ff4ef..5ef7e7bb7 100644 --- a/include/json/assertions.h +++ b/include/json/assertions.h @@ -26,8 +26,8 @@ // afterward in order to tell the compiler that this macro doesn't return. #define JSON_FAIL_MESSAGE(message) \ { \ - assert(false &&message); \ - strcpy(reinterpret_cast(666), message); \ + assert(false&& message); \ + strcpy(reinterpret_cast(666), message); \ exit(123); \ } diff --git a/include/json/reader.h b/include/json/reader.h index af8e13cec..e99dbc0c7 100644 --- a/include/json/reader.h +++ b/include/json/reader.h @@ -31,7 +31,7 @@ namespace Json { class JSON_API Reader { public: typedef char Char; - typedef const Char *Location; + typedef const Char* Location; /** \brief An error tagged with where in the JSON text it was encountered. * @@ -53,7 +53,7 @@ class JSON_API Reader { /** \brief Constructs a Reader allowing the specified feature set * for parsing. */ - Reader(const Features &features); + Reader(const Features& features); /** \brief Read a Value from a JSON * document. @@ -70,7 +70,7 @@ class JSON_API Reader { * error occurred. */ bool - parse(const std::string &document, Value &root, bool collectComments = true); + parse(const std::string& document, Value& root, bool collectComments = true); /** \brief Read a Value from a JSON document. @@ -90,14 +90,14 @@ class JSON_API Reader { * \return \c true if the document was successfully parsed, \c false if an error occurred. */ - bool parse(const char *beginDoc, - const char *endDoc, - Value &root, + bool parse(const char* beginDoc, + const char* endDoc, + Value& root, bool collectComments = true); /// \brief Parse from input stream. /// \see Json::operator>>(std::istream&, Json::Value&). - bool parse(std::istream &is, Value &root, bool collectComments = true); + bool parse(std::istream& is, Value& root, bool collectComments = true); /** \brief Returns a user friendly string that list errors in the parsed * document. @@ -164,8 +164,8 @@ class JSON_API Reader { typedef std::deque Errors; - bool expectToken(TokenType type, Token &token, const char *message); - bool readToken(Token &token); + bool expectToken(TokenType type, Token& token, const char* message); + bool readToken(Token& token); void skipSpaces(); bool match(Location pattern, int patternLength); bool readComment(); @@ -174,37 +174,37 @@ class JSON_API Reader { bool readString(); void readNumber(); bool readValue(); - bool readObject(Token &token); - bool readArray(Token &token); - bool decodeNumber(Token &token); - bool decodeNumber(Token &token, Value &decoded); - bool decodeString(Token &token); - bool decodeString(Token &token, std::string &decoded); - bool decodeDouble(Token &token); - bool decodeDouble(Token &token, Value &decoded); - bool decodeUnicodeCodePoint(Token &token, - Location ¤t, + bool readObject(Token& token); + bool readArray(Token& token); + bool decodeNumber(Token& token); + bool decodeNumber(Token& token, Value& decoded); + bool decodeString(Token& token); + bool decodeString(Token& token, std::string& decoded); + bool decodeDouble(Token& token); + bool decodeDouble(Token& token, Value& decoded); + bool decodeUnicodeCodePoint(Token& token, + Location& current, Location end, - unsigned int &unicode); - bool decodeUnicodeEscapeSequence(Token &token, - Location ¤t, + unsigned int& unicode); + bool decodeUnicodeEscapeSequence(Token& token, + Location& current, Location end, - unsigned int &unicode); - bool addError(const std::string &message, Token &token, Location extra = 0); + unsigned int& unicode); + bool addError(const std::string& message, Token& token, Location extra = 0); bool recoverFromError(TokenType skipUntilToken); - bool addErrorAndRecover(const std::string &message, - Token &token, + bool addErrorAndRecover(const std::string& message, + Token& token, TokenType skipUntilToken); void skipUntilSpace(); - Value ¤tValue(); + Value& currentValue(); Char getNextChar(); void - getLocationLineAndColumn(Location location, int &line, int &column) const; + getLocationLineAndColumn(Location location, int& line, int& column) const; std::string getLocationLineAndColumn(Location location) const; void addComment(Location begin, Location end, CommentPlacement placement); - void skipCommentTokens(Token &token); + void skipCommentTokens(Token& token); - typedef std::stack Nodes; + typedef std::stack Nodes; Nodes nodes_; Errors errors_; std::string document_; @@ -212,7 +212,7 @@ class JSON_API Reader { Location end_; Location current_; Location lastValueEnd_; - Value *lastValue_; + Value* lastValue_; std::string commentsBefore_; Features features_; bool collectComments_; @@ -242,7 +242,7 @@ class JSON_API Reader { \throw std::exception on parse error. \see Json::operator<<() */ -JSON_API std::istream &operator>>(std::istream &, Value &); +JSON_API std::istream& operator>>(std::istream&, Value&); } // namespace Json diff --git a/include/json/value.h b/include/json/value.h index 7ff76d473..a60ca8f75 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -74,14 +74,14 @@ enum CommentPlacement { */ class JSON_API StaticString { public: - explicit StaticString(const char *czstring) : str_(czstring) {} + explicit StaticString(const char* czstring) : str_(czstring) {} - operator const char *() const { return str_; } + operator const char*() const { return str_; } - const char *c_str() const { return str_; } + const char* c_str() const { return str_; } private: - const char *str_; + const char* str_; }; /** \brief Represents a JSON value. @@ -133,7 +133,7 @@ class JSON_API Value { typedef Json::LargestUInt LargestUInt; typedef Json::ArrayIndex ArrayIndex; - static const Value &null; + static const Value& null; /// Minimum signed integer value that can be stored in a Json::Value. static const LargestInt minLargestInt; /// Maximum signed integer value that can be stored in a Json::Value. @@ -168,19 +168,19 @@ class JSON_API Value { duplicateOnCopy }; CZString(ArrayIndex index); - CZString(const char *cstr, DuplicationPolicy allocate); - CZString(const CZString &other); + CZString(const char* cstr, DuplicationPolicy allocate); + CZString(const CZString& other); ~CZString(); - CZString &operator=(CZString other); - bool operator<(const CZString &other) const; - bool operator==(const CZString &other) const; + CZString& operator=(CZString other); + bool operator<(const CZString& other) const; + bool operator==(const CZString& other) const; ArrayIndex index() const; - const char *c_str() const; + const char* c_str() const; bool isStaticString() const; private: - void swap(CZString &other); - const char *cstr_; + void swap(CZString& other); + const char* cstr_; ArrayIndex index_; }; @@ -217,8 +217,8 @@ Json::Value obj_value(Json::objectValue); // {} Value(UInt64 value); #endif // if defined(JSON_HAS_INT64) Value(double value); - Value(const char *value); - Value(const char *beginValue, const char *endValue); + Value(const char* value); + Value(const char* beginValue, const char* endValue); /** \brief Constructs a value from a static string. * Like other value string constructor but do not duplicate the string for @@ -229,34 +229,34 @@ Json::Value obj_value(Json::objectValue); // {} * Json::Value aValue( StaticString("some text") ); * \endcode */ - Value(const StaticString &value); - Value(const std::string &value); + Value(const StaticString& value); + Value(const std::string& value); #ifdef JSON_USE_CPPTL - Value(const CppTL::ConstString &value); + Value(const CppTL::ConstString& value); #endif Value(bool value); - Value(const Value &other); + Value(const Value& other); ~Value(); - Value &operator=(Value other); + Value& operator=(Value other); /// Swap values. /// \note Currently, comments are intentionally not swapped, for /// both logic and efficiency. - void swap(Value &other); + void swap(Value& other); ValueType type() const; - bool operator<(const Value &other) const; - bool operator<=(const Value &other) const; - bool operator>=(const Value &other) const; - bool operator>(const Value &other) const; + bool operator<(const Value& other) const; + bool operator<=(const Value& other) const; + bool operator>=(const Value& other) const; + bool operator>(const Value& other) const; - bool operator==(const Value &other) const; - bool operator!=(const Value &other) const; + bool operator==(const Value& other) const; + bool operator!=(const Value& other) const; - int compare(const Value &other) const; + int compare(const Value& other) const; - const char *asCString() const; + const char* asCString() const; std::string asString() const; #ifdef JSON_USE_CPPTL CppTL::ConstString asConstString() const; @@ -316,7 +316,7 @@ Json::Value obj_value(Json::objectValue); // {} /// in the array so that its size is index+1. /// (You may need to say 'value[0u]' to get your compiler to distinguish /// this from the operator[] which takes a string.) - Value &operator[](ArrayIndex index); + Value& operator[](ArrayIndex index); /// Access an array element (zero based index ). /// If the array contains less than index element, then null value are @@ -324,39 +324,39 @@ Json::Value obj_value(Json::objectValue); // {} /// in the array so that its size is index+1. /// (You may need to say 'value[0u]' to get your compiler to distinguish /// this from the operator[] which takes a string.) - Value &operator[](int index); + Value& operator[](int index); /// Access an array element (zero based index ) /// (You may need to say 'value[0u]' to get your compiler to distinguish /// this from the operator[] which takes a string.) - const Value &operator[](ArrayIndex index) const; + const Value& operator[](ArrayIndex index) const; /// Access an array element (zero based index ) /// (You may need to say 'value[0u]' to get your compiler to distinguish /// this from the operator[] which takes a string.) - const Value &operator[](int index) const; + const Value& operator[](int index) const; /// If the array contains at least index+1 elements, returns the element /// value, /// otherwise returns defaultValue. - Value get(ArrayIndex index, const Value &defaultValue) const; + Value get(ArrayIndex index, const Value& defaultValue) const; /// Return true if index < size(). bool isValidIndex(ArrayIndex index) const; /// \brief Append value to array at the end. /// /// Equivalent to jsonvalue[jsonvalue.size()] = value; - Value &append(const Value &value); + Value& append(const Value& value); /// Access an object value by name, create a null member if it does not exist. - Value &operator[](const char *key); + Value& operator[](const char* key); /// Access an object value by name, returns null if there is no member with /// that name. - const Value &operator[](const char *key) const; + const Value& operator[](const char* key) const; /// Access an object value by name, create a null member if it does not exist. - Value &operator[](const std::string &key); + Value& operator[](const std::string& key); /// Access an object value by name, returns null if there is no member with /// that name. - const Value &operator[](const std::string &key) const; + const Value& operator[](const std::string& key) const; /** \brief Access an object value by name, create a null member if it does not exist. @@ -369,21 +369,21 @@ Json::Value obj_value(Json::objectValue); // {} * object[code] = 1234; * \endcode */ - Value &operator[](const StaticString &key); + Value& operator[](const StaticString& key); #ifdef JSON_USE_CPPTL /// Access an object value by name, create a null member if it does not exist. - Value &operator[](const CppTL::ConstString &key); + Value& operator[](const CppTL::ConstString& key); /// Access an object value by name, returns null if there is no member with /// that name. - const Value &operator[](const CppTL::ConstString &key) const; + const Value& operator[](const CppTL::ConstString& key) const; #endif /// Return the member named key if it exist, defaultValue otherwise. - Value get(const char *key, const Value &defaultValue) const; + Value get(const char* key, const Value& defaultValue) const; /// Return the member named key if it exist, defaultValue otherwise. - Value get(const std::string &key, const Value &defaultValue) const; + Value get(const std::string& key, const Value& defaultValue) const; #ifdef JSON_USE_CPPTL /// Return the member named key if it exist, defaultValue otherwise. - Value get(const CppTL::ConstString &key, const Value &defaultValue) const; + Value get(const CppTL::ConstString& key, const Value& defaultValue) const; #endif /// \brief Remove and return the named member. /// @@ -391,17 +391,17 @@ Json::Value obj_value(Json::objectValue); // {} /// \return the removed Value, or null. /// \pre type() is objectValue or nullValue /// \post type() is unchanged - Value removeMember(const char *key); + Value removeMember(const char* key); /// Same as removeMember(const char*) - Value removeMember(const std::string &key); + Value removeMember(const std::string& key); /// Return true if the object has a member named key. - bool isMember(const char *key) const; + bool isMember(const char* key) const; /// Return true if the object has a member named key. - bool isMember(const std::string &key) const; + bool isMember(const std::string& key) const; #ifdef JSON_USE_CPPTL /// Return true if the object has a member named key. - bool isMember(const CppTL::ConstString &key) const; + bool isMember(const CppTL::ConstString& key) const; #endif /// \brief Return a list of the member names. @@ -417,9 +417,9 @@ Json::Value obj_value(Json::objectValue); // {} //# endif /// Comments must be //... or /* ... */ - void setComment(const char *comment, CommentPlacement placement); + void setComment(const char* comment, CommentPlacement placement); /// Comments must be //... or /* ... */ - void setComment(const std::string &comment, CommentPlacement placement); + void setComment(const std::string& comment, CommentPlacement placement); bool hasComment(CommentPlacement placement) const; /// Include delimiters and embedded newlines. std::string getComment(CommentPlacement placement) const; @@ -440,7 +440,7 @@ Json::Value obj_value(Json::objectValue); // {} size_t getOffsetLimit() const; private: - Value &resolveReference(const char *key, bool isStatic); + Value& resolveReference(const char* key, bool isStatic); #ifdef JSON_VALUE_USE_INTERNAL_MAP inline bool isItemAvailable() const { return itemIsUsed_ == 0; } @@ -459,9 +459,9 @@ Json::Value obj_value(Json::objectValue); // {} CommentInfo(); ~CommentInfo(); - void setComment(const char *text); + void setComment(const char* text); - char *comment_; + char* comment_; }; // struct MemberNamesTransform @@ -478,12 +478,12 @@ Json::Value obj_value(Json::objectValue); // {} LargestUInt uint_; double real_; bool bool_; - char *string_; + char* string_; #ifdef JSON_VALUE_USE_INTERNAL_MAP - ValueInternalArray *array_; - ValueInternalMap *map_; + ValueInternalArray* array_; + ValueInternalMap* map_; #else - ObjectValues *map_; + ObjectValues* map_; #endif } value_; ValueType type_ : 8; @@ -492,7 +492,7 @@ Json::Value obj_value(Json::objectValue); // {} unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container. int memberNameIsStatic_ : 1; // used by the ValueInternalMap container. #endif - CommentInfo *comments_; + CommentInfo* comments_; // [start, limit) byte offsets in the source JSON text from which this Value // was extracted. @@ -509,8 +509,8 @@ class JSON_API PathArgument { PathArgument(); PathArgument(ArrayIndex index); - PathArgument(const char *key); - PathArgument(const std::string &key); + PathArgument(const char* key); + PathArgument(const std::string& key); private: enum Kind { @@ -536,29 +536,29 @@ class JSON_API PathArgument { */ class JSON_API Path { public: - Path(const std::string &path, - const PathArgument &a1 = PathArgument(), - const PathArgument &a2 = PathArgument(), - const PathArgument &a3 = PathArgument(), - const PathArgument &a4 = PathArgument(), - const PathArgument &a5 = PathArgument()); - - const Value &resolve(const Value &root) const; - Value resolve(const Value &root, const Value &defaultValue) const; + Path(const std::string& path, + const PathArgument& a1 = PathArgument(), + const PathArgument& a2 = PathArgument(), + const PathArgument& a3 = PathArgument(), + const PathArgument& a4 = PathArgument(), + const PathArgument& a5 = PathArgument()); + + const Value& resolve(const Value& root) const; + Value resolve(const Value& root, const Value& defaultValue) const; /// Creates the "path" to access the specified node and returns a reference on /// the node. - Value &make(Value &root) const; + Value& make(Value& root) const; private: - typedef std::vector InArgs; + typedef std::vector InArgs; typedef std::vector Args; - void makePath(const std::string &path, const InArgs &in); - void addPathInArg(const std::string &path, - const InArgs &in, - InArgs::const_iterator &itInArg, + void makePath(const std::string& path, const InArgs& in); + void addPathInArg(const std::string& path, + const InArgs& in, + InArgs::const_iterator& itInArg, PathArgument::Kind kind); - void invalidPath(const std::string &path, int location); + void invalidPath(const std::string& path, int location); Args args_; }; @@ -612,13 +612,13 @@ class JSON_API Path { class JSON_API ValueMapAllocator { public: virtual ~ValueMapAllocator(); - virtual ValueInternalMap *newMap() = 0; - virtual ValueInternalMap *newMapCopy(const ValueInternalMap &other) = 0; - virtual void destructMap(ValueInternalMap *map) = 0; - virtual ValueInternalLink *allocateMapBuckets(unsigned int size) = 0; - virtual void releaseMapBuckets(ValueInternalLink *links) = 0; - virtual ValueInternalLink *allocateMapLink() = 0; - virtual void releaseMapLink(ValueInternalLink *link) = 0; + virtual ValueInternalMap* newMap() = 0; + virtual ValueInternalMap* newMapCopy(const ValueInternalMap& other) = 0; + virtual void destructMap(ValueInternalMap* map) = 0; + virtual ValueInternalLink* allocateMapBuckets(unsigned int size) = 0; + virtual void releaseMapBuckets(ValueInternalLink* links) = 0; + virtual ValueInternalLink* allocateMapLink() = 0; + virtual void releaseMapLink(ValueInternalLink* link) = 0; }; /** \brief ValueInternalMap hash-map bucket chain link (for internal use only). @@ -639,9 +639,9 @@ class JSON_API ValueInternalLink { ~ValueInternalLink(); Value items_[itemPerLink]; - char *keys_[itemPerLink]; - ValueInternalLink *previous_; - ValueInternalLink *next_; + char* keys_[itemPerLink]; + ValueInternalLink* previous_; + ValueInternalLink* next_; }; /** \brief A linked page based hash-table implementation used internally by @@ -672,19 +672,19 @@ class JSON_API ValueInternalMap { #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION struct IteratorState { IteratorState() : map_(0), link_(0), itemIndex_(0), bucketIndex_(0) {} - ValueInternalMap *map_; - ValueInternalLink *link_; + ValueInternalMap* map_; + ValueInternalLink* link_; BucketIndex itemIndex_; BucketIndex bucketIndex_; }; #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION ValueInternalMap(); - ValueInternalMap(const ValueInternalMap &other); - ValueInternalMap &operator=(ValueInternalMap other); + ValueInternalMap(const ValueInternalMap& other); + ValueInternalMap& operator=(ValueInternalMap other); ~ValueInternalMap(); - void swap(ValueInternalMap &other); + void swap(ValueInternalMap& other); BucketIndex size() const; @@ -694,46 +694,46 @@ class JSON_API ValueInternalMap { bool reserve(BucketIndex newItemCount); - const Value *find(const char *key) const; + const Value* find(const char* key) const; - Value *find(const char *key); + Value* find(const char* key); - Value &resolveReference(const char *key, bool isStatic); + Value& resolveReference(const char* key, bool isStatic); - void remove(const char *key); + void remove(const char* key); - void doActualRemove(ValueInternalLink *link, + void doActualRemove(ValueInternalLink* link, BucketIndex index, BucketIndex bucketIndex); - ValueInternalLink *&getLastLinkInBucket(BucketIndex bucketIndex); + ValueInternalLink*& getLastLinkInBucket(BucketIndex bucketIndex); - Value &setNewItem(const char *key, + Value& setNewItem(const char* key, bool isStatic, - ValueInternalLink *link, + ValueInternalLink* link, BucketIndex index); - Value &unsafeAdd(const char *key, bool isStatic, HashKey hashedKey); + Value& unsafeAdd(const char* key, bool isStatic, HashKey hashedKey); - HashKey hash(const char *key) const; + HashKey hash(const char* key) const; - int compare(const ValueInternalMap &other) const; + int compare(const ValueInternalMap& other) const; private: - void makeBeginIterator(IteratorState &it) const; - void makeEndIterator(IteratorState &it) const; - static bool equals(const IteratorState &x, const IteratorState &other); - static void increment(IteratorState &iterator); - static void incrementBucket(IteratorState &iterator); - static void decrement(IteratorState &iterator); - static const char *key(const IteratorState &iterator); - static const char *key(const IteratorState &iterator, bool &isStatic); - static Value &value(const IteratorState &iterator); - static int distance(const IteratorState &x, const IteratorState &y); + void makeBeginIterator(IteratorState& it) const; + void makeEndIterator(IteratorState& it) const; + static bool equals(const IteratorState& x, const IteratorState& other); + static void increment(IteratorState& iterator); + static void incrementBucket(IteratorState& iterator); + static void decrement(IteratorState& iterator); + static const char* key(const IteratorState& iterator); + static const char* key(const IteratorState& iterator, bool& isStatic); + static Value& value(const IteratorState& iterator); + static int distance(const IteratorState& x, const IteratorState& y); private: - ValueInternalLink *buckets_; - ValueInternalLink *tailLink_; + ValueInternalLink* buckets_; + ValueInternalLink* tailLink_; BucketIndex bucketsSize_; BucketIndex itemCount_; }; @@ -767,44 +767,44 @@ class JSON_API ValueInternalArray { struct IteratorState // Must be a POD { IteratorState() : array_(0), currentPageIndex_(0), currentItemIndex_(0) {} - ValueInternalArray *array_; - Value **currentPageIndex_; + ValueInternalArray* array_; + Value** currentPageIndex_; unsigned int currentItemIndex_; }; #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION ValueInternalArray(); - ValueInternalArray(const ValueInternalArray &other); - ValueInternalArray &operator=(ValueInternalArray other); + ValueInternalArray(const ValueInternalArray& other); + ValueInternalArray& operator=(ValueInternalArray other); ~ValueInternalArray(); - void swap(ValueInternalArray &other); + void swap(ValueInternalArray& other); void clear(); void resize(ArrayIndex newSize); - Value &resolveReference(ArrayIndex index); + Value& resolveReference(ArrayIndex index); - Value *find(ArrayIndex index) const; + Value* find(ArrayIndex index) const; ArrayIndex size() const; - int compare(const ValueInternalArray &other) const; + int compare(const ValueInternalArray& other) const; private: - static bool equals(const IteratorState &x, const IteratorState &other); - static void increment(IteratorState &iterator); - static void decrement(IteratorState &iterator); - static Value &dereference(const IteratorState &iterator); - static Value &unsafeDereference(const IteratorState &iterator); - static int distance(const IteratorState &x, const IteratorState &y); - static ArrayIndex indexOf(const IteratorState &iterator); - void makeBeginIterator(IteratorState &it) const; - void makeEndIterator(IteratorState &it) const; - void makeIterator(IteratorState &it, ArrayIndex index) const; + static bool equals(const IteratorState& x, const IteratorState& other); + static void increment(IteratorState& iterator); + static void decrement(IteratorState& iterator); + static Value& dereference(const IteratorState& iterator); + static Value& unsafeDereference(const IteratorState& iterator); + static int distance(const IteratorState& x, const IteratorState& y); + static ArrayIndex indexOf(const IteratorState& iterator); + void makeBeginIterator(IteratorState& it) const; + void makeEndIterator(IteratorState& it) const; + void makeIterator(IteratorState& it, ArrayIndex index) const; void makeIndexValid(ArrayIndex index); - Value **pages_; + Value** pages_; ArrayIndex size_; PageIndex pageCount_; }; @@ -875,9 +875,9 @@ virtual void releaseArrayPage( Value *value ) class JSON_API ValueArrayAllocator { public: virtual ~ValueArrayAllocator(); - virtual ValueInternalArray *newArray() = 0; - virtual ValueInternalArray *newArrayCopy(const ValueInternalArray &other) = 0; - virtual void destructArray(ValueInternalArray *array) = 0; + virtual ValueInternalArray* newArray() = 0; + virtual ValueInternalArray* newArrayCopy(const ValueInternalArray& other) = 0; + virtual void destructArray(ValueInternalArray* array) = 0; /** \brief Reallocate array page index. * Reallocates an array of pointer on each page. * \param indexes [input] pointer on the current index. May be \c NULL. @@ -891,14 +891,14 @@ class JSON_API ValueArrayAllocator { * handle. */ virtual void - reallocateArrayPageIndex(Value **&indexes, - ValueInternalArray::PageIndex &indexCount, + reallocateArrayPageIndex(Value**& indexes, + ValueInternalArray::PageIndex& indexCount, ValueInternalArray::PageIndex minNewIndexCount) = 0; virtual void - releaseArrayPageIndex(Value **indexes, + releaseArrayPageIndex(Value** indexes, ValueInternalArray::PageIndex indexCount) = 0; - virtual Value *allocateArrayPage() = 0; - virtual void releaseArrayPage(Value *value) = 0; + virtual Value* allocateArrayPage() = 0; + virtual void releaseArrayPage(Value* value) = 0; }; #endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP @@ -914,17 +914,17 @@ class JSON_API ValueIteratorBase { ValueIteratorBase(); #ifndef JSON_VALUE_USE_INTERNAL_MAP - explicit ValueIteratorBase(const Value::ObjectValues::iterator ¤t); + explicit ValueIteratorBase(const Value::ObjectValues::iterator& current); #else - ValueIteratorBase(const ValueInternalArray::IteratorState &state); - ValueIteratorBase(const ValueInternalMap::IteratorState &state); + ValueIteratorBase(const ValueInternalArray::IteratorState& state); + ValueIteratorBase(const ValueInternalMap::IteratorState& state); #endif - bool operator==(const SelfType &other) const { return isEqual(other); } + bool operator==(const SelfType& other) const { return isEqual(other); } - bool operator!=(const SelfType &other) const { return !isEqual(other); } + bool operator!=(const SelfType& other) const { return !isEqual(other); } - difference_type operator-(const SelfType &other) const { + difference_type operator-(const SelfType& other) const { return computeDistance(other); } @@ -937,20 +937,20 @@ class JSON_API ValueIteratorBase { /// Return the member name of the referenced Value. "" if it is not an /// objectValue. - const char *memberName() const; + const char* memberName() const; protected: - Value &deref() const; + Value& deref() const; void increment(); void decrement(); - difference_type computeDistance(const SelfType &other) const; + difference_type computeDistance(const SelfType& other) const; - bool isEqual(const SelfType &other) const; + bool isEqual(const SelfType& other) const; - void copy(const SelfType &other); + void copy(const SelfType& other); private: #ifndef JSON_VALUE_USE_INTERNAL_MAP @@ -976,8 +976,8 @@ class JSON_API ValueConstIterator : public ValueIteratorBase { typedef const Value value_type; typedef unsigned int size_t; typedef int difference_type; - typedef const Value &reference; - typedef const Value *pointer; + typedef const Value& reference; + typedef const Value* pointer; typedef ValueConstIterator SelfType; ValueConstIterator(); @@ -986,13 +986,13 @@ class JSON_API ValueConstIterator : public ValueIteratorBase { /*! \internal Use by Value to create an iterator. */ #ifndef JSON_VALUE_USE_INTERNAL_MAP - explicit ValueConstIterator(const Value::ObjectValues::iterator ¤t); + explicit ValueConstIterator(const Value::ObjectValues::iterator& current); #else - ValueConstIterator(const ValueInternalArray::IteratorState &state); - ValueConstIterator(const ValueInternalMap::IteratorState &state); + ValueConstIterator(const ValueInternalArray::IteratorState& state); + ValueConstIterator(const ValueInternalMap::IteratorState& state); #endif public: - SelfType &operator=(const ValueIteratorBase &other); + SelfType& operator=(const ValueIteratorBase& other); SelfType operator++(int) { SelfType temp(*this); @@ -1006,12 +1006,12 @@ class JSON_API ValueConstIterator : public ValueIteratorBase { return temp; } - SelfType &operator--() { + SelfType& operator--() { decrement(); return *this; } - SelfType &operator++() { + SelfType& operator++() { increment(); return *this; } @@ -1030,25 +1030,25 @@ class JSON_API ValueIterator : public ValueIteratorBase { typedef Value value_type; typedef unsigned int size_t; typedef int difference_type; - typedef Value &reference; - typedef Value *pointer; + typedef Value& reference; + typedef Value* pointer; typedef ValueIterator SelfType; ValueIterator(); - ValueIterator(const ValueConstIterator &other); - ValueIterator(const ValueIterator &other); + ValueIterator(const ValueConstIterator& other); + ValueIterator(const ValueIterator& other); private: /*! \internal Use by Value to create an iterator. */ #ifndef JSON_VALUE_USE_INTERNAL_MAP - explicit ValueIterator(const Value::ObjectValues::iterator ¤t); + explicit ValueIterator(const Value::ObjectValues::iterator& current); #else - ValueIterator(const ValueInternalArray::IteratorState &state); - ValueIterator(const ValueInternalMap::IteratorState &state); + ValueIterator(const ValueInternalArray::IteratorState& state); + ValueIterator(const ValueInternalMap::IteratorState& state); #endif public: - SelfType &operator=(const SelfType &other); + SelfType& operator=(const SelfType& other); SelfType operator++(int) { SelfType temp(*this); @@ -1062,12 +1062,12 @@ class JSON_API ValueIterator : public ValueIteratorBase { return temp; } - SelfType &operator--() { + SelfType& operator--() { decrement(); return *this; } - SelfType &operator++() { + SelfType& operator++() { increment(); return *this; } diff --git a/include/json/writer.h b/include/json/writer.h index fa79c2cff..dc9e46f4b 100644 --- a/include/json/writer.h +++ b/include/json/writer.h @@ -29,7 +29,7 @@ class JSON_API Writer { public: virtual ~Writer(); - virtual std::string write(const Value &root) = 0; + virtual std::string write(const Value& root) = 0; }; /** \brief Outputs a Value in JSON format @@ -57,10 +57,10 @@ class JSON_API FastWriter : public Writer { void omitEndingLineFeed(); public: // overridden from Writer - virtual std::string write(const Value &root); + virtual std::string write(const Value& root); private: - void writeValue(const Value &value); + void writeValue(const Value& value); std::string document_; bool yamlCompatiblityEnabled_; @@ -101,21 +101,21 @@ class JSON_API StyledWriter : public Writer { * \param root Value to serialize. * \return String containing the JSON document that represents the root value. */ - virtual std::string write(const Value &root); + virtual std::string write(const Value& root); private: - void writeValue(const Value &value); - void writeArrayValue(const Value &value); - bool isMultineArray(const Value &value); - void pushValue(const std::string &value); + void writeValue(const Value& value); + void writeArrayValue(const Value& value); + bool isMultineArray(const Value& value); + void pushValue(const std::string& value); void writeIndent(); - void writeWithIndent(const std::string &value); + void writeWithIndent(const std::string& value); void indent(); void unindent(); - void writeCommentBeforeValue(const Value &root); - void writeCommentAfterValueOnSameLine(const Value &root); - bool hasCommentForValue(const Value &value); - static std::string normalizeEOL(const std::string &text); + void writeCommentBeforeValue(const Value& root); + void writeCommentAfterValueOnSameLine(const Value& root); + bool hasCommentForValue(const Value& value); + static std::string normalizeEOL(const std::string& text); typedef std::vector ChildValues; @@ -164,26 +164,26 @@ class JSON_API StyledStreamWriter { * \note There is no point in deriving from Writer, since write() should not * return a value. */ - void write(std::ostream &out, const Value &root); + void write(std::ostream& out, const Value& root); private: - void writeValue(const Value &value); - void writeArrayValue(const Value &value); - bool isMultineArray(const Value &value); - void pushValue(const std::string &value); + void writeValue(const Value& value); + void writeArrayValue(const Value& value); + bool isMultineArray(const Value& value); + void pushValue(const std::string& value); void writeIndent(); - void writeWithIndent(const std::string &value); + void writeWithIndent(const std::string& value); void indent(); void unindent(); - void writeCommentBeforeValue(const Value &root); - void writeCommentAfterValueOnSameLine(const Value &root); - bool hasCommentForValue(const Value &value); - static std::string normalizeEOL(const std::string &text); + void writeCommentBeforeValue(const Value& root); + void writeCommentAfterValueOnSameLine(const Value& root); + bool hasCommentForValue(const Value& value); + static std::string normalizeEOL(const std::string& text); typedef std::vector ChildValues; ChildValues childValues_; - std::ostream *document_; + std::ostream* document_; std::string indentString_; int rightMargin_; std::string indentation_; @@ -198,11 +198,11 @@ std::string JSON_API valueToString(LargestInt value); std::string JSON_API valueToString(LargestUInt value); std::string JSON_API valueToString(double value); std::string JSON_API valueToString(bool value); -std::string JSON_API valueToQuotedString(const char *value); +std::string JSON_API valueToQuotedString(const char* value); /// \brief Output using the StyledStreamWriter. /// \see Json::operator>>() -JSON_API std::ostream &operator<<(std::ostream &, const Value &root); +JSON_API std::ostream& operator<<(std::ostream&, const Value& root); } // namespace Json diff --git a/src/jsontestrunner/main.cpp b/src/jsontestrunner/main.cpp index e32db0391..338167e9c 100644 --- a/src/jsontestrunner/main.cpp +++ b/src/jsontestrunner/main.cpp @@ -42,15 +42,15 @@ static std::string normalizeFloatingPointStr(double value) { return s; } -static std::string readInputTestFile(const char *path) { - FILE *file = fopen(path, "rb"); +static std::string readInputTestFile(const char* path) { + FILE* file = fopen(path, "rb"); if (!file) return std::string(""); fseek(file, 0, SEEK_END); long size = ftell(file); fseek(file, 0, SEEK_SET); std::string text; - char *buffer = new char[size + 1]; + char* buffer = new char[size + 1]; buffer[size] = 0; if (fread(buffer, 1, size, file) == (unsigned long)size) text = buffer; @@ -60,7 +60,7 @@ static std::string readInputTestFile(const char *path) { } static void -printValueTree(FILE *fout, Json::Value &value, const std::string &path = ".") { +printValueTree(FILE* fout, Json::Value& value, const std::string& path = ".") { switch (value.type()) { case Json::nullValue: fprintf(fout, "%s=null\n", path.c_str()); @@ -110,7 +110,7 @@ printValueTree(FILE *fout, Json::Value &value, const std::string &path = ".") { for (Json::Value::Members::iterator it = members.begin(); it != members.end(); ++it) { - const std::string &name = *it; + const std::string& name = *it; printValueTree(fout, value[name], path + suffix + name); } } break; @@ -119,11 +119,11 @@ printValueTree(FILE *fout, Json::Value &value, const std::string &path = ".") { } } -static int parseAndSaveValueTree(const std::string &input, - const std::string &actual, - const std::string &kind, - Json::Value &root, - const Json::Features &features, +static int parseAndSaveValueTree(const std::string& input, + const std::string& actual, + const std::string& kind, + Json::Value& root, + const Json::Features& features, bool parseOnly) { Json::Reader reader(features); bool parsingSuccessful = reader.parse(input, root); @@ -135,7 +135,7 @@ static int parseAndSaveValueTree(const std::string &input, } if (!parseOnly) { - FILE *factual = fopen(actual.c_str(), "wt"); + FILE* factual = fopen(actual.c_str(), "wt"); if (!factual) { printf("Failed to create %s actual file.\n", kind.c_str()); return 2; @@ -146,14 +146,14 @@ static int parseAndSaveValueTree(const std::string &input, return 0; } -static int rewriteValueTree(const std::string &rewritePath, - const Json::Value &root, - std::string &rewrite) { +static int rewriteValueTree(const std::string& rewritePath, + const Json::Value& root, + std::string& rewrite) { // Json::FastWriter writer; // writer.enableYAMLCompatibility(); Json::StyledWriter writer; rewrite = writer.write(root); - FILE *fout = fopen(rewritePath.c_str(), "wt"); + FILE* fout = fopen(rewritePath.c_str(), "wt"); if (!fout) { printf("Failed to create rewrite file: %s\n", rewritePath.c_str()); return 2; @@ -163,8 +163,8 @@ static int rewriteValueTree(const std::string &rewritePath, return 0; } -static std::string removeSuffix(const std::string &path, - const std::string &extension) { +static std::string removeSuffix(const std::string& path, + const std::string& extension) { if (extension.length() >= path.length()) return std::string(""); std::string suffix = path.substr(path.length() - extension.length()); @@ -182,16 +182,16 @@ static void printConfig() { #endif } -static int printUsage(const char *argv[]) { +static int printUsage(const char* argv[]) { printf("Usage: %s [--strict] input-json-file", argv[0]); return 3; } int parseCommandLine(int argc, - const char *argv[], - Json::Features &features, - std::string &path, - bool &parseOnly) { + const char* argv[], + Json::Features& features, + std::string& path, + bool& parseOnly) { parseOnly = false; if (argc < 2) { return printUsage(argv); @@ -217,7 +217,7 @@ int parseCommandLine(int argc, return 0; } -int main(int argc, const char *argv[]) { +int main(int argc, const char* argv[]) { std::string path; Json::Features features; bool parseOnly; @@ -261,7 +261,7 @@ int main(int argc, const char *argv[]) { } } } - catch (const std::exception &e) { + catch (const std::exception& e) { printf("Unhandled exception:\n%s\n", e.what()); exitCode = 1; } diff --git a/src/lib_json/json_batchallocator.h b/src/lib_json/json_batchallocator.h index a4703b27e..2fbef7a86 100644 --- a/src/lib_json/json_batchallocator.h +++ b/src/lib_json/json_batchallocator.h @@ -33,16 +33,16 @@ class BatchAllocator { // printf( "Size: %d => %s\n", sizeof(AllocatedType), // typeid(AllocatedType).name() ); assert(sizeof(AllocatedType) * objectPerAllocation >= - sizeof(AllocatedType *)); // We must be able to store a slist in the - // object free space. + sizeof(AllocatedType*)); // We must be able to store a slist in the + // object free space. assert(objectsPerPage >= 16); batches_ = allocateBatch(0); // allocated a dummy page currentBatch_ = batches_; } ~BatchAllocator() { - for (BatchInfo *batch = batches_; batch;) { - BatchInfo *nextBatch = batch->next_; + for (BatchInfo* batch = batches_; batch;) { + BatchInfo* nextBatch = batch->next_; free(batch); batch = nextBatch; } @@ -51,11 +51,11 @@ class BatchAllocator { /// allocate space for an array of objectPerAllocation object. /// @warning it is the responsability of the caller to call objects /// constructors. - AllocatedType *allocate() { + AllocatedType* allocate() { if (freeHead_) // returns node from free list. { - AllocatedType *object = freeHead_; - freeHead_ = *(AllocatedType **)object; + AllocatedType* object = freeHead_; + freeHead_ = *(AllocatedType**)object; return object; } if (currentBatch_->used_ == currentBatch_->end_) { @@ -70,7 +70,7 @@ class BatchAllocator { batches_ = currentBatch_; } } - AllocatedType *allocated = currentBatch_->used_; + AllocatedType* allocated = currentBatch_->used_; currentBatch_->used_ += objectPerAllocation; return allocated; } @@ -78,39 +78,39 @@ class BatchAllocator { /// Release the object. /// @warning it is the responsability of the caller to actually destruct the /// object. - void release(AllocatedType *object) { + void release(AllocatedType* object) { assert(object != 0); - *(AllocatedType **)object = freeHead_; + *(AllocatedType**)object = freeHead_; freeHead_ = object; } private: struct BatchInfo { - BatchInfo *next_; - AllocatedType *used_; - AllocatedType *end_; + BatchInfo* next_; + AllocatedType* used_; + AllocatedType* end_; AllocatedType buffer_[objectPerAllocation]; }; // disabled copy constructor and assignement operator. - BatchAllocator(const BatchAllocator &); - void operator=(const BatchAllocator &); + BatchAllocator(const BatchAllocator&); + void operator=(const BatchAllocator&); - static BatchInfo *allocateBatch(unsigned int objectsPerPage) { + static BatchInfo* allocateBatch(unsigned int objectsPerPage) { const unsigned int mallocSize = sizeof(BatchInfo) - sizeof(AllocatedType) * objectPerAllocation + sizeof(AllocatedType) * objectPerAllocation * objectsPerPage; - BatchInfo *batch = static_cast(malloc(mallocSize)); + BatchInfo* batch = static_cast(malloc(mallocSize)); batch->next_ = 0; batch->used_ = batch->buffer_; batch->end_ = batch->buffer_ + objectsPerPage; return batch; } - BatchInfo *batches_; - BatchInfo *currentBatch_; + BatchInfo* batches_; + BatchInfo* currentBatch_; /// Head of a single linked list within the allocated space of freeed object - AllocatedType *freeHead_; + AllocatedType* freeHead_; unsigned int objectsPerPage_; }; diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index 30071a1a3..668390020 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -75,20 +75,20 @@ Reader::Reader() lastValue_(), commentsBefore_(), features_(Features::all()), collectComments_() {} -Reader::Reader(const Features &features) +Reader::Reader(const Features& features) : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(), lastValue_(), commentsBefore_(), features_(features), collectComments_() { } bool -Reader::parse(const std::string &document, Value &root, bool collectComments) { +Reader::parse(const std::string& document, Value& root, bool collectComments) { document_ = document; - const char *begin = document_.c_str(); - const char *end = begin + document_.length(); + const char* begin = document_.c_str(); + const char* end = begin + document_.length(); return parse(begin, end, root, collectComments); } -bool Reader::parse(std::istream &sin, Value &root, bool collectComments) { +bool Reader::parse(std::istream& sin, Value& root, bool collectComments) { // std::istream_iterator begin(sin); // std::istream_iterator end; // Those would allow streamed input from a file, if parse() were a @@ -101,9 +101,9 @@ bool Reader::parse(std::istream &sin, Value &root, bool collectComments) { return parse(doc, root, collectComments); } -bool Reader::parse(const char *beginDoc, - const char *endDoc, - Value &root, +bool Reader::parse(const char* beginDoc, + const char* endDoc, + Value& root, bool collectComments) { if (!features_.allowComments_) { collectComments = false; @@ -215,7 +215,7 @@ bool Reader::readValue() { return successful; } -void Reader::skipCommentTokens(Token &token) { +void Reader::skipCommentTokens(Token& token) { if (features_.allowComments_) { do { readToken(token); @@ -225,14 +225,14 @@ void Reader::skipCommentTokens(Token &token) { } } -bool Reader::expectToken(TokenType type, Token &token, const char *message) { +bool Reader::expectToken(TokenType type, Token& token, const char* message) { readToken(token); if (token.type_ != type) return addError(message, token); return true; } -bool Reader::readToken(Token &token) { +bool Reader::readToken(Token& token) { skipSpaces(); token.start_ = current_; Char c = getNextChar(); @@ -399,7 +399,7 @@ bool Reader::readString() { return c == '"'; } -bool Reader::readObject(Token &tokenStart) { +bool Reader::readObject(Token& tokenStart) { Token tokenName; std::string name; currentValue() = Value(objectValue); @@ -430,7 +430,7 @@ bool Reader::readObject(Token &tokenStart) { return addErrorAndRecover( "Missing ':' after object member name", colon, tokenObjectEnd); } - Value &value = currentValue()[name]; + Value& value = currentValue()[name]; nodes_.push(&value); bool ok = readValue(); nodes_.pop(); @@ -454,7 +454,7 @@ bool Reader::readObject(Token &tokenStart) { "Missing '}' or object member name", tokenName, tokenObjectEnd); } -bool Reader::readArray(Token &tokenStart) { +bool Reader::readArray(Token& tokenStart) { currentValue() = Value(arrayValue); currentValue().setOffsetStart(tokenStart.start_ - begin_); skipSpaces(); @@ -466,7 +466,7 @@ bool Reader::readArray(Token &tokenStart) { } int index = 0; for (;;) { - Value &value = currentValue()[index++]; + Value& value = currentValue()[index++]; nodes_.push(&value); bool ok = readValue(); nodes_.pop(); @@ -491,7 +491,7 @@ bool Reader::readArray(Token &tokenStart) { return true; } -bool Reader::decodeNumber(Token &token) { +bool Reader::decodeNumber(Token& token) { Value decoded; if (!decodeNumber(token, decoded)) return false; @@ -501,7 +501,7 @@ bool Reader::decodeNumber(Token &token) { return true; } -bool Reader::decodeNumber(Token &token, Value &decoded) { +bool Reader::decodeNumber(Token& token, Value& decoded) { bool isDouble = false; for (Location inspect = token.start_; inspect != token.end_; ++inspect) { isDouble = isDouble || in(*inspect, '.', 'e', 'E', '+') || @@ -549,7 +549,7 @@ bool Reader::decodeNumber(Token &token, Value &decoded) { return true; } -bool Reader::decodeDouble(Token &token) { +bool Reader::decodeDouble(Token& token) { Value decoded; if (!decodeDouble(token, decoded)) return false; @@ -559,7 +559,7 @@ bool Reader::decodeDouble(Token &token) { return true; } -bool Reader::decodeDouble(Token &token, Value &decoded) { +bool Reader::decodeDouble(Token& token, Value& decoded) { double value = 0; const int bufferSize = 32; int count; @@ -595,7 +595,7 @@ bool Reader::decodeDouble(Token &token, Value &decoded) { return true; } -bool Reader::decodeString(Token &token) { +bool Reader::decodeString(Token& token) { std::string decoded; if (!decodeString(token, decoded)) return false; @@ -605,7 +605,7 @@ bool Reader::decodeString(Token &token) { return true; } -bool Reader::decodeString(Token &token, std::string &decoded) { +bool Reader::decodeString(Token& token, std::string& decoded) { decoded.reserve(token.end_ - token.start_ - 2); Location current = token.start_ + 1; // skip '"' Location end = token.end_ - 1; // do not include '"' @@ -658,10 +658,10 @@ bool Reader::decodeString(Token &token, std::string &decoded) { return true; } -bool Reader::decodeUnicodeCodePoint(Token &token, - Location ¤t, +bool Reader::decodeUnicodeCodePoint(Token& token, + Location& current, Location end, - unsigned int &unicode) { + unsigned int& unicode) { if (!decodeUnicodeEscapeSequence(token, current, end, unicode)) return false; @@ -687,10 +687,10 @@ bool Reader::decodeUnicodeCodePoint(Token &token, return true; } -bool Reader::decodeUnicodeEscapeSequence(Token &token, - Location ¤t, +bool Reader::decodeUnicodeEscapeSequence(Token& token, + Location& current, Location end, - unsigned int &unicode) { + unsigned int& unicode) { if (end - current < 4) return addError( "Bad unicode escape sequence in string: four digits expected.", @@ -716,7 +716,7 @@ bool Reader::decodeUnicodeEscapeSequence(Token &token, } bool -Reader::addError(const std::string &message, Token &token, Location extra) { +Reader::addError(const std::string& message, Token& token, Location extra) { ErrorInfo info; info.token_ = token; info.message_ = message; @@ -738,14 +738,14 @@ bool Reader::recoverFromError(TokenType skipUntilToken) { return false; } -bool Reader::addErrorAndRecover(const std::string &message, - Token &token, +bool Reader::addErrorAndRecover(const std::string& message, + Token& token, TokenType skipUntilToken) { addError(message, token); return recoverFromError(skipUntilToken); } -Value &Reader::currentValue() { return *(nodes_.top()); } +Value& Reader::currentValue() { return *(nodes_.top()); } Reader::Char Reader::getNextChar() { if (current_ == end_) @@ -754,8 +754,8 @@ Reader::Char Reader::getNextChar() { } void Reader::getLocationLineAndColumn(Location location, - int &line, - int &column) const { + int& line, + int& column) const { Location current = begin_; Location lastLineStart = current; line = 0; @@ -802,7 +802,7 @@ std::string Reader::getFormattedErrorMessages() const { for (Errors::const_iterator itError = errors_.begin(); itError != errors_.end(); ++itError) { - const ErrorInfo &error = *itError; + const ErrorInfo& error = *itError; formattedMessage += "* " + getLocationLineAndColumn(error.token_.start_) + "\n"; formattedMessage += " " + error.message_ + "\n"; @@ -818,7 +818,7 @@ std::vector Reader::getStructuredErrors() const { for (Errors::const_iterator itError = errors_.begin(); itError != errors_.end(); ++itError) { - const ErrorInfo &error = *itError; + const ErrorInfo& error = *itError; Reader::StructuredError structured; structured.offset_start = error.token_.start_ - begin_; structured.offset_limit = error.token_.end_ - begin_; @@ -828,7 +828,7 @@ std::vector Reader::getStructuredErrors() const { return allErrors; } -std::istream &operator>>(std::istream &sin, Value &root) { +std::istream& operator>>(std::istream& sin, Value& root) { Json::Reader reader; bool ok = reader.parse(sin, root, true); if (!ok) { diff --git a/src/lib_json/json_tool.h b/src/lib_json/json_tool.h index 1c067af5c..f9b61c38c 100644 --- a/src/lib_json/json_tool.h +++ b/src/lib_json/json_tool.h @@ -60,7 +60,7 @@ typedef char UIntToStringBuffer[uintToStringBufferSize]; * @param current Input/Output string buffer. * Must have at least uintToStringBufferSize chars free. */ -static inline void uintToString(LargestUInt value, char *¤t) { +static inline void uintToString(LargestUInt value, char*& current) { *--current = 0; do { *--current = char(value % 10) + '0'; @@ -73,7 +73,7 @@ static inline void uintToString(LargestUInt value, char *¤t) { * We had a sophisticated way, but it did not work in WinCE. * @see https://github.com/open-source-parsers/jsoncpp/pull/9 */ -static inline void fixNumericLocale(char *begin, char *end) { +static inline void fixNumericLocale(char* begin, char* end) { while (begin < end) { if (*begin == ',') { *begin = '.'; diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index 51efa5743..2a0b97bbb 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -34,8 +34,8 @@ namespace Json { #define ALIGNAS(byte_alignment) #endif static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 }; -const unsigned char &kNullRef = kNull[0]; -const Value &Value::null = reinterpret_cast(kNullRef); +const unsigned char& kNullRef = kNull[0]; +const Value& Value::null = reinterpret_cast(kNullRef); const Int Value::minInt = Int(~(UInt(-1) / 2)); const Int Value::maxInt = Int(UInt(-1) / 2); @@ -83,7 +83,7 @@ static inline bool InRange(double d, T min, U max) { * computed using strlen(value). * @return Pointer on the duplicate instance of string. */ -static inline char *duplicateStringValue(const char *value, +static inline char* duplicateStringValue(const char* value, unsigned int length = unknown) { if (length == unknown) length = (unsigned int)strlen(value); @@ -93,7 +93,7 @@ static inline char *duplicateStringValue(const char *value, if (length >= (unsigned)Value::maxInt) length = Value::maxInt - 1; - char *newString = static_cast(malloc(length + 1)); + char* newString = static_cast(malloc(length + 1)); JSON_ASSERT_MESSAGE(newString != 0, "in Json::Value::duplicateStringValue(): " "Failed to allocate string value buffer"); @@ -104,7 +104,7 @@ static inline char *duplicateStringValue(const char *value, /** Free the string duplicated by duplicateStringValue(). */ -static inline void releaseStringValue(char *value) { free(value); } +static inline void releaseStringValue(char* value) { free(value); } } // namespace Json @@ -141,7 +141,7 @@ Value::CommentInfo::~CommentInfo() { releaseStringValue(comment_); } -void Value::CommentInfo::setComment(const char *text) { +void Value::CommentInfo::setComment(const char* text) { if (comment_) releaseStringValue(comment_); JSON_ASSERT(text != 0); @@ -166,11 +166,11 @@ void Value::CommentInfo::setComment(const char *text) { Value::CZString::CZString(ArrayIndex index) : cstr_(0), index_(index) {} -Value::CZString::CZString(const char *cstr, DuplicationPolicy allocate) +Value::CZString::CZString(const char* cstr, DuplicationPolicy allocate) : cstr_(allocate == duplicate ? duplicateStringValue(cstr) : cstr), index_(allocate) {} -Value::CZString::CZString(const CZString &other) +Value::CZString::CZString(const CZString& other) : cstr_(other.index_ != noDuplication && other.cstr_ != 0 ? duplicateStringValue(other.cstr_) : other.cstr_), @@ -180,26 +180,26 @@ Value::CZString::CZString(const CZString &other) Value::CZString::~CZString() { if (cstr_ && index_ == duplicate) - releaseStringValue(const_cast(cstr_)); + releaseStringValue(const_cast(cstr_)); } -void Value::CZString::swap(CZString &other) { +void Value::CZString::swap(CZString& other) { std::swap(cstr_, other.cstr_); std::swap(index_, other.index_); } -Value::CZString &Value::CZString::operator=(CZString other) { +Value::CZString& Value::CZString::operator=(CZString other) { swap(other); return *this; } -bool Value::CZString::operator<(const CZString &other) const { +bool Value::CZString::operator<(const CZString& other) const { if (cstr_) return strcmp(cstr_, other.cstr_) < 0; return index_ < other.index_; } -bool Value::CZString::operator==(const CZString &other) const { +bool Value::CZString::operator==(const CZString& other) const { if (cstr_) return strcmp(cstr_, other.cstr_) == 0; return index_ == other.index_; @@ -207,7 +207,7 @@ bool Value::CZString::operator==(const CZString &other) const { ArrayIndex Value::CZString::index() const { return index_; } -const char *Value::CZString::c_str() const { return cstr_; } +const char* Value::CZString::c_str() const { return cstr_; } bool Value::CZString::isStaticString() const { return index_ == noDuplication; } @@ -324,7 +324,7 @@ Value::Value(double value) value_.real_ = value; } -Value::Value(const char *value) +Value::Value(const char* value) : type_(stringValue), allocated_(true) #ifdef JSON_VALUE_USE_INTERNAL_MAP , @@ -335,7 +335,7 @@ Value::Value(const char *value) value_.string_ = duplicateStringValue(value); } -Value::Value(const char *beginValue, const char *endValue) +Value::Value(const char* beginValue, const char* endValue) : type_(stringValue), allocated_(true) #ifdef JSON_VALUE_USE_INTERNAL_MAP , @@ -347,7 +347,7 @@ Value::Value(const char *beginValue, const char *endValue) duplicateStringValue(beginValue, (unsigned int)(endValue - beginValue)); } -Value::Value(const std::string &value) +Value::Value(const std::string& value) : type_(stringValue), allocated_(true) #ifdef JSON_VALUE_USE_INTERNAL_MAP , @@ -359,7 +359,7 @@ Value::Value(const std::string &value) duplicateStringValue(value.c_str(), (unsigned int)value.length()); } -Value::Value(const StaticString &value) +Value::Value(const StaticString& value) : type_(stringValue), allocated_(false) #ifdef JSON_VALUE_USE_INTERNAL_MAP , @@ -367,11 +367,11 @@ Value::Value(const StaticString &value) #endif , comments_(0), start_(0), limit_(0) { - value_.string_ = const_cast(value.c_str()); + value_.string_ = const_cast(value.c_str()); } #ifdef JSON_USE_CPPTL -Value::Value(const CppTL::ConstString &value) +Value::Value(const CppTL::ConstString& value) : type_(stringValue), allocated_(true) #ifdef JSON_VALUE_USE_INTERNAL_MAP , @@ -394,7 +394,7 @@ Value::Value(bool value) value_.bool_ = value; } -Value::Value(const Value &other) +Value::Value(const Value& other) : type_(other.type_), allocated_(false) #ifdef JSON_VALUE_USE_INTERNAL_MAP , @@ -438,7 +438,7 @@ Value::Value(const Value &other) if (other.comments_) { comments_ = new CommentInfo[numberOfCommentPlacement]; for (int comment = 0; comment < numberOfCommentPlacement; ++comment) { - const CommentInfo &otherComment = other.comments_[comment]; + const CommentInfo& otherComment = other.comments_[comment]; if (otherComment.comment_) comments_[comment].setComment(otherComment.comment_); } @@ -478,12 +478,12 @@ Value::~Value() { delete[] comments_; } -Value &Value::operator=(Value other) { +Value& Value::operator=(Value other) { swap(other); return *this; } -void Value::swap(Value &other) { +void Value::swap(Value& other) { ValueType temp = type_; type_ = other.type_; other.type_ = temp; @@ -497,7 +497,7 @@ void Value::swap(Value &other) { ValueType Value::type() const { return type_; } -int Value::compare(const Value &other) const { +int Value::compare(const Value& other) const { if (*this < other) return -1; if (*this > other) @@ -505,7 +505,7 @@ int Value::compare(const Value &other) const { return 0; } -bool Value::operator<(const Value &other) const { +bool Value::operator<(const Value& other) const { int typeDelta = type_ - other.type_; if (typeDelta) return typeDelta < 0 ? true : false; @@ -544,13 +544,13 @@ bool Value::operator<(const Value &other) const { return false; // unreachable } -bool Value::operator<=(const Value &other) const { return !(other < *this); } +bool Value::operator<=(const Value& other) const { return !(other < *this); } -bool Value::operator>=(const Value &other) const { return !(*this < other); } +bool Value::operator>=(const Value& other) const { return !(*this < other); } -bool Value::operator>(const Value &other) const { return other < *this; } +bool Value::operator>(const Value& other) const { return other < *this; } -bool Value::operator==(const Value &other) const { +bool Value::operator==(const Value& other) const { // if ( type_ != other.type_ ) // GCC 2.95.3 says: // attempt to take address of bit-field structure member `Json::Value::type_' @@ -590,9 +590,9 @@ bool Value::operator==(const Value &other) const { return false; // unreachable } -bool Value::operator!=(const Value &other) const { return !(*this == other); } +bool Value::operator!=(const Value& other) const { return !(*this == other); } -const char *Value::asCString() const { +const char* Value::asCString() const { JSON_ASSERT_MESSAGE(type_ == stringValue, "in Json::Value::asCString(): requires stringValue"); return value_.string_; @@ -910,7 +910,7 @@ void Value::resize(ArrayIndex newSize) { #endif } -Value &Value::operator[](ArrayIndex index) { +Value& Value::operator[](ArrayIndex index) { JSON_ASSERT_MESSAGE( type_ == nullValue || type_ == arrayValue, "in Json::Value::operator[](ArrayIndex): requires arrayValue"); @@ -930,14 +930,14 @@ Value &Value::operator[](ArrayIndex index) { #endif } -Value &Value::operator[](int index) { +Value& Value::operator[](int index) { JSON_ASSERT_MESSAGE( index >= 0, "in Json::Value::operator[](int index): index cannot be negative"); return (*this)[ArrayIndex(index)]; } -const Value &Value::operator[](ArrayIndex index) const { +const Value& Value::operator[](ArrayIndex index) const { JSON_ASSERT_MESSAGE( type_ == nullValue || type_ == arrayValue, "in Json::Value::operator[](ArrayIndex)const: requires arrayValue"); @@ -950,23 +950,23 @@ const Value &Value::operator[](ArrayIndex index) const { return null; return (*it).second; #else - Value *value = value_.array_->find(index); + Value* value = value_.array_->find(index); return value ? *value : null; #endif } -const Value &Value::operator[](int index) const { +const Value& Value::operator[](int index) const { JSON_ASSERT_MESSAGE( index >= 0, "in Json::Value::operator[](int index) const: index cannot be negative"); return (*this)[ArrayIndex(index)]; } -Value &Value::operator[](const char *key) { +Value& Value::operator[](const char* key) { return resolveReference(key, false); } -Value &Value::resolveReference(const char *key, bool isStatic) { +Value& Value::resolveReference(const char* key, bool isStatic) { JSON_ASSERT_MESSAGE( type_ == nullValue || type_ == objectValue, "in Json::Value::resolveReference(): requires objectValue"); @@ -981,21 +981,21 @@ Value &Value::resolveReference(const char *key, bool isStatic) { ObjectValues::value_type defaultValue(actualKey, null); it = value_.map_->insert(it, defaultValue); - Value &value = (*it).second; + Value& value = (*it).second; return value; #else return value_.map_->resolveReference(key, isStatic); #endif } -Value Value::get(ArrayIndex index, const Value &defaultValue) const { - const Value *value = &((*this)[index]); +Value Value::get(ArrayIndex index, const Value& defaultValue) const { + const Value* value = &((*this)[index]); return value == &null ? defaultValue : *value; } bool Value::isValidIndex(ArrayIndex index) const { return index < size(); } -const Value &Value::operator[](const char *key) const { +const Value& Value::operator[](const char* key) const { JSON_ASSERT_MESSAGE( type_ == nullValue || type_ == objectValue, "in Json::Value::operator[](char const*)const: requires objectValue"); @@ -1008,45 +1008,45 @@ const Value &Value::operator[](const char *key) const { return null; return (*it).second; #else - const Value *value = value_.map_->find(key); + const Value* value = value_.map_->find(key); return value ? *value : null; #endif } -Value &Value::operator[](const std::string &key) { +Value& Value::operator[](const std::string& key) { return (*this)[key.c_str()]; } -const Value &Value::operator[](const std::string &key) const { +const Value& Value::operator[](const std::string& key) const { return (*this)[key.c_str()]; } -Value &Value::operator[](const StaticString &key) { +Value& Value::operator[](const StaticString& key) { return resolveReference(key, true); } #ifdef JSON_USE_CPPTL -Value &Value::operator[](const CppTL::ConstString &key) { +Value& Value::operator[](const CppTL::ConstString& key) { return (*this)[key.c_str()]; } -const Value &Value::operator[](const CppTL::ConstString &key) const { +const Value& Value::operator[](const CppTL::ConstString& key) const { return (*this)[key.c_str()]; } #endif -Value &Value::append(const Value &value) { return (*this)[size()] = value; } +Value& Value::append(const Value& value) { return (*this)[size()] = value; } -Value Value::get(const char *key, const Value &defaultValue) const { - const Value *value = &((*this)[key]); +Value Value::get(const char* key, const Value& defaultValue) const { + const Value* value = &((*this)[key]); return value == &null ? defaultValue : *value; } -Value Value::get(const std::string &key, const Value &defaultValue) const { +Value Value::get(const std::string& key, const Value& defaultValue) const { return get(key.c_str(), defaultValue); } -Value Value::removeMember(const char *key) { +Value Value::removeMember(const char* key) { JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue, "in Json::Value::removeMember(): requires objectValue"); if (type_ == nullValue) @@ -1060,7 +1060,7 @@ Value Value::removeMember(const char *key) { value_.map_->erase(it); return old; #else - Value *value = value_.map_->find(key); + Value* value = value_.map_->find(key); if (value) { Value old(*value); value_.map_.remove(key); @@ -1071,28 +1071,28 @@ Value Value::removeMember(const char *key) { #endif } -Value Value::removeMember(const std::string &key) { +Value Value::removeMember(const std::string& key) { return removeMember(key.c_str()); } #ifdef JSON_USE_CPPTL -Value Value::get(const CppTL::ConstString &key, - const Value &defaultValue) const { +Value Value::get(const CppTL::ConstString& key, + const Value& defaultValue) const { return get(key.c_str(), defaultValue); } #endif -bool Value::isMember(const char *key) const { - const Value *value = &((*this)[key]); +bool Value::isMember(const char* key) const { + const Value* value = &((*this)[key]); return value != &null; } -bool Value::isMember(const std::string &key) const { +bool Value::isMember(const std::string& key) const { return isMember(key.c_str()); } #ifdef JSON_USE_CPPTL -bool Value::isMember(const CppTL::ConstString &key) const { +bool Value::isMember(const CppTL::ConstString& key) const { return isMember(key.c_str()); } #endif @@ -1243,13 +1243,13 @@ bool Value::isArray() const { return type_ == arrayValue; } bool Value::isObject() const { return type_ == objectValue; } -void Value::setComment(const char *comment, CommentPlacement placement) { +void Value::setComment(const char* comment, CommentPlacement placement) { if (!comments_) comments_ = new CommentInfo[numberOfCommentPlacement]; comments_[placement].setComment(comment); } -void Value::setComment(const std::string &comment, CommentPlacement placement) { +void Value::setComment(const std::string& comment, CommentPlacement placement) { setComment(comment.c_str(), placement); } @@ -1404,21 +1404,21 @@ PathArgument::PathArgument() : key_(), index_(), kind_(kindNone) {} PathArgument::PathArgument(ArrayIndex index) : key_(), index_(index), kind_(kindIndex) {} -PathArgument::PathArgument(const char *key) +PathArgument::PathArgument(const char* key) : key_(key), index_(), kind_(kindKey) {} -PathArgument::PathArgument(const std::string &key) +PathArgument::PathArgument(const std::string& key) : key_(key.c_str()), index_(), kind_(kindKey) {} // class Path // ////////////////////////////////////////////////////////////////// -Path::Path(const std::string &path, - const PathArgument &a1, - const PathArgument &a2, - const PathArgument &a3, - const PathArgument &a4, - const PathArgument &a5) { +Path::Path(const std::string& path, + const PathArgument& a1, + const PathArgument& a2, + const PathArgument& a3, + const PathArgument& a4, + const PathArgument& a5) { InArgs in; in.push_back(&a1); in.push_back(&a2); @@ -1428,9 +1428,9 @@ Path::Path(const std::string &path, makePath(path, in); } -void Path::makePath(const std::string &path, const InArgs &in) { - const char *current = path.c_str(); - const char *end = current + path.length(); +void Path::makePath(const std::string& path, const InArgs& in) { + const char* current = path.c_str(); + const char* end = current + path.length(); InArgs::const_iterator itInArg = in.begin(); while (current != end) { if (*current == '[') { @@ -1451,7 +1451,7 @@ void Path::makePath(const std::string &path, const InArgs &in) { } else if (*current == '.') { ++current; } else { - const char *beginName = current; + const char* beginName = current; while (current != end && !strchr("[.", *current)) ++current; args_.push_back(std::string(beginName, current)); @@ -1459,9 +1459,9 @@ void Path::makePath(const std::string &path, const InArgs &in) { } } -void Path::addPathInArg(const std::string & /*path*/, - const InArgs &in, - InArgs::const_iterator &itInArg, +void Path::addPathInArg(const std::string& /*path*/, + const InArgs& in, + InArgs::const_iterator& itInArg, PathArgument::Kind kind) { if (itInArg == in.end()) { // Error: missing argument %d @@ -1472,14 +1472,14 @@ void Path::addPathInArg(const std::string & /*path*/, } } -void Path::invalidPath(const std::string & /*path*/, int /*location*/) { +void Path::invalidPath(const std::string& /*path*/, int /*location*/) { // Error: invalid path. } -const Value &Path::resolve(const Value &root) const { - const Value *node = &root; +const Value& Path::resolve(const Value& root) const { + const Value* node = &root; for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) { - const PathArgument &arg = *it; + const PathArgument& arg = *it; if (arg.kind_ == PathArgument::kindIndex) { if (!node->isArray() || !node->isValidIndex(arg.index_)) { // Error: unable to resolve path (array value expected at position... @@ -1499,10 +1499,10 @@ const Value &Path::resolve(const Value &root) const { return *node; } -Value Path::resolve(const Value &root, const Value &defaultValue) const { - const Value *node = &root; +Value Path::resolve(const Value& root, const Value& defaultValue) const { + const Value* node = &root; for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) { - const PathArgument &arg = *it; + const PathArgument& arg = *it; if (arg.kind_ == PathArgument::kindIndex) { if (!node->isArray() || !node->isValidIndex(arg.index_)) return defaultValue; @@ -1518,10 +1518,10 @@ Value Path::resolve(const Value &root, const Value &defaultValue) const { return *node; } -Value &Path::make(Value &root) const { - Value *node = &root; +Value& Path::make(Value& root) const { + Value* node = &root; for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) { - const PathArgument &arg = *it; + const PathArgument& arg = *it; if (arg.kind_ == PathArgument::kindIndex) { if (!node->isArray()) { // Error: node is not an array at position ... diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp index 4eba284d8..62bdae12f 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -22,7 +22,7 @@ namespace Json { -static bool containsControlCharacter(const char *str) { +static bool containsControlCharacter(const char* str) { while (*str) { if (isControlCharacter(*(str++))) return true; @@ -32,7 +32,7 @@ static bool containsControlCharacter(const char *str) { std::string valueToString(LargestInt value) { UIntToStringBuffer buffer; - char *current = buffer + sizeof(buffer); + char* current = buffer + sizeof(buffer); bool isNegative = value < 0; if (isNegative) value = -value; @@ -45,7 +45,7 @@ std::string valueToString(LargestInt value) { std::string valueToString(LargestUInt value) { UIntToStringBuffer buffer; - char *current = buffer + sizeof(buffer); + char* current = buffer + sizeof(buffer); uintToString(value, current); assert(current >= buffer); return current; @@ -102,7 +102,7 @@ std::string valueToString(double value) { std::string valueToString(bool value) { return value ? "true" : "false"; } -std::string valueToQuotedString(const char *value) { +std::string valueToQuotedString(const char* value) { if (value == NULL) return ""; // Not sure how to handle unicode... @@ -117,7 +117,7 @@ std::string valueToQuotedString(const char *value) { std::string result; result.reserve(maxsize); // to avoid lots of mallocs result += "\""; - for (const char *c = value; *c != 0; ++c) { + for (const char* c = value; *c != 0; ++c) { switch (*c) { case '\"': result += "\\\""; @@ -181,7 +181,7 @@ void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; } void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; } -std::string FastWriter::write(const Value &root) { +std::string FastWriter::write(const Value& root) { document_ = ""; writeValue(root); if (!omitEndingLineFeed_) @@ -189,7 +189,7 @@ std::string FastWriter::write(const Value &root) { return document_; } -void FastWriter::writeValue(const Value &value) { +void FastWriter::writeValue(const Value& value) { switch (value.type()) { case nullValue: if (!dropNullPlaceholders_) @@ -225,7 +225,7 @@ void FastWriter::writeValue(const Value &value) { document_ += "{"; for (Value::Members::iterator it = members.begin(); it != members.end(); ++it) { - const std::string &name = *it; + const std::string& name = *it; if (it != members.begin()) document_ += ","; document_ += valueToQuotedString(name.c_str()); @@ -243,7 +243,7 @@ void FastWriter::writeValue(const Value &value) { StyledWriter::StyledWriter() : rightMargin_(74), indentSize_(3), addChildValues_() {} -std::string StyledWriter::write(const Value &root) { +std::string StyledWriter::write(const Value& root) { document_ = ""; addChildValues_ = false; indentString_ = ""; @@ -254,7 +254,7 @@ std::string StyledWriter::write(const Value &root) { return document_; } -void StyledWriter::writeValue(const Value &value) { +void StyledWriter::writeValue(const Value& value) { switch (value.type()) { case nullValue: pushValue("null"); @@ -286,8 +286,8 @@ void StyledWriter::writeValue(const Value &value) { indent(); Value::Members::iterator it = members.begin(); for (;;) { - const std::string &name = *it; - const Value &childValue = value[name]; + const std::string& name = *it; + const Value& childValue = value[name]; writeCommentBeforeValue(childValue); writeWithIndent(valueToQuotedString(name.c_str())); document_ += " : "; @@ -306,7 +306,7 @@ void StyledWriter::writeValue(const Value &value) { } } -void StyledWriter::writeArrayValue(const Value &value) { +void StyledWriter::writeArrayValue(const Value& value) { unsigned size = value.size(); if (size == 0) pushValue("[]"); @@ -318,7 +318,7 @@ void StyledWriter::writeArrayValue(const Value &value) { bool hasChildValue = !childValues_.empty(); unsigned index = 0; for (;;) { - const Value &childValue = value[index]; + const Value& childValue = value[index]; writeCommentBeforeValue(childValue); if (hasChildValue) writeWithIndent(childValues_[index]); @@ -349,12 +349,12 @@ void StyledWriter::writeArrayValue(const Value &value) { } } -bool StyledWriter::isMultineArray(const Value &value) { +bool StyledWriter::isMultineArray(const Value& value) { int size = value.size(); bool isMultiLine = size * 3 >= rightMargin_; childValues_.clear(); for (int index = 0; index < size && !isMultiLine; ++index) { - const Value &childValue = value[index]; + const Value& childValue = value[index]; isMultiLine = isMultiLine || ((childValue.isArray() || childValue.isObject()) && childValue.size() > 0); @@ -374,7 +374,7 @@ bool StyledWriter::isMultineArray(const Value &value) { return isMultiLine; } -void StyledWriter::pushValue(const std::string &value) { +void StyledWriter::pushValue(const std::string& value) { if (addChildValues_) childValues_.push_back(value); else @@ -392,7 +392,7 @@ void StyledWriter::writeIndent() { document_ += indentString_; } -void StyledWriter::writeWithIndent(const std::string &value) { +void StyledWriter::writeWithIndent(const std::string& value) { writeIndent(); document_ += value; } @@ -404,7 +404,7 @@ void StyledWriter::unindent() { indentString_.resize(indentString_.size() - indentSize_); } -void StyledWriter::writeCommentBeforeValue(const Value &root) { +void StyledWriter::writeCommentBeforeValue(const Value& root) { if (!root.hasComment(commentBefore)) return; @@ -423,7 +423,7 @@ void StyledWriter::writeCommentBeforeValue(const Value &root) { document_ += "\n"; } -void StyledWriter::writeCommentAfterValueOnSameLine(const Value &root) { +void StyledWriter::writeCommentAfterValueOnSameLine(const Value& root) { if (root.hasComment(commentAfterOnSameLine)) document_ += " " + normalizeEOL(root.getComment(commentAfterOnSameLine)); @@ -434,18 +434,18 @@ void StyledWriter::writeCommentAfterValueOnSameLine(const Value &root) { } } -bool StyledWriter::hasCommentForValue(const Value &value) { +bool StyledWriter::hasCommentForValue(const Value& value) { return value.hasComment(commentBefore) || value.hasComment(commentAfterOnSameLine) || value.hasComment(commentAfter); } -std::string StyledWriter::normalizeEOL(const std::string &text) { +std::string StyledWriter::normalizeEOL(const std::string& text) { std::string normalized; normalized.reserve(text.length()); - const char *begin = text.c_str(); - const char *end = begin + text.length(); - const char *current = begin; + const char* begin = text.c_str(); + const char* end = begin + text.length(); + const char* current = begin; while (current != end) { char c = *current++; if (c == '\r') // mac or dos EOL @@ -466,7 +466,7 @@ StyledStreamWriter::StyledStreamWriter(std::string indentation) : document_(NULL), rightMargin_(74), indentation_(indentation), addChildValues_() {} -void StyledStreamWriter::write(std::ostream &out, const Value &root) { +void StyledStreamWriter::write(std::ostream& out, const Value& root) { document_ = &out; addChildValues_ = false; indentString_ = ""; @@ -477,7 +477,7 @@ void StyledStreamWriter::write(std::ostream &out, const Value &root) { document_ = NULL; // Forget the stream, for safety. } -void StyledStreamWriter::writeValue(const Value &value) { +void StyledStreamWriter::writeValue(const Value& value) { switch (value.type()) { case nullValue: pushValue("null"); @@ -509,8 +509,8 @@ void StyledStreamWriter::writeValue(const Value &value) { indent(); Value::Members::iterator it = members.begin(); for (;;) { - const std::string &name = *it; - const Value &childValue = value[name]; + const std::string& name = *it; + const Value& childValue = value[name]; writeCommentBeforeValue(childValue); writeWithIndent(valueToQuotedString(name.c_str())); *document_ << " : "; @@ -529,7 +529,7 @@ void StyledStreamWriter::writeValue(const Value &value) { } } -void StyledStreamWriter::writeArrayValue(const Value &value) { +void StyledStreamWriter::writeArrayValue(const Value& value) { unsigned size = value.size(); if (size == 0) pushValue("[]"); @@ -541,7 +541,7 @@ void StyledStreamWriter::writeArrayValue(const Value &value) { bool hasChildValue = !childValues_.empty(); unsigned index = 0; for (;;) { - const Value &childValue = value[index]; + const Value& childValue = value[index]; writeCommentBeforeValue(childValue); if (hasChildValue) writeWithIndent(childValues_[index]); @@ -572,12 +572,12 @@ void StyledStreamWriter::writeArrayValue(const Value &value) { } } -bool StyledStreamWriter::isMultineArray(const Value &value) { +bool StyledStreamWriter::isMultineArray(const Value& value) { int size = value.size(); bool isMultiLine = size * 3 >= rightMargin_; childValues_.clear(); for (int index = 0; index < size && !isMultiLine; ++index) { - const Value &childValue = value[index]; + const Value& childValue = value[index]; isMultiLine = isMultiLine || ((childValue.isArray() || childValue.isObject()) && childValue.size() > 0); @@ -597,7 +597,7 @@ bool StyledStreamWriter::isMultineArray(const Value &value) { return isMultiLine; } -void StyledStreamWriter::pushValue(const std::string &value) { +void StyledStreamWriter::pushValue(const std::string& value) { if (addChildValues_) childValues_.push_back(value); else @@ -620,7 +620,7 @@ void StyledStreamWriter::writeIndent() { *document_ << '\n' << indentString_; } -void StyledStreamWriter::writeWithIndent(const std::string &value) { +void StyledStreamWriter::writeWithIndent(const std::string& value) { writeIndent(); *document_ << value; } @@ -632,14 +632,14 @@ void StyledStreamWriter::unindent() { indentString_.resize(indentString_.size() - indentation_.size()); } -void StyledStreamWriter::writeCommentBeforeValue(const Value &root) { +void StyledStreamWriter::writeCommentBeforeValue(const Value& root) { if (!root.hasComment(commentBefore)) return; *document_ << normalizeEOL(root.getComment(commentBefore)); *document_ << "\n"; } -void StyledStreamWriter::writeCommentAfterValueOnSameLine(const Value &root) { +void StyledStreamWriter::writeCommentAfterValueOnSameLine(const Value& root) { if (root.hasComment(commentAfterOnSameLine)) *document_ << " " + normalizeEOL(root.getComment(commentAfterOnSameLine)); @@ -650,18 +650,18 @@ void StyledStreamWriter::writeCommentAfterValueOnSameLine(const Value &root) { } } -bool StyledStreamWriter::hasCommentForValue(const Value &value) { +bool StyledStreamWriter::hasCommentForValue(const Value& value) { return value.hasComment(commentBefore) || value.hasComment(commentAfterOnSameLine) || value.hasComment(commentAfter); } -std::string StyledStreamWriter::normalizeEOL(const std::string &text) { +std::string StyledStreamWriter::normalizeEOL(const std::string& text) { std::string normalized; normalized.reserve(text.length()); - const char *begin = text.c_str(); - const char *end = begin + text.length(); - const char *current = begin; + const char* begin = text.c_str(); + const char* end = begin + text.length(); + const char* current = begin; while (current != end) { char c = *current++; if (c == '\r') // mac or dos EOL @@ -675,7 +675,7 @@ std::string StyledStreamWriter::normalizeEOL(const std::string &text) { return normalized; } -std::ostream &operator<<(std::ostream &sout, const Value &root) { +std::ostream& operator<<(std::ostream& sout, const Value& root) { Json::StyledStreamWriter writer; writer.write(sout, root); return sout; diff --git a/src/test_lib_json/jsontest.cpp b/src/test_lib_json/jsontest.cpp index dc14ccefc..ef9c543fa 100644 --- a/src/test_lib_json/jsontest.cpp +++ b/src/test_lib_json/jsontest.cpp @@ -81,14 +81,14 @@ TestResult::TestResult() predicateStackTail_ = &rootPredicateNode_; } -void TestResult::setTestName(const std::string &name) { name_ = name; } +void TestResult::setTestName(const std::string& name) { name_ = name; } -TestResult & -TestResult::addFailure(const char *file, unsigned int line, const char *expr) { +TestResult& +TestResult::addFailure(const char* file, unsigned int line, const char* expr) { /// Walks the PredicateContext stack adding them to failures_ if not already /// added. unsigned int nestingLevel = 0; - PredicateContext *lastNode = rootPredicateNode_.next_; + PredicateContext* lastNode = rootPredicateNode_.next_; for (; lastNode != 0; lastNode = lastNode->next_) { if (lastNode->id_ > lastUsedPredicateId_) // new PredicateContext { @@ -108,9 +108,9 @@ TestResult::addFailure(const char *file, unsigned int line, const char *expr) { return *this; } -void TestResult::addFailureInfo(const char *file, +void TestResult::addFailureInfo(const char* file, unsigned int line, - const char *expr, + const char* expr, unsigned int nestingLevel) { Failure failure; failure.file_ = file; @@ -122,13 +122,13 @@ void TestResult::addFailureInfo(const char *file, failures_.push_back(failure); } -TestResult &TestResult::popPredicateContext() { - PredicateContext *lastNode = &rootPredicateNode_; +TestResult& TestResult::popPredicateContext() { + PredicateContext* lastNode = &rootPredicateNode_; while (lastNode->next_ != 0 && lastNode->next_->next_ != 0) { lastNode = lastNode->next_; } // Set message target to popped failure - PredicateContext *tail = lastNode->next_; + PredicateContext* tail = lastNode->next_; if (tail != 0 && tail->failure_ != 0) { messageTarget_ = tail->failure_; } @@ -142,7 +142,7 @@ bool TestResult::failed() const { return !failures_.empty(); } unsigned int TestResult::getAssertionNestingLevel() const { unsigned int level = 0; - const PredicateContext *lastNode = &rootPredicateNode_; + const PredicateContext* lastNode = &rootPredicateNode_; while (lastNode->next_ != 0) { lastNode = lastNode->next_; ++level; @@ -162,7 +162,7 @@ void TestResult::printFailure(bool printTestName) const { // Print in reverse to display the callstack in the right order Failures::const_iterator itEnd = failures_.end(); for (Failures::const_iterator it = failures_.begin(); it != itEnd; ++it) { - const Failure &failure = *it; + const Failure& failure = *it; std::string indent(failure.nestingLevel_ * 2, ' '); if (failure.file_) { printf("%s%s(%d): ", indent.c_str(), failure.file_, failure.line_); @@ -179,8 +179,8 @@ void TestResult::printFailure(bool printTestName) const { } } -std::string TestResult::indentText(const std::string &text, - const std::string &indent) { +std::string TestResult::indentText(const std::string& text, + const std::string& indent) { std::string reindented; std::string::size_type lastIndex = 0; while (lastIndex < text.size()) { @@ -195,22 +195,22 @@ std::string TestResult::indentText(const std::string &text, return reindented; } -TestResult &TestResult::addToLastFailure(const std::string &message) { +TestResult& TestResult::addToLastFailure(const std::string& message) { if (messageTarget_ != 0) { messageTarget_->message_ += message; } return *this; } -TestResult &TestResult::operator<<(Json::Int64 value) { +TestResult& TestResult::operator<<(Json::Int64 value) { return addToLastFailure(Json::valueToString(value)); } -TestResult &TestResult::operator<<(Json::UInt64 value) { +TestResult& TestResult::operator<<(Json::UInt64 value) { return addToLastFailure(Json::valueToString(value)); } -TestResult &TestResult::operator<<(bool value) { +TestResult& TestResult::operator<<(bool value) { return addToLastFailure(value ? "true" : "false"); } @@ -221,7 +221,7 @@ TestCase::TestCase() : result_(0) {} TestCase::~TestCase() {} -void TestCase::run(TestResult &result) { +void TestCase::run(TestResult& result) { result_ = &result; runTestCase(); } @@ -231,7 +231,7 @@ void TestCase::run(TestResult &result) { Runner::Runner() {} -Runner &Runner::add(TestCaseFactory factory) { +Runner& Runner::add(TestCaseFactory factory) { tests_.push_back(factory); return *this; } @@ -241,14 +241,14 @@ unsigned int Runner::testCount() const { } std::string Runner::testNameAt(unsigned int index) const { - TestCase *test = tests_[index](); + TestCase* test = tests_[index](); std::string name = test->testName(); delete test; return name; } -void Runner::runTestAt(unsigned int index, TestResult &result) const { - TestCase *test = tests_[index](); +void Runner::runTestAt(unsigned int index, TestResult& result) const { + TestCase* test = tests_[index](); result.setTestName(test->testName()); printf("Testing %s: ", test->testName()); fflush(stdout); @@ -258,13 +258,13 @@ void Runner::runTestAt(unsigned int index, TestResult &result) const { test->run(result); #if JSON_USE_EXCEPTION } - catch (const std::exception &e) { + catch (const std::exception& e) { result.addFailure(__FILE__, __LINE__, "Unexpected exception caught:") << e.what(); } #endif // if JSON_USE_EXCEPTION delete test; - const char *status = result.failed() ? "FAILED" : "OK"; + const char* status = result.failed() ? "FAILED" : "OK"; printf("%s\n", status); fflush(stdout); } @@ -287,7 +287,7 @@ bool Runner::runAllTest(bool printSummary) const { return true; } else { for (unsigned int index = 0; index < failures.size(); ++index) { - TestResult &result = failures[index]; + TestResult& result = failures[index]; result.printFailure(count > 1); } @@ -303,8 +303,8 @@ bool Runner::runAllTest(bool printSummary) const { } } -bool Runner::testIndex(const std::string &testName, - unsigned int &indexOut) const { +bool Runner::testIndex(const std::string& testName, + unsigned int& indexOut) const { unsigned int count = testCount(); for (unsigned int index = 0; index < count; ++index) { if (testNameAt(index) == testName) { @@ -322,7 +322,7 @@ void Runner::listTests() const { } } -int Runner::runCommandLine(int argc, const char *argv[]) const { +int Runner::runCommandLine(int argc, const char* argv[]) const { typedef std::deque TestNames; Runner subrunner; for (int index = 1; index < argc; ++index) { @@ -363,7 +363,7 @@ int Runner::runCommandLine(int argc, const char *argv[]) const { #if defined(_MSC_VER) && defined(_DEBUG) // Hook MSVCRT assertions to prevent dialog from appearing static int -msvcrtSilentReportHook(int reportType, char *message, int * /*returnValue*/) { +msvcrtSilentReportHook(int reportType, char* message, int* /*returnValue*/) { // The default CRT handling of error and assertion is to display // an error dialog to the user. // Instead, when an error or an assertion occurs, we force the @@ -409,7 +409,7 @@ void Runner::preventDialogOnCrash() { #endif // if defined(_WIN32) } -void Runner::printUsage(const char *appName) { +void Runner::printUsage(const char* appName) { printf("Usage: %s [options]\n" "\n" "If --test is not specified, then all the test cases be run.\n" @@ -426,12 +426,12 @@ void Runner::printUsage(const char *appName) { // Assertion functions // ////////////////////////////////////////////////////////////////// -TestResult &checkStringEqual(TestResult &result, - const std::string &expected, - const std::string &actual, - const char *file, +TestResult& checkStringEqual(TestResult& result, + const std::string& expected, + const std::string& actual, + const char* file, unsigned int line, - const char *expr) { + const char* expr) { if (expected != actual) { result.addFailure(file, line, expr); result << "Expected: '" << expected << "'\n"; diff --git a/src/test_lib_json/jsontest.h b/src/test_lib_json/jsontest.h index 38372e92c..5c56a40b0 100644 --- a/src/test_lib_json/jsontest.h +++ b/src/test_lib_json/jsontest.h @@ -30,7 +30,7 @@ namespace JsonTest { class Failure { public: - const char *file_; + const char* file_; unsigned int line_; std::string expr_; std::string message_; @@ -43,13 +43,13 @@ class Failure { struct PredicateContext { typedef unsigned int Id; Id id_; - const char *file_; + const char* file_; unsigned int line_; - const char *expr_; - PredicateContext *next_; + const char* expr_; + PredicateContext* next_; /// Related Failure, set when the PredicateContext is converted /// into a Failure. - Failure *failure_; + Failure* failure_; }; class TestResult { @@ -63,25 +63,25 @@ class TestResult { PredicateContext::Id predicateId_; /// \internal Implementation detail for predicate macros - PredicateContext *predicateStackTail_; + PredicateContext* predicateStackTail_; - void setTestName(const std::string &name); + void setTestName(const std::string& name); /// Adds an assertion failure. - TestResult & - addFailure(const char *file, unsigned int line, const char *expr = 0); + TestResult& + addFailure(const char* file, unsigned int line, const char* expr = 0); /// Removes the last PredicateContext added to the predicate stack /// chained list. /// Next messages will be targed at the PredicateContext that was removed. - TestResult &popPredicateContext(); + TestResult& popPredicateContext(); bool failed() const; void printFailure(bool printTestName) const; // Generic operator that will work with anything ostream can deal with. - template TestResult &operator<<(const T &value) { + template TestResult& operator<<(const T& value) { std::ostringstream oss; oss.precision(16); oss.setf(std::ios_base::floatfield); @@ -90,21 +90,21 @@ class TestResult { } // Specialized versions. - TestResult &operator<<(bool value); + TestResult& operator<<(bool value); // std:ostream does not support 64bits integers on all STL implementation - TestResult &operator<<(Json::Int64 value); - TestResult &operator<<(Json::UInt64 value); + TestResult& operator<<(Json::Int64 value); + TestResult& operator<<(Json::UInt64 value); private: - TestResult &addToLastFailure(const std::string &message); + TestResult& addToLastFailure(const std::string& message); unsigned int getAssertionNestingLevel() const; /// Adds a failure or a predicate context - void addFailureInfo(const char *file, + void addFailureInfo(const char* file, unsigned int line, - const char *expr, + const char* expr, unsigned int nestingLevel); - static std::string indentText(const std::string &text, - const std::string &indent); + static std::string indentText(const std::string& text, + const std::string& indent); typedef std::deque Failures; Failures failures_; @@ -112,7 +112,7 @@ class TestResult { PredicateContext rootPredicateNode_; PredicateContext::Id lastUsedPredicateId_; /// Failure which is the target of the messages added using operator << - Failure *messageTarget_; + Failure* messageTarget_; }; class TestCase { @@ -121,32 +121,32 @@ class TestCase { virtual ~TestCase(); - void run(TestResult &result); + void run(TestResult& result); - virtual const char *testName() const = 0; + virtual const char* testName() const = 0; protected: - TestResult *result_; + TestResult* result_; private: virtual void runTestCase() = 0; }; /// Function pointer type for TestCase factory -typedef TestCase *(*TestCaseFactory)(); +typedef TestCase* (*TestCaseFactory)(); class Runner { public: Runner(); /// Adds a test to the suite - Runner &add(TestCaseFactory factory); + Runner& add(TestCaseFactory factory); /// Runs test as specified on the command-line /// If no command-line arguments are provided, run all tests. /// If --list-tests is provided, then print the list of all test cases /// If --test is provided, then run test testname. - int runCommandLine(int argc, const char *argv[]) const; + int runCommandLine(int argc, const char* argv[]) const; /// Runs all the test cases bool runAllTest(bool printSummary) const; @@ -158,17 +158,17 @@ class Runner { std::string testNameAt(unsigned int index) const; /// Runs the test case at the specified index using the specified TestResult - void runTestAt(unsigned int index, TestResult &result) const; + void runTestAt(unsigned int index, TestResult& result) const; - static void printUsage(const char *appName); + static void printUsage(const char* appName); private: // prevents copy construction and assignment - Runner(const Runner &other); - Runner &operator=(const Runner &other); + Runner(const Runner& other); + Runner& operator=(const Runner& other); private: void listTests() const; - bool testIndex(const std::string &testName, unsigned int &index) const; + bool testIndex(const std::string& testName, unsigned int& index) const; static void preventDialogOnCrash(); private: @@ -177,12 +177,12 @@ class Runner { }; template -TestResult &checkEqual(TestResult &result, - const T &expected, - const U &actual, - const char *file, +TestResult& checkEqual(TestResult& result, + const T& expected, + const U& actual, + const char* file, unsigned int line, - const char *expr) { + const char* expr) { if (static_cast(expected) != actual) { result.addFailure(file, line, expr); result << "Expected: " << static_cast(expected) << "\n"; @@ -191,12 +191,12 @@ TestResult &checkEqual(TestResult &result, return result; } -TestResult &checkStringEqual(TestResult &result, - const std::string &expected, - const std::string &actual, - const char *file, +TestResult& checkStringEqual(TestResult& result, + const std::string& expected, + const std::string& actual, + const char* file, unsigned int line, - const char *expr); + const char* expr); } // namespace JsonTest @@ -260,12 +260,12 @@ TestResult &checkStringEqual(TestResult &result, #define JSONTEST_FIXTURE(FixtureType, name) \ class Test##FixtureType##name : public FixtureType { \ public: \ - static JsonTest::TestCase *factory() { \ + static JsonTest::TestCase* factory() { \ return new Test##FixtureType##name(); \ } \ \ public: /* overidden from TestCase */ \ - virtual const char *testName() const { return #FixtureType "/" #name; } \ + virtual const char* testName() const { return #FixtureType "/" #name; } \ virtual void runTestCase(); \ }; \ \ diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index d6f358275..13fc21df5 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -85,23 +85,23 @@ struct ValueTest : JsonTest::TestCase { bool isNumeric_; }; - void checkConstMemberCount(const Json::Value &value, + void checkConstMemberCount(const Json::Value& value, unsigned int expectedCount); - void checkMemberCount(Json::Value &value, unsigned int expectedCount); + void checkMemberCount(Json::Value& value, unsigned int expectedCount); - void checkIs(const Json::Value &value, const IsCheck &check); + void checkIs(const Json::Value& value, const IsCheck& check); - void checkIsLess(const Json::Value &x, const Json::Value &y); + void checkIsLess(const Json::Value& x, const Json::Value& y); - void checkIsEqual(const Json::Value &x, const Json::Value &y); + void checkIsEqual(const Json::Value& x, const Json::Value& y); /// Normalize the representation of floating-point number by stripped leading /// 0 in exponent. - static std::string normalizeFloatingPointStr(const std::string &s); + static std::string normalizeFloatingPointStr(const std::string& s); }; -std::string ValueTest::normalizeFloatingPointStr(const std::string &s) { +std::string ValueTest::normalizeFloatingPointStr(const std::string& s) { std::string::size_type index = s.find_last_of("eE"); if (index != std::string::npos) { std::string::size_type hasSign = @@ -187,7 +187,7 @@ JSONTEST_FIXTURE(ValueTest, objects) { JSONTEST_ASSERT(!emptyObject_.isConvertibleTo(Json::stringValue)); // Access through const reference - const Json::Value &constObject = object1_; + const Json::Value& constObject = object1_; JSONTEST_ASSERT_EQUAL(Json::Value(1234), constObject["id"]); JSONTEST_ASSERT_EQUAL(Json::Value(), constObject["unknown id"]); @@ -229,7 +229,7 @@ JSONTEST_FIXTURE(ValueTest, arrays) { JSONTEST_ASSERT(!emptyArray_.isConvertibleTo(Json::stringValue)); // Access through const reference - const Json::Value &constArray = array1_; + const Json::Value& constArray = array1_; JSONTEST_ASSERT_EQUAL(Json::Value(1234), constArray[index0]); JSONTEST_ASSERT_EQUAL(Json::Value(1234), constArray[0]); @@ -1239,7 +1239,7 @@ JSONTEST_FIXTURE(ValueTest, nonIntegers) { normalizeFloatingPointStr(val.asString())); } -void ValueTest::checkConstMemberCount(const Json::Value &value, +void ValueTest::checkConstMemberCount(const Json::Value& value, unsigned int expectedCount) { unsigned int count = 0; Json::Value::const_iterator itEnd = value.end(); @@ -1249,7 +1249,7 @@ void ValueTest::checkConstMemberCount(const Json::Value &value, JSONTEST_ASSERT_EQUAL(expectedCount, count) << "Json::Value::const_iterator"; } -void ValueTest::checkMemberCount(Json::Value &value, +void ValueTest::checkMemberCount(Json::Value& value, unsigned int expectedCount) { JSONTEST_ASSERT_EQUAL(expectedCount, value.size()); @@ -1269,7 +1269,7 @@ ValueTest::IsCheck::IsCheck() isUInt64_(false), isIntegral_(false), isDouble_(false), isNumeric_(false) {} -void ValueTest::checkIs(const Json::Value &value, const IsCheck &check) { +void ValueTest::checkIs(const Json::Value& value, const IsCheck& check) { JSONTEST_ASSERT_EQUAL(check.isObject_, value.isObject()); JSONTEST_ASSERT_EQUAL(check.isArray_, value.isArray()); JSONTEST_ASSERT_EQUAL(check.isBool_, value.isBool()); @@ -1384,7 +1384,7 @@ JSONTEST_FIXTURE(ValueTest, compareType) { Json::Value(Json::objectValue))); } -void ValueTest::checkIsLess(const Json::Value &x, const Json::Value &y) { +void ValueTest::checkIsLess(const Json::Value& x, const Json::Value& y) { JSONTEST_ASSERT(x < y); JSONTEST_ASSERT(y > x); JSONTEST_ASSERT(x <= y); @@ -1399,7 +1399,7 @@ void ValueTest::checkIsLess(const Json::Value &x, const Json::Value &y) { JSONTEST_ASSERT(y.compare(x) >= 0); } -void ValueTest::checkIsEqual(const Json::Value &x, const Json::Value &y) { +void ValueTest::checkIsEqual(const Json::Value& x, const Json::Value& y) { JSONTEST_ASSERT(x == y); JSONTEST_ASSERT(y == x); JSONTEST_ASSERT(x <= y); @@ -1601,7 +1601,7 @@ JSONTEST_FIXTURE(ReaderTest, parseWithDetailError) { JSONTEST_ASSERT(errors.at(0).message == "Bad escape sequence in string"); } -int main(int argc, const char *argv[]) { +int main(int argc, const char* argv[]) { JsonTest::Runner runner; JSONTEST_REGISTER_FIXTURE(runner, ValueTest, checkNormalizeFloatingPointStr); JSONTEST_REGISTER_FIXTURE(runner, ValueTest, memberCount);