diff --git a/.gitignore b/.gitignore index a299ff5..2dbbadb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ /bin/* +!/bin/data +!/bin/encodings +!/bin/jsonchecker /build/*.exe /build/gmake /build/vs*/ diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index b9f9a27..6837556 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -285,12 +285,7 @@ public: explicit GenericValue(double d) : data_(), flags_(kNumberDoubleFlag) { data_.n.d = d; } //! Constructor for constant string (i.e. do not make a copy of string) - GenericValue(const Ch* s, SizeType length) : data_(), flags_() { - RAPIDJSON_ASSERT(s != NULL); - flags_ = kConstStringFlag; - data_.s.str = s; - data_.s.length = length; - } + GenericValue(const Ch* s, SizeType length) : data_(), flags_() { SetStringRaw(s, length); } //! Constructor for constant string (i.e. do not make a copy of string) explicit GenericValue(const Ch* s) : data_(), flags_() { SetStringRaw(s, internal::StrLen(s)); } @@ -427,14 +422,8 @@ public: A better approach is to use the now public FindMember(). */ GenericValue& operator[](const Ch* name) { - MemberIterator member = FindMember(name); - if (member != MemberEnd()) - return member->value; - else { - RAPIDJSON_ASSERT(false); // see above note - static GenericValue NullValue; - return NullValue; - } + GenericValue n(name, internal::StrLen(name)); + return (*this)[n]; } const GenericValue& operator[](const Ch* name) const { return const_cast(*this)[name]; } @@ -486,15 +475,8 @@ public: \c std::map, this has been changed to MemberEnd() now. */ MemberIterator FindMember(const Ch* name) { - RAPIDJSON_ASSERT(name); - RAPIDJSON_ASSERT(IsObject()); - - SizeType len = internal::StrLen(name); - MemberIterator member = MemberBegin(); - for (; member != MemberEnd(); ++member) - if (member->name.data_.s.length == len && memcmp(member->name.data_.s.str, name, len * sizeof(Ch)) == 0) - break; - return member; + GenericValue n(name, internal::StrLen(name)); + return FindMember(n); } ConstMemberIterator FindMember(const Ch* name) const { return const_cast(*this).FindMember(name); } @@ -565,13 +547,8 @@ public: \note Removing member is implemented by moving the last member. So the ordering of members is changed. */ bool RemoveMember(const Ch* name) { - MemberIterator m = FindMember(name); - if (m != MemberEnd()) { - RemoveMember(m); - return true; - } - else - return false; + GenericValue n(name, internal::StrLen(name)); + return RemoveMember(n); } bool RemoveMember(const GenericValue& name) { @@ -891,7 +868,7 @@ private: }; // 12 bytes in 32-bit mode, 16 bytes in 64-bit mode struct Array { - GenericValue* elements; + GenericValue* elements; SizeType size; SizeType capacity; }; // 12 bytes in 32-bit mode, 16 bytes in 64-bit mode @@ -1004,7 +981,7 @@ public: template GenericDocument& ParseStream(InputStream& is) { - return ParseStream<0, Encoding, InputStream>(is); + return ParseStream(is); } //! Parse JSON text from a mutable string. @@ -1024,7 +1001,7 @@ public: } GenericDocument& ParseInsitu(Ch* str) { - return ParseInsitu<0, Encoding>(str); + return ParseInsitu(str); } //! Parse JSON text from a read-only string. @@ -1044,7 +1021,7 @@ public: } GenericDocument& Parse(const Ch* str) { - return Parse<0>(str); + return Parse(str); } //! Whether a parse error was occured in the last parsing. diff --git a/include/rapidjson/error/en.h b/include/rapidjson/error/en.h index 45017d3..81637ee 100644 --- a/include/rapidjson/error/en.h +++ b/include/rapidjson/error/en.h @@ -34,7 +34,7 @@ inline const RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErro case kParseErrorStringMissQuotationMark: return RAPIDJSON_ERROR_STRING("Missing a closing quotation mark in string."); case kParseErrorStringInvalidEncoding: return RAPIDJSON_ERROR_STRING("Invalid encoidng in string."); - case kParesErrorNumberTooBig: return RAPIDJSON_ERROR_STRING("Number too big to be stored in double."); + case kParseErrorNumberTooBig: return RAPIDJSON_ERROR_STRING("Number too big to be stored in double."); case kParseErrorNumberMissFraction: return RAPIDJSON_ERROR_STRING("Miss fraction part in number."); case kParseErrorNumberMissExponent: return RAPIDJSON_ERROR_STRING("Miss exponent in number."); diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index 76fed8d..9010aec 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -71,7 +71,7 @@ enum ParseErrorCode { kParseErrorStringMissQuotationMark, //!< Missing a closing quotation mark in string. kParseErrorStringInvalidEncoding, //!< Invalid encoidng in string. - kParesErrorNumberTooBig, //!< Number too big to be stored in double. + kParseErrorNumberTooBig, //!< Number too big to be stored in double. kParseErrorNumberMissFraction, //!< Miss fraction part in number. kParseErrorNumberMissExponent //!< Miss exponent in number. }; @@ -224,7 +224,7 @@ inline const char *SkipWhitespace_SIMD(const char* p) { x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w1)); x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w2)); x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w3)); - unsigned short r = ~_mm_movemask_epi8(x); + unsigned short r = (unsigned short)~_mm_movemask_epi8(x); if (r == 0) // all 16 characters are whitespace p += 16; else { // some of characters may be non-whitespace @@ -323,7 +323,7 @@ public: template bool Parse(InputStream& is, Handler& handler) { - return Parse<0>(is, handler); + return Parse(is, handler); } bool HasParseError() const { return parseErrorCode_ != kParseErrorNone; } @@ -610,7 +610,7 @@ private: } } else - RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, is.Tell()); + RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, s.Tell()); // Parse 64bit int uint64_t i64 = 0; @@ -643,7 +643,7 @@ private: d = (double)i64; while (s.Peek() >= '0' && s.Peek() <= '9') { if (d >= 1E307) - RAPIDJSON_PARSE_ERROR(kParesErrorNumberTooBig, is.Tell()); + RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, s.Tell()); d = d * 10 + (s.Take() - '0'); } } @@ -662,7 +662,7 @@ private: --expFrac; } else - RAPIDJSON_PARSE_ERROR(kParseErrorNumberMissFraction, is.Tell()); + RAPIDJSON_PARSE_ERROR(kParseErrorNumberMissFraction, s.Tell()); while (s.Peek() >= '0' && s.Peek() <= '9') { if (expFrac > -16) { @@ -695,11 +695,11 @@ private: while (s.Peek() >= '0' && s.Peek() <= '9') { exp = exp * 10 + (s.Take() - '0'); if (exp > 308) - RAPIDJSON_PARSE_ERROR(kParesErrorNumberTooBig, is.Tell()); + RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, s.Tell()); } } else - RAPIDJSON_PARSE_ERROR(kParseErrorNumberMissExponent, is.Tell()); + RAPIDJSON_PARSE_ERROR(kParseErrorNumberMissExponent, s.Tell()); if (expMinus) exp = -exp; diff --git a/test/perftest/rapidjsontest.cpp b/test/perftest/rapidjsontest.cpp index df8a0f8..ea9d144 100644 --- a/test/perftest/rapidjsontest.cpp +++ b/test/perftest/rapidjsontest.cpp @@ -85,7 +85,7 @@ TEST_F(RapidJson, SIMD_SUFFIX(ReaderParse_DummyHandler_ValidateEncoding)) { } } -TEST_F(RapidJson, SIMD_SUFFIX(DoucmentParseInsitu_MemoryPoolAllocator)) { +TEST_F(RapidJson, SIMD_SUFFIX(DocumentParseInsitu_MemoryPoolAllocator)) { //const size_t userBufferSize = 128 * 1024; //char* userBuffer = (char*)malloc(userBufferSize); @@ -108,7 +108,7 @@ TEST_F(RapidJson, SIMD_SUFFIX(DoucmentParseInsitu_MemoryPoolAllocator)) { //free(userBuffer); } -TEST_F(RapidJson, SIMD_SUFFIX(DoucmentParse_MemoryPoolAllocator)) { +TEST_F(RapidJson, SIMD_SUFFIX(DocumentParse_MemoryPoolAllocator)) { //const size_t userBufferSize = 128 * 1024; //char* userBuffer = (char*)malloc(userBufferSize); @@ -130,7 +130,7 @@ TEST_F(RapidJson, SIMD_SUFFIX(DoucmentParse_MemoryPoolAllocator)) { //free(userBuffer); } -TEST_F(RapidJson, SIMD_SUFFIX(DoucmentParse_CrtAllocator)) { +TEST_F(RapidJson, SIMD_SUFFIX(DocumentParse_CrtAllocator)) { for (size_t i = 0; i < kTrialCount; i++) { memcpy(temp_, json_, length_ + 1); GenericDocument, CrtAllocator> doc; diff --git a/test/unittest/readertest.cpp b/test/unittest/readertest.cpp index 4b5162b..264f7ba 100644 --- a/test/unittest/readertest.cpp +++ b/test/unittest/readertest.cpp @@ -171,9 +171,9 @@ TEST(Reader, ParseNumber_Error) { for (int i = 1; i < 310; i++) n1e309[i] = '0'; n1e309[310] = '\0'; - TEST_NUMBER_ERROR(kParesErrorNumberTooBig, n1e309); + TEST_NUMBER_ERROR(kParseErrorNumberTooBig, n1e309); } - TEST_NUMBER_ERROR(kParesErrorNumberTooBig, "1e309"); + TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e309"); // Miss fraction part in number. TEST_NUMBER_ERROR(kParseErrorNumberMissFraction, "1."); diff --git a/test/unittest/valuetest.cpp b/test/unittest/valuetest.cpp index 67a11ef..93d4eb0 100644 --- a/test/unittest/valuetest.cpp +++ b/test/unittest/valuetest.cpp @@ -27,7 +27,7 @@ TEST(Value, assignment_operator) { template void TestCopyFrom() { - Value::AllocatorType a; + typename Value::AllocatorType a; Value v1(1234); Value v2(v1, a); // deep copy constructor EXPECT_TRUE(v1.GetType() == v2.GetType());