rj_schema 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19eb83cc4006b11ecda8501708b451b4cfe400e16647c500767d55529036d6c6
4
- data.tar.gz: 89d3ff306e51a50b0126d37fa5497b2bf0b8412410c0085e5cd2d888678b6b9c
3
+ metadata.gz: db6d63465e54f3312ccd40d2c977010837c56752ff9f69cec195e16c2e649e84
4
+ data.tar.gz: 26f7ecbf9a6db0a996e0ea957170ac61f167a56f26569efa449e93516093fdc8
5
5
  SHA512:
6
- metadata.gz: 70bdd94dabed8771fc19638d574301d57087b3dc06a681552c6a03fbec59427af11ee5a14c1f115f850f37acbbd6ca8c27892d4b15f9eac01878db2354b9f3e6
7
- data.tar.gz: 0154d872a12749c5cd3740db0cb82001e1e0fcce4aa930fdd40e1f76cfafcb07f0e46efdec72c6cbb63d295a2ba3a44b681b2c02d86bd7e1ed063a19dd183750
6
+ metadata.gz: 13950dad02f406b7ab9393b49b671da97f496857f8636a7117742eed6ca40bbb24eba7c23e51cce143e228814808abb3f9b98ba79140d5463217b3c61bc681a6
7
+ data.tar.gz: a5f68291b62e4ff4c40ea9d099f556ebf1ca390ed1b1ed095330436debd7cf9a4d2bfdc75f3113287ec8eb78d5732d31593b30d08256b7afcc9989b33fe25230
@@ -128,7 +128,7 @@ IF(UNIX OR CYGWIN)
128
128
  ELSEIF(WIN32)
129
129
  SET(_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/cmake")
130
130
  ENDIF()
131
- SET(CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" CACHE PATH "The directory cmake fiels are installed in")
131
+ SET(CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" CACHE PATH "The directory cmake files are installed in")
132
132
 
133
133
  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
134
134
 
@@ -1126,7 +1126,7 @@ HTML_STYLESHEET =
1126
1126
  # defined cascading style sheet that is included after the standard style sheets
1127
1127
  # created by doxygen. Using this option one can overrule certain style aspects.
1128
1128
  # This is preferred over using HTML_STYLESHEET since it does not replace the
1129
- # standard style sheet and is therefor more robust against future updates.
1129
+ # standard style sheet and is therefore more robust against future updates.
1130
1130
  # Doxygen will copy the style sheet file to the output directory. For an example
1131
1131
  # see the documentation.
1132
1132
  # This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1126,7 +1126,7 @@ HTML_STYLESHEET =
1126
1126
  # defined cascading style sheet that is included after the standard style sheets
1127
1127
  # created by doxygen. Using this option one can overrule certain style aspects.
1128
1128
  # This is preferred over using HTML_STYLESHEET since it does not replace the
1129
- # standard style sheet and is therefor more robust against future updates.
1129
+ # standard style sheet and is therefore more robust against future updates.
1130
1130
  # Doxygen will copy the style sheet file to the output directory. For an example
1131
1131
  # see the documentation.
1132
1132
  # This tag requires that the tag GENERATE_HTML is set to YES.
@@ -236,7 +236,7 @@ Alternatively, if we don't want to explicitly refer to the root value of `addres
236
236
 
237
237
  4. What is BOM? How RapidJSON handle it?
238
238
 
239
- [Byte order mark (BOM)](http://en.wikipedia.org/wiki/Byte_order_mark) sometimes reside at the beginning of file/stream to indiciate the UTF encoding type of it.
239
+ [Byte order mark (BOM)](http://en.wikipedia.org/wiki/Byte_order_mark) sometimes reside at the beginning of file/stream to indicate the UTF encoding type of it.
240
240
 
241
241
  RapidJSON's `EncodedInputStream` can detect/consume BOM. `EncodedOutputStream` can optionally write a BOM. See [Encoded Streams](doc/stream.md) for example.
242
242
 
@@ -28,7 +28,7 @@ Both SAX and DOM APIs depends on 3 additional concepts: `Allocator`, `Encoding`
28
28
 
29
29
  ## Data Layout {#DataLayout}
30
30
 
31
- `Value` is a [variant type](http://en.wikipedia.org/wiki/Variant_type). In RapidJSON's context, an instance of `Value` can contain 1 of 6 JSON value types. This is possible by using `union`. Each `Value` contains two members: `union Data data_` and a`unsigned flags_`. The `flags_` indiciates the JSON type, and also additional information.
31
+ `Value` is a [variant type](http://en.wikipedia.org/wiki/Variant_type). In RapidJSON's context, an instance of `Value` can contain 1 of 6 JSON value types. This is possible by using `union`. Each `Value` contains two members: `union Data data_` and a`unsigned flags_`. The `flags_` indicates the JSON type, and also additional information.
32
32
 
33
33
  The following tables show the data layout of each type. The 32-bit/64-bit columns indicates the size of the field in bytes.
34
34
 
@@ -101,7 +101,7 @@ The following tables show the data layout of each type. The 32-bit/64-bit column
101
101
 
102
102
  Here are some notes:
103
103
  * To reduce memory consumption for 64-bit architecture, `SizeType` is typedef as `unsigned` instead of `size_t`.
104
- * Zero padding for 32-bit number may be placed after or before the actual type, according to the endianess. This makes possible for interpreting a 32-bit integer as a 64-bit integer, without any conversion.
104
+ * Zero padding for 32-bit number may be placed after or before the actual type, according to the endianness. This makes possible for interpreting a 32-bit integer as a 64-bit integer, without any conversion.
105
105
  * An `Int` is always an `Int64`, but the converse is not always true.
106
106
 
107
107
  ## Flags {#Flags}
@@ -42,6 +42,7 @@ Note that, `StringStream` is a typedef of `GenericStringStream<UTF8<> >`, user m
42
42
 
43
43
  ~~~~~~~~~~cpp
44
44
  #include "rapidjson/stringbuffer.h"
45
+ #include <rapidjson/writer.h>
45
46
 
46
47
  StringBuffer buffer;
47
48
  Writer<StringBuffer> writer(buffer);
@@ -98,6 +99,7 @@ Apart from reading file, user can also use `FileReadStream` to read `stdin`.
98
99
 
99
100
  ~~~~~~~~~~cpp
100
101
  #include "rapidjson/filewritestream.h"
102
+ #include <rapidjson/writer.h>
101
103
  #include <cstdio>
102
104
 
103
105
  using namespace rapidjson;
@@ -215,6 +217,7 @@ fclose(fp);
215
217
  ~~~~~~~~~~cpp
216
218
  #include "rapidjson/filewritestream.h" // FileWriteStream
217
219
  #include "rapidjson/encodedstream.h" // EncodedOutputStream
220
+ #include <rapidjson/writer.h>
218
221
  #include <cstdio>
219
222
 
220
223
  Document d; // Document is GenericDocument<UTF8<> >
@@ -42,6 +42,7 @@ d.Parse(json);
42
42
 
43
43
  ~~~~~~~~~~cpp
44
44
  #include "rapidjson/stringbuffer.h"
45
+ #include <rapidjson/writer.h>
45
46
 
46
47
  StringBuffer buffer;
47
48
  Writer<StringBuffer> writer(buffer);
@@ -98,6 +99,7 @@ fclose(fp);
98
99
 
99
100
  ~~~~~~~~~~cpp
100
101
  #include "rapidjson/filewritestream.h"
102
+ #include <rapidjson/writer.h>
101
103
  #include <cstdio>
102
104
 
103
105
  using namespace rapidjson;
@@ -215,6 +217,7 @@ fclose(fp);
215
217
  ~~~~~~~~~~cpp
216
218
  #include "rapidjson/filewritestream.h" // FileWriteStream
217
219
  #include "rapidjson/encodedstream.h" // EncodedOutputStream
220
+ #include <rapidjson/writer.h>
218
221
  #include <cstdio>
219
222
 
220
223
  Document d; // Document 为 GenericDocument<UTF8<> >
@@ -97,7 +97,7 @@ private:
97
97
  // PIMPL
98
98
  void* mDocument; ///< DOM result of parsing.
99
99
  void* mStack; ///< Stack for iterating the DOM
100
- bool mError; ///< Whether an error is occured.
100
+ bool mError; ///< Whether an error has occurred.
101
101
  };
102
102
 
103
103
  class JsonWriter {
@@ -1,4 +1,4 @@
1
- // JSON to JSONx conversion exmaple, using SAX API.
1
+ // JSON to JSONx conversion example, using SAX API.
2
2
  // JSONx is an IBM standard format to represent JSON as XML.
3
3
  // https://www-01.ibm.com/support/knowledgecenter/SS9H2Y_7.1.0/com.ibm.dp.doc/json_jsonx.html
4
4
  // This example parses JSON text from stdin with validation,
@@ -143,7 +143,7 @@ int main() {
143
143
  AsyncDocumentParser<> parser(d);
144
144
 
145
145
  const char json1[] = " { \"hello\" : \"world\", \"t\" : tr";
146
- //const char json1[] = " { \"hello\" : \"world\", \"t\" : trX"; // Fot test parsing error
146
+ //const char json1[] = " { \"hello\" : \"world\", \"t\" : trX"; // For test parsing error
147
147
  const char json2[] = "ue, \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.14";
148
148
  const char json3[] = "16, \"a\":[1, 2, 3, 4] } ";
149
149
 
@@ -451,6 +451,26 @@ struct TypeHelper<ValueType, unsigned> {
451
451
  static ValueType& Set(ValueType& v, unsigned data, typename ValueType::AllocatorType&) { return v.SetUint(data); }
452
452
  };
453
453
 
454
+ #ifdef _MSC_VER
455
+ RAPIDJSON_STATIC_ASSERT(sizeof(long) == sizeof(int));
456
+ template<typename ValueType>
457
+ struct TypeHelper<ValueType, long> {
458
+ static bool Is(const ValueType& v) { return v.IsInt(); }
459
+ static long Get(const ValueType& v) { return v.GetInt(); }
460
+ static ValueType& Set(ValueType& v, long data) { return v.SetInt(data); }
461
+ static ValueType& Set(ValueType& v, long data, typename ValueType::AllocatorType&) { return v.SetInt(data); }
462
+ };
463
+
464
+ RAPIDJSON_STATIC_ASSERT(sizeof(unsigned long) == sizeof(unsigned));
465
+ template<typename ValueType>
466
+ struct TypeHelper<ValueType, unsigned long> {
467
+ static bool Is(const ValueType& v) { return v.IsUint(); }
468
+ static unsigned long Get(const ValueType& v) { return v.GetUint(); }
469
+ static ValueType& Set(ValueType& v, unsigned long data) { return v.SetUint(data); }
470
+ static ValueType& Set(ValueType& v, unsigned long data, typename ValueType::AllocatorType&) { return v.SetUint(data); }
471
+ };
472
+ #endif
473
+
454
474
  template<typename ValueType>
455
475
  struct TypeHelper<ValueType, int64_t> {
456
476
  static bool Is(const ValueType& v) { return v.IsInt64(); }
@@ -2014,7 +2034,12 @@ private:
2014
2034
  if (count) {
2015
2035
  GenericValue* e = static_cast<GenericValue*>(allocator.Malloc(count * sizeof(GenericValue)));
2016
2036
  SetElementsPointer(e);
2037
+ RAPIDJSON_DIAG_PUSH
2038
+ #if defined(__GNUC__) && __GNUC__ >= 8
2039
+ RAPIDJSON_DIAG_OFF(class-memaccess) // ignore complains from gcc that no trivial copy constructor exists.
2040
+ #endif
2017
2041
  std::memcpy(e, values, count * sizeof(GenericValue));
2042
+ RAPIDJSON_DIAG_POP
2018
2043
  }
2019
2044
  else
2020
2045
  SetElementsPointer(0);
@@ -2027,7 +2052,12 @@ private:
2027
2052
  if (count) {
2028
2053
  Member* m = static_cast<Member*>(allocator.Malloc(count * sizeof(Member)));
2029
2054
  SetMembersPointer(m);
2055
+ RAPIDJSON_DIAG_PUSH
2056
+ #if defined(__GNUC__) && __GNUC__ >= 8
2057
+ RAPIDJSON_DIAG_OFF(class-memaccess) // ignore complains from gcc that no trivial copy constructor exists.
2058
+ #endif
2030
2059
  std::memcpy(m, members, count * sizeof(Member));
2060
+ RAPIDJSON_DIAG_POP
2031
2061
  }
2032
2062
  else
2033
2063
  SetMembersPointer(0);
@@ -2362,7 +2392,7 @@ public:
2362
2392
  //!@name Handling parse errors
2363
2393
  //!@{
2364
2394
 
2365
- //! Whether a parse error has occured in the last parsing.
2395
+ //! Whether a parse error has occurred in the last parsing.
2366
2396
  bool HasParseError() const { return parseResult_.IsError(); }
2367
2397
 
2368
2398
  //! Get the \ref ParseErrorCode of last parsing.
@@ -17,7 +17,7 @@
17
17
 
18
18
  #include "../rapidjson.h"
19
19
 
20
- #if defined(_MSC_VER) && defined(_M_AMD64)
20
+ #if defined(_MSC_VER) && !__INTEL_COMPILER && defined(_M_AMD64)
21
21
  #include <intrin.h> // for _umul128
22
22
  #pragma intrinsic(_umul128)
23
23
  #endif
@@ -1,5 +1,5 @@
1
1
  // Tencent is pleased to support the open source community by making RapidJSON available.
2
- //
2
+ //
3
3
  // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4
4
  //
5
5
  // Licensed under the MIT License (the "License"); you may not use this file except
@@ -7,9 +7,9 @@
7
7
  //
8
8
  // http://opensource.org/licenses/MIT
9
9
  //
10
- // Unless required by applicable law or agreed to in writing, software distributed
11
- // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12
- // CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ // Unless required by applicable law or agreed to in writing, software distributed
11
+ // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12
+ // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13
13
  // specific language governing permissions and limitations under the License.
14
14
 
15
15
  #ifndef RAPIDJSON_ITOA_
@@ -37,12 +37,14 @@ inline const char* GetDigitsLut() {
37
37
  }
38
38
 
39
39
  inline char* u32toa(uint32_t value, char* buffer) {
40
+ RAPIDJSON_ASSERT(buffer != 0);
41
+
40
42
  const char* cDigitsLut = GetDigitsLut();
41
43
 
42
44
  if (value < 10000) {
43
45
  const uint32_t d1 = (value / 100) << 1;
44
46
  const uint32_t d2 = (value % 100) << 1;
45
-
47
+
46
48
  if (value >= 1000)
47
49
  *buffer++ = cDigitsLut[d1];
48
50
  if (value >= 100)
@@ -55,13 +57,13 @@ inline char* u32toa(uint32_t value, char* buffer) {
55
57
  // value = bbbbcccc
56
58
  const uint32_t b = value / 10000;
57
59
  const uint32_t c = value % 10000;
58
-
60
+
59
61
  const uint32_t d1 = (b / 100) << 1;
60
62
  const uint32_t d2 = (b % 100) << 1;
61
-
63
+
62
64
  const uint32_t d3 = (c / 100) << 1;
63
65
  const uint32_t d4 = (c % 100) << 1;
64
-
66
+
65
67
  if (value >= 10000000)
66
68
  *buffer++ = cDigitsLut[d1];
67
69
  if (value >= 1000000)
@@ -69,7 +71,7 @@ inline char* u32toa(uint32_t value, char* buffer) {
69
71
  if (value >= 100000)
70
72
  *buffer++ = cDigitsLut[d2];
71
73
  *buffer++ = cDigitsLut[d2 + 1];
72
-
74
+
73
75
  *buffer++ = cDigitsLut[d3];
74
76
  *buffer++ = cDigitsLut[d3 + 1];
75
77
  *buffer++ = cDigitsLut[d4];
@@ -77,10 +79,10 @@ inline char* u32toa(uint32_t value, char* buffer) {
77
79
  }
78
80
  else {
79
81
  // value = aabbbbcccc in decimal
80
-
82
+
81
83
  const uint32_t a = value / 100000000; // 1 to 42
82
84
  value %= 100000000;
83
-
85
+
84
86
  if (a >= 10) {
85
87
  const unsigned i = a << 1;
86
88
  *buffer++ = cDigitsLut[i];
@@ -91,13 +93,13 @@ inline char* u32toa(uint32_t value, char* buffer) {
91
93
 
92
94
  const uint32_t b = value / 10000; // 0 to 9999
93
95
  const uint32_t c = value % 10000; // 0 to 9999
94
-
96
+
95
97
  const uint32_t d1 = (b / 100) << 1;
96
98
  const uint32_t d2 = (b % 100) << 1;
97
-
99
+
98
100
  const uint32_t d3 = (c / 100) << 1;
99
101
  const uint32_t d4 = (c % 100) << 1;
100
-
102
+
101
103
  *buffer++ = cDigitsLut[d1];
102
104
  *buffer++ = cDigitsLut[d1 + 1];
103
105
  *buffer++ = cDigitsLut[d2];
@@ -111,6 +113,7 @@ inline char* u32toa(uint32_t value, char* buffer) {
111
113
  }
112
114
 
113
115
  inline char* i32toa(int32_t value, char* buffer) {
116
+ RAPIDJSON_ASSERT(buffer != 0);
114
117
  uint32_t u = static_cast<uint32_t>(value);
115
118
  if (value < 0) {
116
119
  *buffer++ = '-';
@@ -121,6 +124,7 @@ inline char* i32toa(int32_t value, char* buffer) {
121
124
  }
122
125
 
123
126
  inline char* u64toa(uint64_t value, char* buffer) {
127
+ RAPIDJSON_ASSERT(buffer != 0);
124
128
  const char* cDigitsLut = GetDigitsLut();
125
129
  const uint64_t kTen8 = 100000000;
126
130
  const uint64_t kTen9 = kTen8 * 10;
@@ -131,13 +135,13 @@ inline char* u64toa(uint64_t value, char* buffer) {
131
135
  const uint64_t kTen14 = kTen8 * 1000000;
132
136
  const uint64_t kTen15 = kTen8 * 10000000;
133
137
  const uint64_t kTen16 = kTen8 * kTen8;
134
-
138
+
135
139
  if (value < kTen8) {
136
140
  uint32_t v = static_cast<uint32_t>(value);
137
141
  if (v < 10000) {
138
142
  const uint32_t d1 = (v / 100) << 1;
139
143
  const uint32_t d2 = (v % 100) << 1;
140
-
144
+
141
145
  if (v >= 1000)
142
146
  *buffer++ = cDigitsLut[d1];
143
147
  if (v >= 100)
@@ -150,13 +154,13 @@ inline char* u64toa(uint64_t value, char* buffer) {
150
154
  // value = bbbbcccc
151
155
  const uint32_t b = v / 10000;
152
156
  const uint32_t c = v % 10000;
153
-
157
+
154
158
  const uint32_t d1 = (b / 100) << 1;
155
159
  const uint32_t d2 = (b % 100) << 1;
156
-
160
+
157
161
  const uint32_t d3 = (c / 100) << 1;
158
162
  const uint32_t d4 = (c % 100) << 1;
159
-
163
+
160
164
  if (value >= 10000000)
161
165
  *buffer++ = cDigitsLut[d1];
162
166
  if (value >= 1000000)
@@ -164,7 +168,7 @@ inline char* u64toa(uint64_t value, char* buffer) {
164
168
  if (value >= 100000)
165
169
  *buffer++ = cDigitsLut[d2];
166
170
  *buffer++ = cDigitsLut[d2 + 1];
167
-
171
+
168
172
  *buffer++ = cDigitsLut[d3];
169
173
  *buffer++ = cDigitsLut[d3 + 1];
170
174
  *buffer++ = cDigitsLut[d4];
@@ -174,22 +178,22 @@ inline char* u64toa(uint64_t value, char* buffer) {
174
178
  else if (value < kTen16) {
175
179
  const uint32_t v0 = static_cast<uint32_t>(value / kTen8);
176
180
  const uint32_t v1 = static_cast<uint32_t>(value % kTen8);
177
-
181
+
178
182
  const uint32_t b0 = v0 / 10000;
179
183
  const uint32_t c0 = v0 % 10000;
180
-
184
+
181
185
  const uint32_t d1 = (b0 / 100) << 1;
182
186
  const uint32_t d2 = (b0 % 100) << 1;
183
-
187
+
184
188
  const uint32_t d3 = (c0 / 100) << 1;
185
189
  const uint32_t d4 = (c0 % 100) << 1;
186
190
 
187
191
  const uint32_t b1 = v1 / 10000;
188
192
  const uint32_t c1 = v1 % 10000;
189
-
193
+
190
194
  const uint32_t d5 = (b1 / 100) << 1;
191
195
  const uint32_t d6 = (b1 % 100) << 1;
192
-
196
+
193
197
  const uint32_t d7 = (c1 / 100) << 1;
194
198
  const uint32_t d8 = (c1 % 100) << 1;
195
199
 
@@ -209,7 +213,7 @@ inline char* u64toa(uint64_t value, char* buffer) {
209
213
  *buffer++ = cDigitsLut[d4];
210
214
  if (value >= kTen8)
211
215
  *buffer++ = cDigitsLut[d4 + 1];
212
-
216
+
213
217
  *buffer++ = cDigitsLut[d5];
214
218
  *buffer++ = cDigitsLut[d5 + 1];
215
219
  *buffer++ = cDigitsLut[d6];
@@ -222,7 +226,7 @@ inline char* u64toa(uint64_t value, char* buffer) {
222
226
  else {
223
227
  const uint32_t a = static_cast<uint32_t>(value / kTen16); // 1 to 1844
224
228
  value %= kTen16;
225
-
229
+
226
230
  if (a < 10)
227
231
  *buffer++ = static_cast<char>('0' + static_cast<char>(a));
228
232
  else if (a < 100) {
@@ -232,7 +236,7 @@ inline char* u64toa(uint64_t value, char* buffer) {
232
236
  }
233
237
  else if (a < 1000) {
234
238
  *buffer++ = static_cast<char>('0' + static_cast<char>(a / 100));
235
-
239
+
236
240
  const uint32_t i = (a % 100) << 1;
237
241
  *buffer++ = cDigitsLut[i];
238
242
  *buffer++ = cDigitsLut[i + 1];
@@ -245,28 +249,28 @@ inline char* u64toa(uint64_t value, char* buffer) {
245
249
  *buffer++ = cDigitsLut[j];
246
250
  *buffer++ = cDigitsLut[j + 1];
247
251
  }
248
-
252
+
249
253
  const uint32_t v0 = static_cast<uint32_t>(value / kTen8);
250
254
  const uint32_t v1 = static_cast<uint32_t>(value % kTen8);
251
-
255
+
252
256
  const uint32_t b0 = v0 / 10000;
253
257
  const uint32_t c0 = v0 % 10000;
254
-
258
+
255
259
  const uint32_t d1 = (b0 / 100) << 1;
256
260
  const uint32_t d2 = (b0 % 100) << 1;
257
-
261
+
258
262
  const uint32_t d3 = (c0 / 100) << 1;
259
263
  const uint32_t d4 = (c0 % 100) << 1;
260
-
264
+
261
265
  const uint32_t b1 = v1 / 10000;
262
266
  const uint32_t c1 = v1 % 10000;
263
-
267
+
264
268
  const uint32_t d5 = (b1 / 100) << 1;
265
269
  const uint32_t d6 = (b1 % 100) << 1;
266
-
270
+
267
271
  const uint32_t d7 = (c1 / 100) << 1;
268
272
  const uint32_t d8 = (c1 % 100) << 1;
269
-
273
+
270
274
  *buffer++ = cDigitsLut[d1];
271
275
  *buffer++ = cDigitsLut[d1 + 1];
272
276
  *buffer++ = cDigitsLut[d2];
@@ -284,11 +288,12 @@ inline char* u64toa(uint64_t value, char* buffer) {
284
288
  *buffer++ = cDigitsLut[d8];
285
289
  *buffer++ = cDigitsLut[d8 + 1];
286
290
  }
287
-
291
+
288
292
  return buffer;
289
293
  }
290
294
 
291
295
  inline char* i64toa(int64_t value, char* buffer) {
296
+ RAPIDJSON_ASSERT(buffer != 0);
292
297
  uint64_t u = static_cast<uint64_t>(value);
293
298
  if (value < 0) {
294
299
  *buffer++ = '-';
@@ -39,7 +39,7 @@ enum PrettyFormatOptions {
39
39
 
40
40
  //! Writer with indentation and spacing.
41
41
  /*!
42
- \tparam OutputStream Type of ouptut os.
42
+ \tparam OutputStream Type of output os.
43
43
  \tparam SourceEncoding Encoding of source string.
44
44
  \tparam TargetEncoding Encoding of output stream.
45
45
  \tparam StackAllocator Type of allocator for allocating memory of stack.
@@ -26,7 +26,7 @@
26
26
 
27
27
  Some RapidJSON features are configurable to adapt the library to a wide
28
28
  variety of platforms, environments and usage scenarios. Most of the
29
- features can be configured in terms of overriden or predefined
29
+ features can be configured in terms of overridden or predefined
30
30
  preprocessor macros at compile-time.
31
31
 
32
32
  Some additional customization is available in the \ref RAPIDJSON_ERRORS APIs.
@@ -219,7 +219,7 @@
219
219
  # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
220
220
  # define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN
221
221
  # else
222
- # error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN.
222
+ # error Unknown machine endianness detected. User needs to define RAPIDJSON_ENDIAN.
223
223
  # endif // __BYTE_ORDER__
224
224
  // Detect with GLIBC's endian.h
225
225
  # elif defined(__GLIBC__)
@@ -229,7 +229,7 @@
229
229
  # elif (__BYTE_ORDER == __BIG_ENDIAN)
230
230
  # define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN
231
231
  # else
232
- # error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN.
232
+ # error Unknown machine endianness detected. User needs to define RAPIDJSON_ENDIAN.
233
233
  # endif // __GLIBC__
234
234
  // Detect with _LITTLE_ENDIAN and _BIG_ENDIAN macro
235
235
  # elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
@@ -246,7 +246,7 @@
246
246
  # elif defined(RAPIDJSON_DOXYGEN_RUNNING)
247
247
  # define RAPIDJSON_ENDIAN
248
248
  # else
249
- # error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN.
249
+ # error Unknown machine endianness detected. User needs to define RAPIDJSON_ENDIAN.
250
250
  # endif
251
251
  #endif // RAPIDJSON_ENDIAN
252
252
 
@@ -678,7 +678,7 @@ public:
678
678
  return IsIterativeParsingCompleteState(state_);
679
679
  }
680
680
 
681
- //! Whether a parse error has occured in the last parsing.
681
+ //! Whether a parse error has occurred in the last parsing.
682
682
  bool HasParseError() const { return parseResult_.IsError(); }
683
683
 
684
684
  //! Get the \ref ParseErrorCode of last parsing.
@@ -901,7 +901,7 @@ private:
901
901
  return false;
902
902
  }
903
903
 
904
- // Helper function to parse four hexidecimal digits in \uXXXX in ParseString().
904
+ // Helper function to parse four hexadecimal digits in \uXXXX in ParseString().
905
905
  template<typename InputStream>
906
906
  unsigned ParseHex4(InputStream& is, size_t escapeOffset) {
907
907
  unsigned codepoint = 0;
@@ -1008,7 +1008,7 @@ private:
1008
1008
 
1009
1009
  Ch c = is.Peek();
1010
1010
  if (RAPIDJSON_UNLIKELY(c == '\\')) { // Escape
1011
- size_t escapeOffset = is.Tell(); // For invalid escaping, report the inital '\\' as error offset
1011
+ size_t escapeOffset = is.Tell(); // For invalid escaping, report the initial '\\' as error offset
1012
1012
  is.Take();
1013
1013
  Ch e = is.Peek();
1014
1014
  if ((sizeof(Ch) == 1 || unsigned(e) < 256) && RAPIDJSON_LIKELY(escape[static_cast<unsigned char>(e)])) {
@@ -1673,6 +1673,7 @@ private:
1673
1673
  if (const SchemaType* sc = remoteDocument->GetSchema(pointer)) {
1674
1674
  if (schema)
1675
1675
  *schema = sc;
1676
+ new (schemaMap_.template Push<SchemaEntry>()) SchemaEntry(source, const_cast<SchemaType*>(sc), false, allocator_);
1676
1677
  return true;
1677
1678
  }
1678
1679
  }
@@ -1860,7 +1861,12 @@ public:
1860
1861
 
1861
1862
  //! Gets the JSON pointer pointed to the invalid value.
1862
1863
  PointerType GetInvalidDocumentPointer() const {
1863
- return documentStack_.Empty() ? PointerType() : PointerType(documentStack_.template Bottom<Ch>(), documentStack_.GetSize() / sizeof(Ch));
1864
+ if (documentStack_.Empty()) {
1865
+ return PointerType();
1866
+ }
1867
+ else {
1868
+ return PointerType(documentStack_.template Bottom<Ch>(), documentStack_.GetSize() / sizeof(Ch));
1869
+ }
1864
1870
  }
1865
1871
 
1866
1872
  void NotMultipleOf(int64_t actual, const SValue& expected) {
@@ -48,7 +48,7 @@ Changed
48
48
 
49
49
  dependencies {
50
50
  packages : {
51
- //TODO: Add dependecies here in [pkg.name]/[version] form per newline
51
+ //TODO: Add dependencies here in [pkg.name]/[version] form per newline
52
52
  //zlib/[1.2.8],
53
53
  };
54
54
  }
@@ -432,7 +432,7 @@ bool Writer1<rapidjson::StringBuffer>::WriteUint(unsigned u) {
432
432
  return true;
433
433
  }
434
434
 
435
- // Using digits LUT to reduce divsion/modulo
435
+ // Using digits LUT to reduce division/modulo
436
436
  template<typename OutputStream>
437
437
  class Writer2 {
438
438
  public:
@@ -616,7 +616,7 @@ inline bool Writer3<rapidjson::InsituStringStream>::WriteUint64(uint64_t u) {
616
616
  return true;
617
617
  }
618
618
 
619
- // Using digits LUT to reduce divsion/modulo, two passes
619
+ // Using digits LUT to reduce division/modulo, two passes
620
620
  template<typename OutputStream>
621
621
  class Writer4 {
622
622
  public:
@@ -2004,6 +2004,35 @@ TEST(SchemaValidator, Ref_remote) {
2004
2004
  SchemaValidatorType, PointerType);
2005
2005
  }
2006
2006
 
2007
+ TEST(SchemaValidator, Ref_remote_issue1210) {
2008
+ class SchemaDocumentProvider : public IRemoteSchemaDocumentProvider {
2009
+ SchemaDocument** collection;
2010
+ public:
2011
+ SchemaDocumentProvider(SchemaDocument** collection) : collection(collection) { }
2012
+ virtual const SchemaDocument* GetRemoteDocument(const char* uri, SizeType length) {
2013
+ int i = 0;
2014
+ while (collection[i] && SchemaDocument::URIType(uri, length) != collection[i]->GetURI()) ++i;
2015
+ return collection[i];
2016
+ }
2017
+ };
2018
+ SchemaDocument* collection[] = { 0, 0, 0 };
2019
+ SchemaDocumentProvider provider(collection);
2020
+
2021
+ Document x, y, z;
2022
+ x.Parse("{\"properties\":{\"country\":{\"$ref\":\"y.json#/definitions/country_remote\"}},\"type\":\"object\"}");
2023
+ y.Parse("{\"definitions\":{\"country_remote\":{\"$ref\":\"z.json#/definitions/country_list\"}}}");
2024
+ z.Parse("{\"definitions\":{\"country_list\":{\"enum\":[\"US\"]}}}");
2025
+
2026
+ SchemaDocument sz(z, "z.json", 6, &provider);
2027
+ collection[0] = &sz;
2028
+ SchemaDocument sy(y, "y.json", 6, &provider);
2029
+ collection[1] = &sy;
2030
+ SchemaDocument sx(x, "x.json", 6, &provider);
2031
+
2032
+ VALIDATE(sx, "{\"country\":\"UK\"}", false);
2033
+ VALIDATE(sx, "{\"country\":\"US\"}", true);
2034
+ }
2035
+
2007
2036
  #ifdef __clang__
2008
2037
  RAPIDJSON_DIAG_POP
2009
2038
  #endif
@@ -439,6 +439,17 @@ TEST(Value, Int) {
439
439
  EXPECT_EQ(5678, z.Get<int>());
440
440
  EXPECT_EQ(5679, z.Set(5679).Get<int>());
441
441
  EXPECT_EQ(5680, z.Set<int>(5680).Get<int>());
442
+
443
+ #ifdef _MSC_VER
444
+ // long as int on MSC platforms
445
+ RAPIDJSON_STATIC_ASSERT(sizeof(long) == sizeof(int));
446
+ z.SetInt(2222);
447
+ EXPECT_TRUE(z.Is<long>());
448
+ EXPECT_EQ(2222l, z.Get<long>());
449
+ EXPECT_EQ(3333l, z.Set(3333l).Get<long>());
450
+ EXPECT_EQ(4444l, z.Set<long>(4444l).Get<long>());
451
+ EXPECT_TRUE(z.IsInt());
452
+ #endif
442
453
  }
443
454
 
444
455
  TEST(Value, Uint) {
@@ -485,6 +496,17 @@ TEST(Value, Uint) {
485
496
  EXPECT_EQ(2147483648u, z.Get<unsigned>());
486
497
  EXPECT_EQ(2147483649u, z.Set(2147483649u).Get<unsigned>());
487
498
  EXPECT_EQ(2147483650u, z.Set<unsigned>(2147483650u).Get<unsigned>());
499
+
500
+ #ifdef _MSC_VER
501
+ // unsigned long as unsigned on MSC platforms
502
+ RAPIDJSON_STATIC_ASSERT(sizeof(unsigned long) == sizeof(unsigned));
503
+ z.SetUint(2222);
504
+ EXPECT_TRUE(z.Is<unsigned long>());
505
+ EXPECT_EQ(2222ul, z.Get<unsigned long>());
506
+ EXPECT_EQ(3333ul, z.Set(3333ul).Get<unsigned long>());
507
+ EXPECT_EQ(4444ul, z.Set<unsigned long>(4444ul).Get<unsigned long>());
508
+ EXPECT_TRUE(x.IsUint());
509
+ #endif
488
510
  }
489
511
 
490
512
  TEST(Value, Int64) {
@@ -1,7 +1,7 @@
1
1
  require 'json'
2
2
 
3
3
  class RjSchema
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
6
6
 
7
7
  require 'rj_schema/rj_schema'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rj_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Semmler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-25 00:00:00.000000000 Z
11
+ date: 2018-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler