diff options
author | Milo Yip <miloyip@gmail.com> | 2014-07-02 20:59:35 +0400 |
---|---|---|
committer | Milo Yip <miloyip@gmail.com> | 2014-07-02 20:59:35 +0400 |
commit | 5a186104f4b9b5f223d4fc997c92f856539df276 (patch) | |
tree | 8581732ee4e65200223ac81c2bff09844907e89c /include/rapidjson | |
parent | 5852c42bb9d407fe5ed6e5a94d59d4487bb84da4 (diff) |
Fixes warnings
Diffstat (limited to 'include/rapidjson')
-rw-r--r-- | include/rapidjson/document.h | 33 | ||||
-rw-r--r-- | include/rapidjson/encodedstream.h | 19 | ||||
-rw-r--r-- | include/rapidjson/encodings.h | 9 | ||||
-rw-r--r-- | include/rapidjson/filereadstream.h | 5 | ||||
-rw-r--r-- | include/rapidjson/filestream.h | 4 | ||||
-rw-r--r-- | include/rapidjson/filewritestream.h | 4 | ||||
-rw-r--r-- | include/rapidjson/internal/stack.h | 4 | ||||
-rw-r--r-- | include/rapidjson/prettywriter.h | 14 | ||||
-rw-r--r-- | include/rapidjson/writer.h | 5 |
9 files changed, 76 insertions, 21 deletions
diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index a95d57fa..ae13c28a 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -10,6 +10,11 @@ #pragma warning(disable : 4127) // conditional expression is constant
#endif
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Weffc++"
+#endif
+
namespace rapidjson {
// Forward declaration.
@@ -59,7 +64,7 @@ public: //@{
//! Default constructor creates a null value.
- GenericValue() : flags_(kNullFlag) {}
+ GenericValue() : data_(), flags_(kNullFlag) {}
//! Copy constructor is not permitted.
private:
@@ -72,7 +77,7 @@ public: \param type Type of the value.
\note Default content for number is zero.
*/
- GenericValue(Type type) : data_() {
+ GenericValue(Type type) : data_(), flags_() {
static const unsigned defaultFlags[7] = {
kNullFlag, kFalseFlag, kTrueFlag, kObjectFlag, kArrayFlag, kConstStringFlag,
kNumberAnyFlag
@@ -92,24 +97,24 @@ public: GenericValue(const GenericValue<Encoding,SourceAllocator>& rhs, Allocator & allocator);
//! Constructor for boolean value.
- explicit GenericValue(bool b) : flags_(b ? kTrueFlag : kFalseFlag) {}
+ explicit GenericValue(bool b) : data_(), flags_(b ? kTrueFlag : kFalseFlag) {}
//! Constructor for int value.
- explicit GenericValue(int i) : flags_(kNumberIntFlag) {
+ explicit GenericValue(int i) : data_(), flags_(kNumberIntFlag) {
data_.n.i64 = i;
if (i >= 0)
flags_ |= kUintFlag | kUint64Flag;
}
//! Constructor for unsigned value.
- explicit GenericValue(unsigned u) : flags_(kNumberUintFlag) {
+ explicit GenericValue(unsigned u) : data_(), flags_(kNumberUintFlag) {
data_.n.u64 = u;
if (!(u & 0x80000000))
flags_ |= kIntFlag | kInt64Flag;
}
//! Constructor for int64_t value.
- explicit GenericValue(int64_t i64) : flags_(kNumberInt64Flag) {
+ explicit GenericValue(int64_t i64) : data_(), flags_(kNumberInt64Flag) {
data_.n.i64 = i64;
if (i64 >= 0) {
flags_ |= kNumberUint64Flag;
@@ -123,7 +128,7 @@ public: }
//! Constructor for uint64_t value.
- explicit GenericValue(uint64_t u64) : flags_(kNumberUint64Flag) {
+ explicit GenericValue(uint64_t u64) : data_(), flags_(kNumberUint64Flag) {
data_.n.u64 = u64;
if (!(u64 & UINT64_C(0x8000000000000000)))
flags_ |= kInt64Flag;
@@ -134,10 +139,10 @@ public: }
//! Constructor for double value.
- explicit GenericValue(double d) : flags_(kNumberDoubleFlag) { data_.n.d = d; }
+ 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) {
+ GenericValue(const Ch* s, SizeType length) : data_(), flags_() {
RAPIDJSON_ASSERT(s != NULL);
flags_ = kConstStringFlag;
data_.s.str = s;
@@ -145,13 +150,13 @@ public: }
//! Constructor for constant string (i.e. do not make a copy of string)
- explicit GenericValue(const Ch* s) { SetStringRaw(s, internal::StrLen(s)); }
+ explicit GenericValue(const Ch* s) : data_(), flags_() { SetStringRaw(s, internal::StrLen(s)); }
//! Constructor for copy-string (i.e. do make a copy of string)
- GenericValue(const Ch* s, SizeType length, Allocator& allocator) { SetStringRaw(s, length, allocator); }
+ GenericValue(const Ch* s, SizeType length, Allocator& allocator) : data_(), flags_() { SetStringRaw(s, length, allocator); }
//! Constructor for copy-string (i.e. do make a copy of string)
- GenericValue(const Ch*s, Allocator& allocator) { SetStringRaw(s, internal::StrLen(s), allocator); }
+ GenericValue(const Ch*s, Allocator& allocator) : data_(), flags_() { SetStringRaw(s, internal::StrLen(s), allocator); }
//! Destructor.
/*! Need to destruct elements of array, members of object, or copy-string.
@@ -962,4 +967,8 @@ GenericValue<Encoding,Allocator>::GenericValue(const GenericValue<Encoding,Sourc #pragma warning(pop)
#endif
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
#endif // RAPIDJSON_DOCUMENT_H_
diff --git a/include/rapidjson/encodedstream.h b/include/rapidjson/encodedstream.h index 70bf6ce0..f33b14e3 100644 --- a/include/rapidjson/encodedstream.h +++ b/include/rapidjson/encodedstream.h @@ -3,6 +3,11 @@ #include "rapidjson.h"
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Weffc++"
+#endif
+
namespace rapidjson {
//! Input byte stream wrapper with a statically bound encoding.
@@ -31,7 +36,7 @@ public: size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
private:
- // Prohibit assignment for VC C4512 warning
+ EncodedInputStream(const EncodedInputStream&);
EncodedInputStream& operator=(const EncodedInputStream&);
InputByteStream& is_;
@@ -65,7 +70,7 @@ public: size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
private:
- // Prohibit assignment for VC C4512 warning
+ EncodedOutputStream(const EncodedOutputStream&);
EncodedOutputStream& operator=(const EncodedOutputStream&);
OutputByteStream& os_;
@@ -110,6 +115,9 @@ public: size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
private:
+ AutoUTFInputStream(const AutoUTFInputStream&);
+ AutoUTFInputStream& operator=(const AutoUTFInputStream&);
+
// Detect encoding type with BOM or RFC 4627
void DetectType() {
// BOM (Byte Order Mark):
@@ -230,6 +238,9 @@ public: size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
private:
+ AutoUTFOutputStream(const AutoUTFOutputStream&);
+ AutoUTFOutputStream& operator=(const AutoUTFOutputStream&);
+
void PutBOM() {
typedef void (*PutBOMFunc)(OutputByteStream&);
static const PutBOMFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(PutBOM) };
@@ -247,4 +258,8 @@ private: } // namespace rapidjson
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
#endif // RAPIDJSON_FILESTREAM_H_
diff --git a/include/rapidjson/encodings.h b/include/rapidjson/encodings.h index ce19340b..1e663223 100644 --- a/include/rapidjson/encodings.h +++ b/include/rapidjson/encodings.h @@ -3,6 +3,11 @@ #include "rapidjson.h"
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Weffc++"
+#endif
+
namespace rapidjson {
///////////////////////////////////////////////////////////////////////////////
@@ -524,4 +529,8 @@ struct Transcoder<Encoding, Encoding> { } // namespace rapidjson
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
#endif // RAPIDJSON_ENCODINGS_H_
diff --git a/include/rapidjson/filereadstream.h b/include/rapidjson/filereadstream.h index 29ab393e..4d42d381 100644 --- a/include/rapidjson/filereadstream.h +++ b/include/rapidjson/filereadstream.h @@ -69,11 +69,6 @@ private: bool eof_;
};
-template<>
-struct StreamTraits<FileReadStream> {
- typedef FileReadStream StreamCopyType; // Enable stream copy optimization.
-};
-
} // namespace rapidjson
#endif // RAPIDJSON_FILESTREAM_H_
diff --git a/include/rapidjson/filestream.h b/include/rapidjson/filestream.h index 985265d7..7e1e3b1f 100644 --- a/include/rapidjson/filestream.h +++ b/include/rapidjson/filestream.h @@ -28,6 +28,10 @@ public: size_t PutEnd(char*) { return 0; }
private:
+ // Prohibit copy constructor & assignment operator.
+ FileStream(const FileStream&);
+ FileStream& operator=(const FileStream&);
+
void Read() {
RAPIDJSON_ASSERT(fp_ != 0);
int c = fgetc(fp_);
diff --git a/include/rapidjson/filewritestream.h b/include/rapidjson/filewritestream.h index 9f0ce659..41283113 100644 --- a/include/rapidjson/filewritestream.h +++ b/include/rapidjson/filewritestream.h @@ -56,6 +56,10 @@ public: size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; }
private:
+ // Prohibit copy constructor & assignment operator.
+ FileWriteStream(const FileWriteStream&);
+ FileWriteStream& operator=(const FileWriteStream&);
+
FILE* fp_;
char *buffer_;
char *bufferEnd_;
diff --git a/include/rapidjson/internal/stack.h b/include/rapidjson/internal/stack.h index c1a8bedd..ff5ff82a 100644 --- a/include/rapidjson/internal/stack.h +++ b/include/rapidjson/internal/stack.h @@ -69,6 +69,10 @@ public: size_t GetCapacity() const { return stack_capacity_; }
private:
+ // Prohibit copy constructor & assignment operator.
+ Stack(const Stack&);
+ Stack& operator=(const Stack&);
+
Allocator* allocator_;
Allocator* own_allocator_;
char *stack_;
diff --git a/include/rapidjson/prettywriter.h b/include/rapidjson/prettywriter.h index 5b154ad7..cbbcdab1 100644 --- a/include/rapidjson/prettywriter.h +++ b/include/rapidjson/prettywriter.h @@ -3,6 +3,11 @@ #include "writer.h"
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Weffc++"
+#endif
+
namespace rapidjson {
//! Writer with indentation and spacing.
@@ -162,8 +167,17 @@ protected: Ch indentChar_;
unsigned indentCharCount_;
+
+private:
+ // Prohibit copy constructor & assignment operator.
+ PrettyWriter(const PrettyWriter&);
+ PrettyWriter& operator=(const PrettyWriter&);
};
} // namespace rapidjson
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
#endif // RAPIDJSON_RAPIDJSON_H_
diff --git a/include/rapidjson/writer.h b/include/rapidjson/writer.h index f3b088c4..95c550cd 100644 --- a/include/rapidjson/writer.h +++ b/include/rapidjson/writer.h @@ -284,8 +284,9 @@ protected: static const int kDefaultDoublePrecision = 6;
private:
- // Prohibit assignment for VC C4512 warning
- Writer& operator=(const Writer& w);
+ // Prohibit copy constructor & assignment operator.
+ Writer(const Writer&);
+ Writer& operator=(const Writer&);
};
} // namespace rapidjson
|