Commit 92554b52 authored by Milo Yip's avatar Milo Yip

Merge remote-tracking branch 'origin/master' into issue120floatprecision

parents 23b7a5ec 7eee4303
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <cstdio> #include <cstdio>
using namespace rapidjson; using namespace rapidjson;
using namespace std;
int main(int, char*[]) { int main(int, char*[]) {
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
......
...@@ -1896,9 +1896,26 @@ template <typename SourceAllocator> ...@@ -1896,9 +1896,26 @@ template <typename SourceAllocator>
inline inline
GenericValue<Encoding,Allocator>::GenericValue(const GenericValue<Encoding,SourceAllocator>& rhs, Allocator& allocator) GenericValue<Encoding,Allocator>::GenericValue(const GenericValue<Encoding,SourceAllocator>& rhs, Allocator& allocator)
{ {
switch (rhs.GetType()) {
case kObjectType:
case kArrayType: { // perform deep copy via SAX Handler
GenericDocument<Encoding,Allocator> d(&allocator); GenericDocument<Encoding,Allocator> d(&allocator);
rhs.Accept(d); rhs.Accept(d);
RawAssign(*d.stack_.template Pop<GenericValue>(1)); RawAssign(*d.stack_.template Pop<GenericValue>(1));
}
break;
case kStringType:
if (rhs.flags_ == kConstStringFlag) {
flags_ = rhs.flags_;
data_ = *reinterpret_cast<const Data*>(&rhs.data_);
} else {
SetStringRaw(StringRef(rhs.GetString(), rhs.GetStringLength()), allocator);
}
break;
default: // kNumberType, kTrueType, kFalseType, kNullType
flags_ = rhs.flags_;
data_ = *reinterpret_cast<const Data*>(&rhs.data_);
}
} }
RAPIDJSON_NAMESPACE_END RAPIDJSON_NAMESPACE_END
......
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
\param buffer user-supplied buffer. \param buffer user-supplied buffer.
\param bufferSize size of buffer in bytes. Must >=4 bytes. \param bufferSize size of buffer in bytes. Must >=4 bytes.
*/ */
FileReadStream(FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { FileReadStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) {
RAPIDJSON_ASSERT(fp_ != 0); RAPIDJSON_ASSERT(fp_ != 0);
RAPIDJSON_ASSERT(bufferSize >= 4); RAPIDJSON_ASSERT(bufferSize >= 4);
Read(); Read();
...@@ -79,7 +79,7 @@ private: ...@@ -79,7 +79,7 @@ private:
} }
} }
FILE* fp_; std::FILE* fp_;
Ch *buffer_; Ch *buffer_;
size_t bufferSize_; size_t bufferSize_;
Ch *bufferLast_; Ch *bufferLast_;
......
...@@ -36,7 +36,7 @@ class FileStream { ...@@ -36,7 +36,7 @@ class FileStream {
public: public:
typedef char Ch; //!< Character type. Only support char. typedef char Ch; //!< Character type. Only support char.
FileStream(FILE* fp) : fp_(fp), current_('\0'), count_(0) { Read(); } FileStream(std::FILE* fp) : fp_(fp), current_('\0'), count_(0) { Read(); }
char Peek() const { return current_; } char Peek() const { return current_; }
char Take() { char c = current_; Read(); return c; } char Take() { char c = current_; Read(); return c; }
size_t Tell() const { return count_; } size_t Tell() const { return count_; }
...@@ -63,7 +63,7 @@ private: ...@@ -63,7 +63,7 @@ private:
current_ = '\0'; current_ = '\0';
} }
FILE* fp_; std::FILE* fp_;
char current_; char current_;
size_t count_; size_t count_;
}; };
......
...@@ -34,7 +34,7 @@ class FileWriteStream { ...@@ -34,7 +34,7 @@ class FileWriteStream {
public: public:
typedef char Ch; //!< Character type. Only support char. typedef char Ch; //!< Character type. Only support char.
FileWriteStream(FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) { FileWriteStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) {
RAPIDJSON_ASSERT(fp_ != 0); RAPIDJSON_ASSERT(fp_ != 0);
} }
...@@ -80,7 +80,7 @@ private: ...@@ -80,7 +80,7 @@ private:
FileWriteStream(const FileWriteStream&); FileWriteStream(const FileWriteStream&);
FileWriteStream& operator=(const FileWriteStream&); FileWriteStream& operator=(const FileWriteStream&);
FILE* fp_; std::FILE* fp_;
char *buffer_; char *buffer_;
char *bufferEnd_; char *bufferEnd_;
char *current_; char *current_;
......
...@@ -76,7 +76,9 @@ TEST(StringBuffer, Pop) { ...@@ -76,7 +76,9 @@ TEST(StringBuffer, Pop) {
TEST(StringBuffer, Traits) { TEST(StringBuffer, Traits) {
static_assert( std::is_constructible<StringBuffer>::value, ""); static_assert( std::is_constructible<StringBuffer>::value, "");
static_assert( std::is_default_constructible<StringBuffer>::value, ""); static_assert( std::is_default_constructible<StringBuffer>::value, "");
#ifndef _MSC_VER
static_assert(!std::is_copy_constructible<StringBuffer>::value, ""); static_assert(!std::is_copy_constructible<StringBuffer>::value, "");
#endif
static_assert( std::is_move_constructible<StringBuffer>::value, ""); static_assert( std::is_move_constructible<StringBuffer>::value, "");
static_assert(!std::is_nothrow_constructible<StringBuffer>::value, ""); static_assert(!std::is_nothrow_constructible<StringBuffer>::value, "");
...@@ -85,7 +87,9 @@ TEST(StringBuffer, Traits) { ...@@ -85,7 +87,9 @@ TEST(StringBuffer, Traits) {
static_assert(!std::is_nothrow_move_constructible<StringBuffer>::value, ""); static_assert(!std::is_nothrow_move_constructible<StringBuffer>::value, "");
static_assert( std::is_assignable<StringBuffer,StringBuffer>::value, ""); static_assert( std::is_assignable<StringBuffer,StringBuffer>::value, "");
#ifndef _MSC_VER
static_assert(!std::is_copy_assignable<StringBuffer>::value, ""); static_assert(!std::is_copy_assignable<StringBuffer>::value, "");
#endif
static_assert( std::is_move_assignable<StringBuffer>::value, ""); static_assert( std::is_move_assignable<StringBuffer>::value, "");
static_assert(!std::is_nothrow_assignable<StringBuffer,StringBuffer>::value, ""); static_assert(!std::is_nothrow_assignable<StringBuffer,StringBuffer>::value, "");
...@@ -93,7 +97,9 @@ TEST(StringBuffer, Traits) { ...@@ -93,7 +97,9 @@ TEST(StringBuffer, Traits) {
static_assert(!std::is_nothrow_move_assignable<StringBuffer>::value, ""); static_assert(!std::is_nothrow_move_assignable<StringBuffer>::value, "");
static_assert( std::is_destructible<StringBuffer>::value, ""); static_assert( std::is_destructible<StringBuffer>::value, "");
static_assert( std::is_nothrow_destructible<StringBuffer>::value, ""); #ifndef _MSC_VER
static_assert(std::is_nothrow_destructible<StringBuffer>::value, "");
#endif
} }
TEST(StringBuffer, MoveConstructor) { TEST(StringBuffer, MoveConstructor) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment