220 Commits

Author SHA1 Message Date
thebusytypist
46e89dad0d Add unittests for kParserErrorTermination; Fix bugs in last merge. 2014-07-15 00:51:34 +08:00
thebusytypist
d4da07c5fb Merge upstream/master. 2014-07-14 23:49:57 +08:00
miloyip
d5218804bf More endian detection
Since __BYTE_ORDER__ only avaliable since GCC 4.6.0, add more detection.
2014-07-14 14:16:34 +08:00
miloyip
065e3b1628 Do not assume little endian when detection fail, add more detections 2014-07-14 13:54:15 +08:00
Milo Yip
a37a1881a5 Fixes missing supportUnicode in AutoUTF 2014-07-14 00:03:40 +08:00
Milo Yip
b5436f7104 Add ASCII encoding which can fulfill #69 2014-07-13 23:51:56 +08:00
Milo Yip
27101d9cd1 Add API doc for Writer::Reset() and Writer::IsComplete() 2014-07-13 13:27:15 +08:00
Milo Yip
5babae98e5 Add Writer::IsComplete() 2014-07-13 13:21:25 +08:00
Milo Yip
b234007713 Fixes #66 by adding Writer::Reset() and multiple root check
Note it redefines RAPIDJSON_ASSERT() to throw exception in unittest and
check for assertion with gtest.
2014-07-13 13:16:03 +08:00
Milo Yip
9e3ed44e85 Suppress VS2013 warnings due to #64 2014-07-13 01:10:25 +08:00
Philipp A. Hartmann
ff5713faf0 error/en.h: fix typo, add termination string 2014-07-12 18:45:49 +02:00
Philipp A. Hartmann
c69610239a error.h: add kParseErrorTermination (from #61) 2014-07-12 18:44:31 +02:00
Philipp A. Hartmann
152db11ad6 Merge branch 'upstream/master' into feature/exception-support
Conflicts:
	include/rapidjson/reader.h
2014-07-12 18:42:06 +02:00
Milo Yip
b55fcbd36a Merge pull request #61 from miloyip/issue59terminate
Fixes #59 by adding bool return value for each event handler function
2014-07-12 23:42:50 +08:00
thebusytypist
3038a7855e Revise unittests: reset the handler before the transition which we are going to test. 2014-07-11 16:03:38 +08:00
Philipp A. Hartmann
418a5829b3 update documentation of ParseResult and related functions 2014-07-11 09:39:20 +02:00
Philipp A. Hartmann
2fcb999749 add ParseResult 2014-07-11 09:39:20 +02:00
Philipp A. Hartmann
4475521177 GenericDocument: simplify error handling in ParseStream
* unconditionally store error state of reader after parsing
 * clear stack after parsing by using a ClearStackOnExit scope guard
2014-07-11 09:39:20 +02:00
Philipp A. Hartmann
3c1d4bc21d reader.h: prepare "early return path" for exception support
In case of a user-defined RAPIDJSON_PARSE_ERROR_NORETURN that throws
an exception instead of using the Rapidjson ParseError API, the early
return paths performing the stack unwinding manually can be omitted as
well.

This patch provides a customizable RAPIDJSON_PARSE_ERROR_EARLY_RETURN
macro to remove these (then unneeded) control paths from the parsing
implementation (with and without a return value).

Secondly, clearing the parse stack is moved to a small helper struct
that calls stack_.Clear() from its destructor.  This avoids the need
for the 'goto' in the ParseStream function and ensures proper cleanup
even if e.g. a user-defined Allocator throws an exception.
2014-07-11 09:39:20 +02:00
Philipp A. Hartmann
b37bd85318 move ParseErrorCode to error/error.h
In order to enable the customization of the error macros
 - RAPIDJSON_PARSE_ERROR_NORETURN
 - RAPIDJSON_PARSE_ERROR_EARLY_RETURN
the user may need to have access to the ParseErrorCode enum
already.  This requires a separate header location than the
GenericReader.
2014-07-11 09:39:20 +02:00
Philipp A. Hartmann
41d211cd51 GenericValue::operator= : fixup assignment operator
While MSVC doesn't like the explicit `.template operator=<...>` syntax
(see 4f40ed6), Clang 3.5 complains about the absence of it:

In file included from ../../test/perftest/rapidjsontest.cpp:6:
../../include/rapidjson/document.h:504:18: error: use 'template' keyword to treat 'operator =' as a dependent template name
                return (*this).operator=<StringRefType>(str);
                               ^
                               template

Delegate both operator=(StringRefType) and operator=(T) to operator(GenericValue&).
2014-07-11 08:27:28 +02:00
thebusytypist
36434b66c8 Merge remote-tracking branch 'upstream/master' into TransitionTable 2014-07-11 12:52:07 +08:00
Philipp A. Hartmann
ca36a2e66e writer.h: use warning macros for MSVC 2014-07-10 19:49:52 +02:00
Philipp A. Hartmann
7a2e6e79c6 StrLen: align implementations
There are two copies of `StrLen` in the RapidJSON code base
 * strfunc.h: rapidjson::internal::StrLen<Ch>
 * unittest.h: Strlen<Ch>

To hide a warning on MSVC, align both implementations to use
'unsigned/SizeType' as return type and add an explicit cast.
2014-07-10 19:41:17 +02:00
Philipp A. Hartmann
4f40ed64b6 MSVC: fix compiler error in GenericDocument
The `StringRefType` assignment operator overload
leads to a compiler error on MSVC 2005 and later:

..\..\include\rapidjson/document.h(504) : error C2951: template declarations are only permitted at global, namespace, or class scope

Drop the unneeded 'template' keyword here.
2014-07-10 19:41:08 +02:00
Philipp A. Hartmann
bde95eca04 Writer::WriteUint: add cast to hide warning C4244 on MSVC 2014-07-10 19:38:23 +02:00
Philipp A. Hartmann
04f9c5020f encodings.h: hide narrowing conversion warnings on MSVC 2014-07-10 19:38:23 +02:00
Philipp A. Hartmann
e63125f1a1 MSVC: fix SSE/intrinsic support
MSVC with enabled RAPIDJSON_SSE2/RAPIDJSON_SSE42 requires the explicit
definition of the `_BitScanForward` intrinsic.  This can be reliably
ensured by including "intrin.h" and properly marking '_BitScanForward'
as intrinsic.

Confirmed on MSVC 2005, 2008.
Should fix https://code.google.com/p/rapidjson/issues/detail?id=96
2014-07-10 19:35:47 +02:00
thebusytypist
e3c4b33915 Add unittests for state transition. 2014-07-10 22:27:25 +08:00
thebusytypist
692904b77b Handle all unspecific parsing errors. 2014-07-10 19:49:43 +08:00
Milo Yip
cc04219e36 Fixes #59 by adding bool return value for each event handler function 2014-07-10 19:33:01 +08:00
thebusytypist
f6235b2160 Add basic error handling. 2014-07-10 00:00:56 +08:00
Philipp A. Hartmann
edf8a0aa1d GenericValue: add Move() 2014-07-09 11:25:38 +02:00
Philipp A. Hartmann
9b3969d0e1 GenericValue: fixup bool constructor
With the new string handling API, the constructor taking a `bool`
parameter matches in some unwanted cases, as pointers can be casted
to `bool` implicitly.

Add a SFINAE helper to this constructor to avoid matching arbitrary
pointers.  To avoid confusion for the user, this mechanism is hidden
from the Doxygen documentation.
2014-07-08 20:41:59 +02:00
Philipp A. Hartmann
ed9cdbc2f7 GenericStringRef: disallow assignment, const string pointer 2014-07-08 20:23:47 +02:00
Philipp A. Hartmann
524362242b Add documentation to new string API 2014-07-08 20:23:27 +02:00
thebusytypist
91aaa346e4 Finish the new implementation of state machine. But not been unittested. 2014-07-08 22:54:22 +08:00
Philipp A. Hartmann
4007301e1f Add a wrapper for constant string references 2014-07-08 16:38:28 +02:00
Philipp A. Hartmann
3bfffa3cf9 meta.h: inherit from TrueType/FalseType where applicable
To reduce repetition and to provide a proper type hierarchy,
let type traits inherit from TrueType and FalseType.
2014-07-08 16:38:28 +02:00
Philipp A. Hartmann
813da24d72 Add RAPIDJSON_DIAG_* macros to handle compiler warnings
Warning push/pop support has been added to GCC in version 4.6.0,
and pragmas to ignore certain warnings are present since 4.2.0.
This patch hides the compiler-specific warning push/pop/disable
pragmas behind a macro-based implementation (currently for MSVC and
clang /GCC.

This avoids warnings, as seen e.g. on GCC 4.4:
  ../../include/rapidjson/document.h:14: error: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
and earlier versions complaining about unknown pragmas being ignored.

Note: unittest.h and perftest.h need to check for compilers
explicitly, as rapidjson.h is not included there.
2014-07-08 14:45:19 +02:00
thebusytypist
6b0df217a8 WIP: refactor iterative parsing. 2014-07-08 02:19:35 +08:00
thebusytypist
ebb9a250d8 It is sufficient to check finish state in iterative parsing. 2014-07-07 22:06:14 +08:00
thebusytypist
7d33b01515 Bugfix: add missing transition from finish state. 2014-07-07 21:57:23 +08:00
thebusytypist
7acb0c181e Rename flags/state names/functions/test cases from 'NonRecursive' to 'Iterative'. 2014-07-07 21:46:57 +08:00
Milo Yip
6e4d8db51d Fix readme issue in doxygen, customize css
Imitate GitHub markdown rendering
2014-07-07 01:01:49 +08:00
Philipp A. Hartmann
a213d2d881 Doxygen: fixup main page
To avoid the {#mainpage} tag to be rendered on GitHub, explicitly add a
`\mainpage` section to `rapidjson.h`, referring to `readme.md`.
2014-07-06 16:39:23 +02:00
Philipp A. Hartmann
53b27ac8ba GenericReader: improve doxygen documentation 2014-07-06 15:35:43 +02:00
Philipp A. Hartmann
ec8f26e6e5 (Pretty)Writer: improve doxygen documentation 2014-07-06 15:35:43 +02:00
Philipp A. Hartmann
7972f22fcb Doxygen: document some UTF-8 typedefs 2014-07-06 15:35:43 +02:00
Philipp A. Hartmann
6ed0ac174f GenericDocument: improve Doxygen documentation 2014-07-06 15:35:43 +02:00