139 Commits

Author SHA1 Message Date
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
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
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
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
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
Philipp A. Hartmann
c63c40fa85 GenericMemberIterator::Type -> GenericMemberIterator::Iterator
Rename nested typedef to avoid confusion with JSON Type enum.
2014-07-06 15:35:43 +02:00
Philipp A. Hartmann
5174fe4f65 rapidjson.h: add some file-level doxygen documentation
Although not yet complete, the rapidjson.h header contains most of
the customisation macro definitions.  These should be documented via
Doxygen as well.  This requires adding file-level documentation.

Some parts are excluded via `@cond` to avoid cluttering the documentation
with internals too much.

Secondly, a brief description is added to the 'rapidjson' namespace to
include the namespace-level elements (enums, typedefs, functions) to
the generated documentation.
2014-07-06 15:35:43 +02:00
Milo Yip
96882f4977 Prohibit copy constructor in StackStream. 2014-07-04 20:19:15 +08:00
Milo Yip
d9c02b5b79 Fixed a few cppcheck warnings.
C-style cast
Add function const to MemoryPoolAllocator::Capacity() and Size()
2014-07-04 19:53:14 +08:00
Milo Yip
e2cd486e6e Fixes -Wswitch-default warnings 2014-07-04 17:25:33 +08:00
Milo Yip
b01093b16c Fixes a compilation error in Reader when using encoded stream.
Added unit test for parsing EncodedStream to Document.
2014-07-04 14:32:44 +08:00
Milo Yip
9ed11d29a2 Safer implementation of Swap()
Also added documentation, unit tests for swapping Document/Value,
Document/Document.
2014-07-04 00:59:16 +08:00
Philipp A. Hartmann
c8673ef3de GenericReader::ParseNumber: consistently use s.Tell()
The error messages in ParseNumber used `is.Tell` to report the
position of the number parsing error.  Depending on the copy
optimization of the current stream, this can lead to different
behaviour (beginning of number vs. position of error).
2014-07-03 17:07:14 +02:00
Philipp A. Hartmann
249529f039 avoid truncation warning on MSVC 2014-07-03 17:07:07 +02:00
Philipp A. Hartmann
afa8279d8a GenericValue: drop duplicate/unneeded code
* Delegate constant string construction to SetStringRaw
 * Delegate "const Ch*" overloads to GenericValue variants
   of operator[], FindMember and RemoveMember
 * Remove repeated template arguments in nested struct Array

(cherry-picked from ca9b0332d)
2014-07-03 17:06:36 +02:00
Philipp A. Hartmann
d178fd4e94 Parse*: explicitly spell out kParseDefaultFlags
Instead of hard-coding the value 0 for the parseFlags in the
various parsing overloads, explicitly use kParseDefaultFlags
to provide more self-documenting code.
2014-07-03 17:06:35 +02:00
Philipp A. Hartmann
6b7f346437 ParseErrorCode: fix typo (NumberTooBig) 2014-07-03 17:06:35 +02:00
Milo Yip
1aa84342ba Added GenericValue::Swap() 2014-07-03 22:38:34 +08:00
Milo Yip
009c4005b2 Fixes 'not' keyword that is not supported by Visual Studio by default 2014-07-03 22:37:42 +08:00
Philipp A. Hartmann
5835750259 GenericMemberIterator: fixup some formatting and documentation
No functional changes.
2014-07-03 15:18:01 +02:00
Philipp A. Hartmann
86c47a6a8b document.h: move inclusion of template meta functions
In order to activate the suppression of "-Weffc++" warnings in the
template meta function classes (non-virtual destructor), move the
inclusion of the meta-function header `internal/meta.h` after the
suppression pragma.
2014-07-03 14:56:43 +02:00
Philipp A. Hartmann
43737ef310 GenericValue::FindMember: return MemberEnd, if member doesn't exist 2014-07-03 14:33:56 +02:00
Philipp A. Hartmann
17a8804cf3 document.h: add GenericMemberIterator
Add dedicated class-based member iterator to prepare the switch to a
(safe) API change to return MemberEnd() from FindMember().

Pointer-based iterator can be kept by defining
RAPIDJSON_NOMEMBERITERATORCLASS. This may be useful for platforms without
a working <iterator> header.
2014-07-03 14:29:57 +02:00
Philipp A. Hartmann
05179e2891 internal/meta.h: add some template meta functions
* Add/RemoveConst
 * IsSame, IsConst, IsMoreConst
 * Enable/DisableIf (including helper macro)
2014-07-03 14:24:58 +02:00
Philipp A. Hartmann
7890a1b17a StreamLocalCopy: move to reader.h
Eventually move to internal header `internal/streamcopy.h`?

Based on 088e8173.
2014-07-02 21:28:41 +02:00
Philipp A. Hartmann
f6903f79d4 GenericReader: simplify local stream copy optimization
rapidjson.h:
 * StreamLocalCopy: add default argument to copy optimization selector
   based on StreamTraits of Stream parameter
 * drop operator->, operator*
 * make Stream (reference) member public
 * drop empty destructor

reader.h:
 * add local references, initialized from "copy"
   (reverts algorithmic bodies back to plain 's.xx()')
2014-07-02 20:51:10 +02:00
Milo Yip
1e99f0b537 Merge remote-tracking branch 'origin/master' into warning 2014-07-03 01:00:01 +08:00
Milo Yip
5a186104f4 Fixes warnings 2014-07-03 00:59:35 +08:00
Milo Yip
2a9c7a9ffa Makes FileReadStream not using local copy optimization 2014-07-03 00:25:45 +08:00
Milo Yip
9aec8d6ad4 Fixes local copy optimization
The previous optimization #32 has problem that restoration requires
assignment operator.
Change the backup/restore process using a template wrapper class to
select code path.
2014-07-02 23:49:47 +08:00
Milo Yip
10924e389c Fixes parsing small floating point values underflow
https://code.google.com/p/rapidjson/issues/detail?id=75

The modification is slightly different from dlbattle123 to improve
speed.
2014-06-30 21:26:43 +08:00
miloyip
a9356c09c0 Fixes IBM XL C/C++ for AIX issue
Move rapidjson::GenericValue::Member to rapidjson::GenericMember

https://code.google.com/p/rapidjson/issues/detail?id=64
2014-06-30 19:07:58 +08:00
miloyip
a1ce06a187 Fixes vs2010 warning about INT64_C() 2014-06-30 10:18:14 +08:00
miloyip
389fe87cd8 Merge branch 'master' into issue23errorcode
Conflicts:
	example/condense/condense.cpp
	include/rapidjson/reader.h
	test/unittest/readertest.cpp
2014-06-30 09:44:24 +08:00
Milo Yip
8e76a9dcce Fixes compilation error
need ‘typename’ before
‘rapidjson::StreamTraits<InputStream>::StreamCopyType
2014-06-29 21:24:15 +08:00