Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilo Yip <miloyip@gmail.com>2014-06-25 12:06:00 +0400
committerMilo Yip <miloyip@gmail.com>2014-06-25 12:06:00 +0400
commite4ffa48a7563e892047c27f0a50fdeb6f71e6b8b (patch)
tree10a23f1332b47d4d163ee5005baf4771bfd46b85 /include/rapidjson
parent23056abad12c5bddf73e00b728d1d53c712627a5 (diff)
Remove some clang -Weverything warnings.
Diffstat (limited to 'include/rapidjson')
-rw-r--r--include/rapidjson/allocators.h16
-rw-r--r--include/rapidjson/encodings.h30
-rw-r--r--include/rapidjson/filereadstream.h4
-rw-r--r--include/rapidjson/filestream.h2
-rw-r--r--include/rapidjson/filewritestream.h8
-rw-r--r--include/rapidjson/internal/stack.h8
-rw-r--r--include/rapidjson/prettywriter.h5
-rw-r--r--include/rapidjson/rapidjson.h10
-rw-r--r--include/rapidjson/reader.h20
-rw-r--r--include/rapidjson/writer.h8
10 files changed, 56 insertions, 55 deletions
diff --git a/include/rapidjson/allocators.h b/include/rapidjson/allocators.h
index 6dfa85ae..1db5a1be 100644
--- a/include/rapidjson/allocators.h
+++ b/include/rapidjson/allocators.h
@@ -43,7 +43,7 @@ concept Allocator {
//! C-runtime library allocator.
/*! This class is just wrapper for standard C library memory routines.
- \implements Allocator
+ \note implements Allocator concept
*/
class CrtAllocator {
public:
@@ -70,7 +70,7 @@ public:
The user-buffer is not deallocated by this allocator.
\tparam BaseAllocator the allocator type for allocating memory chunks. Default is CrtAllocator.
- \implements Allocator
+ \note implements Allocator concept
*/
template <typename BaseAllocator = CrtAllocator>
class MemoryPoolAllocator {
@@ -99,12 +99,12 @@ public:
\param chunkSize The size of memory chunk. The default is kDefaultChunkSize.
\param baseAllocator The allocator for allocating memory chunks.
*/
- MemoryPoolAllocator(char *buffer, size_t size, size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) :
+ MemoryPoolAllocator(void *buffer, size_t size, size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) :
chunkHead_(0), chunk_capacity_(chunkSize), userBuffer_(buffer), baseAllocator_(baseAllocator), ownBaseAllocator_(0)
{
RAPIDJSON_ASSERT(buffer != 0);
RAPIDJSON_ASSERT(size > sizeof(ChunkHeader));
- chunkHead_ = (ChunkHeader*)buffer;
+ chunkHead_ = reinterpret_cast<ChunkHeader *>(buffer);
chunkHead_->capacity = size - sizeof(ChunkHeader);
chunkHead_->size = 0;
chunkHead_->next = 0;
@@ -120,7 +120,7 @@ public:
//! Deallocates all memory chunks, excluding the user-supplied buffer.
void Clear() {
- while(chunkHead_ != 0 && chunkHead_ != (ChunkHeader *)userBuffer_) {
+ while(chunkHead_ != 0 && chunkHead_ != userBuffer_) {
ChunkHeader* next = chunkHead_->next;
baseAllocator_->Free(chunkHead_);
chunkHead_ = next;
@@ -153,7 +153,7 @@ public:
if (chunkHead_->size + size > chunkHead_->capacity)
AddChunk(chunk_capacity_ > size ? chunk_capacity_ : size);
- char *buffer = (char *)(chunkHead_ + 1) + chunkHead_->size;
+ void *buffer = reinterpret_cast<char *>(chunkHead_ + 1) + chunkHead_->size;
chunkHead_->size += size;
return buffer;
}
@@ -169,7 +169,7 @@ public:
// Simply expand it if it is the last allocation and there is sufficient space
if (originalPtr == (char *)(chunkHead_ + 1) + chunkHead_->size - originalSize) {
- size_t increment = newSize - originalSize;
+ size_t increment = static_cast<size_t>(newSize - originalSize);
increment = RAPIDJSON_ALIGN(increment);
if (chunkHead_->size + increment <= chunkHead_->capacity) {
chunkHead_->size += increment;
@@ -211,7 +211,7 @@ private:
ChunkHeader *chunkHead_; //!< Head of the chunk linked-list. Only the head chunk serves allocation.
size_t chunk_capacity_; //!< The minimum capacity of chunk when they are allocated.
- char *userBuffer_; //!< User supplied buffer.
+ void *userBuffer_; //!< User supplied buffer.
BaseAllocator* baseAllocator_; //!< base allocator for allocating memory chunks.
BaseAllocator* ownBaseAllocator_; //!< base allocator created by this object.
};
diff --git a/include/rapidjson/encodings.h b/include/rapidjson/encodings.h
index c7e8e5b1..16397e65 100644
--- a/include/rapidjson/encodings.h
+++ b/include/rapidjson/encodings.h
@@ -64,7 +64,7 @@ concept Encoding {
/*! http://en.wikipedia.org/wiki/UTF-8
http://tools.ietf.org/html/rfc3629
\tparam CharType Code unit for storing 8-bit UTF-8 data. Default is char.
- \implements Encoding
+ \note implements Encoding concept.
*/
template<typename CharType = char>
struct UTF8 {
@@ -73,22 +73,22 @@ struct UTF8 {
template<typename OutputStream>
static void Encode(OutputStream& os, unsigned codepoint) {
if (codepoint <= 0x7F)
- os.Put(codepoint & 0xFF);
+ os.Put(static_cast<Ch>(codepoint & 0xFF));
else if (codepoint <= 0x7FF) {
- os.Put(0xC0 | ((codepoint >> 6) & 0xFF));
- os.Put(0x80 | ((codepoint & 0x3F)));
+ os.Put(static_cast<Ch>(0xC0 | ((codepoint >> 6) & 0xFF)));
+ os.Put(static_cast<Ch>(0x80 | ((codepoint & 0x3F))));
}
else if (codepoint <= 0xFFFF) {
- os.Put(0xE0 | ((codepoint >> 12) & 0xFF));
- os.Put(0x80 | ((codepoint >> 6) & 0x3F));
- os.Put(0x80 | (codepoint & 0x3F));
+ os.Put(static_cast<Ch>(0xE0 | ((codepoint >> 12) & 0xFF)));
+ os.Put(static_cast<Ch>(0x80 | ((codepoint >> 6) & 0x3F)));
+ os.Put(static_cast<Ch>(0x80 | (codepoint & 0x3F)));
}
else {
RAPIDJSON_ASSERT(codepoint <= 0x10FFFF);
- os.Put(0xF0 | ((codepoint >> 18) & 0xFF));
- os.Put(0x80 | ((codepoint >> 12) & 0x3F));
- os.Put(0x80 | ((codepoint >> 6) & 0x3F));
- os.Put(0x80 | (codepoint & 0x3F));
+ os.Put(static_cast<Ch>(0xF0 | ((codepoint >> 18) & 0xFF)));
+ os.Put(static_cast<Ch>(0x80 | ((codepoint >> 12) & 0x3F)));
+ os.Put(static_cast<Ch>(0x80 | ((codepoint >> 6) & 0x3F)));
+ os.Put(static_cast<Ch>(0x80 | (codepoint & 0x3F)));
}
}
@@ -204,7 +204,7 @@ struct UTF8 {
/*! http://en.wikipedia.org/wiki/UTF-16
http://tools.ietf.org/html/rfc2781
\tparam CharType Type for storing 16-bit UTF-16 data. Default is wchar_t. C++11 may use char16_t instead.
- \implements Encoding
+ \note implements Encoding concept
\note For in-memory access, no need to concern endianness. The code units and code points are represented by CPU's endianness.
For streaming, use UTF16LE and UTF16BE, which handle endianness.
@@ -332,8 +332,8 @@ struct UTF16BE : UTF16<CharType> {
//! UTF-32 encoding.
/*! http://en.wikipedia.org/wiki/UTF-32
- \tparam Ch Type for storing 32-bit UTF-32 data. Default is unsigned. C++11 may use char32_t instead.
- \implements Encoding
+ \tparam CharType Type for storing 32-bit UTF-32 data. Default is unsigned. C++11 may use char32_t instead.
+ \note implements Encoding concept
\note For in-memory access, no need to concern endianness. The code units and code points are represented by CPU's endianness.
For streaming, use UTF32LE and UTF32BE, which handle endianness.
@@ -448,7 +448,7 @@ enum UTFType {
kUTF16LE = 1, //!< UTF-16 little endian.
kUTF16BE = 2, //!< UTF-16 big endian.
kUTF32LE = 3, //!< UTF-32 little endian.
- kUTF32BE = 4, //!< UTF-32 big endian.
+ kUTF32BE = 4 //!< UTF-32 big endian.
};
//! Dynamically select encoding according to stream's runtime-specified UTF encoding type.
diff --git a/include/rapidjson/filereadstream.h b/include/rapidjson/filereadstream.h
index 2d208416..4d42d381 100644
--- a/include/rapidjson/filereadstream.h
+++ b/include/rapidjson/filereadstream.h
@@ -8,7 +8,7 @@ namespace rapidjson {
//! File byte stream for input using fread().
/*!
- \implements Stream
+ \note implements Stream concept
*/
class FileReadStream {
public:
@@ -28,7 +28,7 @@ public:
Ch Peek() const { return *current_; }
Ch Take() { Ch c = *current_; Read(); return c; }
- size_t Tell() const { return count_ + (current_ - buffer_); }
+ size_t Tell() const { return count_ + static_cast<size_t>(current_ - buffer_); }
// Not implemented
void Put(Ch) { RAPIDJSON_ASSERT(false); }
diff --git a/include/rapidjson/filestream.h b/include/rapidjson/filestream.h
index 57ab0bad..e0099d58 100644
--- a/include/rapidjson/filestream.h
+++ b/include/rapidjson/filestream.h
@@ -9,7 +9,7 @@ namespace rapidjson {
//! (Depreciated) Wrapper of C file stream for input or output.
/*!
This simple wrapper does not check the validity of the stream.
- \implements Stream
+ \note implements Stream concept
\deprecated { This was only for basic testing in version 0.1, it is found that the performance is very low by using fgetc(). Use FileReadStream instead. }
*/
class FileStream {
diff --git a/include/rapidjson/filewritestream.h b/include/rapidjson/filewritestream.h
index 3d15ea87..9f0ce659 100644
--- a/include/rapidjson/filewritestream.h
+++ b/include/rapidjson/filewritestream.h
@@ -8,7 +8,7 @@ namespace rapidjson {
//! Wrapper of C file stream for input using fread().
/*!
- \implements Stream
+ \note implements Stream concept
*/
class FileWriteStream {
public:
@@ -26,13 +26,13 @@ public:
}
void PutN(char c, size_t n) {
- size_t avail = bufferEnd_ - current_;
+ size_t avail = static_cast<size_t>(bufferEnd_ - current_);
while (n > avail) {
memset(current_, c, avail);
current_ += avail;
Flush();
n -= avail;
- avail = bufferEnd_ - current_;
+ avail = static_cast<size_t>(bufferEnd_ - current_);
}
if (n > 0) {
@@ -43,7 +43,7 @@ public:
void Flush() {
if (current_ != buffer_) {
- fwrite(buffer_, 1, current_ - buffer_, fp_);
+ fwrite(buffer_, 1, static_cast<size_t>(current_ - buffer_), fp_);
current_ = buffer_;
}
}
diff --git a/include/rapidjson/internal/stack.h b/include/rapidjson/internal/stack.h
index 6ed47e33..c1a8bedd 100644
--- a/include/rapidjson/internal/stack.h
+++ b/include/rapidjson/internal/stack.h
@@ -42,7 +42,7 @@ public:
stack_top_ = stack_ + size;
stack_end_ = stack_ + stack_capacity_;
}
- T* ret = (T*)stack_top_;
+ T* ret = reinterpret_cast<T*>(stack_top_);
stack_top_ += sizeof(T) * count;
return ret;
}
@@ -51,13 +51,13 @@ public:
T* Pop(size_t count) {
RAPIDJSON_ASSERT(GetSize() >= count * sizeof(T));
stack_top_ -= count * sizeof(T);
- return (T*)stack_top_;
+ return reinterpret_cast<T*>(stack_top_);
}
template<typename T>
T* Top() {
RAPIDJSON_ASSERT(GetSize() >= sizeof(T));
- return (T*)(stack_top_ - sizeof(T));
+ return reinterpret_cast<T*>(stack_top_ - sizeof(T));
}
template<typename T>
@@ -65,7 +65,7 @@ public:
Allocator& GetAllocator() { return *allocator_; }
bool Empty() const { return stack_top_ == stack_; }
- size_t GetSize() const { return stack_top_ - stack_; }
+ size_t GetSize() const { return static_cast<size_t>(stack_top_ - stack_); }
size_t GetCapacity() const { return stack_capacity_; }
private:
diff --git a/include/rapidjson/prettywriter.h b/include/rapidjson/prettywriter.h
index 2a0a505f..112456e9 100644
--- a/include/rapidjson/prettywriter.h
+++ b/include/rapidjson/prettywriter.h
@@ -8,7 +8,8 @@ namespace rapidjson {
//! Writer with indentation and spacing.
/*!
\tparam OutputStream Type of ouptut os.
- \tparam Encoding Encoding of both source strings and output.
+ \tparam SourceEncoding Encoding of source.
+ \tparam TargetEncoding Encoding of target in output stream.
\tparam Allocator Type of allocator for allocating memory of stack.
*/
template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename Allocator = MemoryPoolAllocator<> >
@@ -26,7 +27,7 @@ public:
Base(os, allocator, levelDepth), indentChar_(' '), indentCharCount_(4) {}
//! Set custom indentation.
- /*! \param indentChar Character for indentation. Must be whitespace character (' ', '\t', '\n', '\r').
+ /*! \param indentChar Character for indentation. Must be whitespace character (' ', '\\t', '\\n', '\\r').
\param indentCharCount Number of indent characters for each indentation level.
\note The default indentation is 4 spaces.
*/
diff --git a/include/rapidjson/rapidjson.h b/include/rapidjson/rapidjson.h
index 2ba3c580..b11e6b96 100644
--- a/include/rapidjson/rapidjson.h
+++ b/include/rapidjson/rapidjson.h
@@ -55,7 +55,7 @@ typedef unsigned __int64 uint64_t;
Currently the default uses 4 bytes alignment. User can customize this.
*/
#ifndef RAPIDJSON_ALIGN
-#define RAPIDJSON_ALIGN(x) ((x + 3) & ~3)
+#define RAPIDJSON_ALIGN(x) ((x + 3u) & ~3u)
#endif
///////////////////////////////////////////////////////////////////////////////
@@ -183,7 +183,7 @@ inline void PutN(Stream& stream, Ch c, size_t n) {
// StringStream
//! Read-only string stream.
-/*! \implements Stream
+/*! \note implements Stream concept
*/
template <typename Encoding>
struct GenericStringStream {
@@ -193,7 +193,7 @@ struct GenericStringStream {
Ch Peek() const { return *src_; }
Ch Take() { return *src_++; }
- size_t Tell() const { return src_ - head_; }
+ size_t Tell() const { return static_cast<size_t>(src_ - head_); }
Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
void Put(Ch) { RAPIDJSON_ASSERT(false); }
@@ -211,7 +211,7 @@ typedef GenericStringStream<UTF8<> > StringStream;
//! A read-write string stream.
/*! This string stream is particularly designed for in-situ parsing.
- \implements Stream
+ \note implements Stream concept
*/
template <typename Encoding>
struct GenericInsituStringStream {
@@ -248,7 +248,7 @@ enum Type {
kObjectType = 3, //!< object
kArrayType = 4, //!< array
kStringType = 5, //!< string
- kNumberType = 6, //!< number
+ kNumberType = 6 //!< number
};
} // namespace rapidjson
diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h
index c932dea4..67f52e49 100644
--- a/include/rapidjson/reader.h
+++ b/include/rapidjson/reader.h
@@ -39,7 +39,7 @@ namespace rapidjson {
enum ParseFlag {
kParseDefaultFlags = 0, //!< Default parse flags. Non-destructive parsing. Text strings are decoded into allocated buffer.
kParseInsituFlag = 1, //!< In-situ(destructive) parsing.
- kParseValidateEncodingFlag = 2, //!< Validate encoding of JSON strings.
+ kParseValidateEncodingFlag = 2 //!< Validate encoding of JSON strings.
};
///////////////////////////////////////////////////////////////////////////////
@@ -71,7 +71,7 @@ concept Handler {
//! Default implementation of Handler.
/*! This can be used as base class of any reader handler.
- \implements Handler
+ \note implements Handler concept
*/
template<typename Encoding = UTF8<> >
struct BaseReaderHandler {
@@ -96,7 +96,7 @@ struct BaseReaderHandler {
// SkipWhitespace
//! Skip the JSON white spaces in a stream.
-/*! \param stream A input stream for skipping white spaces.
+/*! \param is A input stream for skipping white spaces.
\note This function has SSE2/SSE4.2 specialization.
*/
template<typename InputStream>
@@ -216,7 +216,7 @@ public:
/*! \tparam parseFlags Combination of ParseFlag.
\tparam InputStream Type of input stream.
\tparam Handler Type of handler which must implement Handler concept.
- \param stream Input stream to be parsed.
+ \param is Input stream to be parsed.
\param handler The handler to receive events.
\return Whether the parsing is successful.
*/
@@ -368,7 +368,7 @@ private:
for (int i = 0; i < 4; i++) {
Ch c = s.Take();
codepoint <<= 4;
- codepoint += c;
+ codepoint += static_cast<unsigned>(c);
if (c >= '0' && c <= '9')
codepoint -= '0';
else if (c >= 'A' && c <= 'F')
@@ -494,7 +494,7 @@ private:
s.Take();
}
else if (s.Peek() >= '1' && s.Peek() <= '9') {
- i = s.Take() - '0';
+ i = static_cast<unsigned>(s.Take() - '0');
if (minus)
while (s.Peek() >= '0' && s.Peek() <= '9') {
@@ -504,7 +504,7 @@ private:
break;
}
}
- i = i * 10 + (s.Take() - '0');
+ i = i * 10 + static_cast<unsigned>(s.Take() - '0');
}
else
while (s.Peek() >= '0' && s.Peek() <= '9') {
@@ -514,7 +514,7 @@ private:
break;
}
}
- i = i * 10 + (s.Take() - '0');
+ i = i * 10 + static_cast<unsigned>(s.Take() - '0');
}
}
else
@@ -532,7 +532,7 @@ private:
useDouble = true;
break;
}
- i64 = i64 * 10 + (s.Take() - '0');
+ i64 = i64 * 10 + static_cast<unsigned>(s.Take() - '0');
}
else
while (s.Peek() >= '0' && s.Peek() <= '9') {
@@ -541,7 +541,7 @@ private:
useDouble = true;
break;
}
- i64 = i64 * 10 + (s.Take() - '0');
+ i64 = i64 * 10 + static_cast<unsigned>(s.Take() - '0');
}
}
diff --git a/include/rapidjson/writer.h b/include/rapidjson/writer.h
index 4f3aedc3..38dc8b8c 100644
--- a/include/rapidjson/writer.h
+++ b/include/rapidjson/writer.h
@@ -27,7 +27,7 @@ namespace rapidjson {
\tparam OutputStream Type of output stream.
\tparam SourceEncoding Encoding of both source strings.
\tparam TargetEncoding Encoding of and output stream.
- \implements Handler
+ \note implements Handler concept
*/
template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename Allocator = MemoryPoolAllocator<> >
class Writer {
@@ -97,9 +97,9 @@ public:
protected:
//! Information for each nested level
struct Level {
- Level(bool inArray_) : inArray(inArray_), valueCount(0) {}
- bool inArray; //!< true if in array, otherwise in object
+ Level(bool inArray_) : valueCount(0), inArray(inArray_) {}
size_t valueCount; //!< number of values in this level
+ bool inArray; //!< true if in array, otherwise in object
};
static const size_t kDefaultLevelDepth = 32;
@@ -164,7 +164,7 @@ protected:
//! \todo Optimization with custom double-to-string converter.
void WriteDouble(double d) {
char buffer[100];
-#if _MSC_VER
+#ifdef _MSC_VER
int ret = sprintf_s(buffer, sizeof(buffer), "%g", d);
#else
int ret = snprintf(buffer, sizeof(buffer), "%g", d);