jsoncons 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +7 -0
  2. data/ext/jsoncons/extconf.rb +43 -0
  3. data/ext/jsoncons/jsoncons.cpp +161 -0
  4. data/ext/jsoncons/jsoncons.h +10 -0
  5. data/jsoncons.gemspec +44 -0
  6. data/lib/jsoncons/jsoncons/examples/input/address-book.json +13 -0
  7. data/lib/jsoncons/jsoncons/examples/input/books.json +28 -0
  8. data/lib/jsoncons/jsoncons/examples/input/countries.json +7 -0
  9. data/lib/jsoncons/jsoncons/examples/input/employees.json +30 -0
  10. data/lib/jsoncons/jsoncons/examples/input/jsonschema/name.json +15 -0
  11. data/lib/jsoncons/jsoncons/examples/input/multiple-json-objects.json +3 -0
  12. data/lib/jsoncons/jsoncons/examples/input/sales.csv +6 -0
  13. data/lib/jsoncons/jsoncons/examples/input/store.json +28 -0
  14. data/lib/jsoncons/jsoncons/examples/input/tasks.csv +6 -0
  15. data/lib/jsoncons/jsoncons/include/jsoncons/allocator_holder.hpp +38 -0
  16. data/lib/jsoncons/jsoncons/include/jsoncons/basic_json.hpp +5905 -0
  17. data/lib/jsoncons/jsoncons/include/jsoncons/bigint.hpp +1611 -0
  18. data/lib/jsoncons/jsoncons/include/jsoncons/byte_string.hpp +820 -0
  19. data/lib/jsoncons/jsoncons/include/jsoncons/config/binary_config.hpp +226 -0
  20. data/lib/jsoncons/jsoncons/include/jsoncons/config/compiler_support.hpp +375 -0
  21. data/lib/jsoncons/jsoncons/include/jsoncons/config/jsoncons_config.hpp +309 -0
  22. data/lib/jsoncons/jsoncons/include/jsoncons/config/version.hpp +40 -0
  23. data/lib/jsoncons/jsoncons/include/jsoncons/conv_error.hpp +218 -0
  24. data/lib/jsoncons/jsoncons/include/jsoncons/decode_json.hpp +209 -0
  25. data/lib/jsoncons/jsoncons/include/jsoncons/decode_traits.hpp +651 -0
  26. data/lib/jsoncons/jsoncons/include/jsoncons/detail/endian.hpp +44 -0
  27. data/lib/jsoncons/jsoncons/include/jsoncons/detail/grisu3.hpp +312 -0
  28. data/lib/jsoncons/jsoncons/include/jsoncons/detail/optional.hpp +483 -0
  29. data/lib/jsoncons/jsoncons/include/jsoncons/detail/parse_number.hpp +1133 -0
  30. data/lib/jsoncons/jsoncons/include/jsoncons/detail/span.hpp +188 -0
  31. data/lib/jsoncons/jsoncons/include/jsoncons/detail/string_view.hpp +537 -0
  32. data/lib/jsoncons/jsoncons/include/jsoncons/detail/string_wrapper.hpp +370 -0
  33. data/lib/jsoncons/jsoncons/include/jsoncons/detail/write_number.hpp +567 -0
  34. data/lib/jsoncons/jsoncons/include/jsoncons/encode_json.hpp +315 -0
  35. data/lib/jsoncons/jsoncons/include/jsoncons/encode_traits.hpp +378 -0
  36. data/lib/jsoncons/jsoncons/include/jsoncons/json.hpp +18 -0
  37. data/lib/jsoncons/jsoncons/include/jsoncons/json_array.hpp +324 -0
  38. data/lib/jsoncons/jsoncons/include/jsoncons/json_content_handler.hpp +12 -0
  39. data/lib/jsoncons/jsoncons/include/jsoncons/json_cursor.hpp +448 -0
  40. data/lib/jsoncons/jsoncons/include/jsoncons/json_decoder.hpp +420 -0
  41. data/lib/jsoncons/jsoncons/include/jsoncons/json_encoder.hpp +1587 -0
  42. data/lib/jsoncons/jsoncons/include/jsoncons/json_error.hpp +156 -0
  43. data/lib/jsoncons/jsoncons/include/jsoncons/json_exception.hpp +241 -0
  44. data/lib/jsoncons/jsoncons/include/jsoncons/json_filter.hpp +653 -0
  45. data/lib/jsoncons/jsoncons/include/jsoncons/json_fwd.hpp +23 -0
  46. data/lib/jsoncons/jsoncons/include/jsoncons/json_object.hpp +1772 -0
  47. data/lib/jsoncons/jsoncons/include/jsoncons/json_options.hpp +862 -0
  48. data/lib/jsoncons/jsoncons/include/jsoncons/json_parser.hpp +2900 -0
  49. data/lib/jsoncons/jsoncons/include/jsoncons/json_reader.hpp +731 -0
  50. data/lib/jsoncons/jsoncons/include/jsoncons/json_traits_macros.hpp +1072 -0
  51. data/lib/jsoncons/jsoncons/include/jsoncons/json_traits_macros_deprecated.hpp +144 -0
  52. data/lib/jsoncons/jsoncons/include/jsoncons/json_type.hpp +206 -0
  53. data/lib/jsoncons/jsoncons/include/jsoncons/json_type_traits.hpp +1830 -0
  54. data/lib/jsoncons/jsoncons/include/jsoncons/json_visitor.hpp +1560 -0
  55. data/lib/jsoncons/jsoncons/include/jsoncons/json_visitor2.hpp +2079 -0
  56. data/lib/jsoncons/jsoncons/include/jsoncons/pretty_print.hpp +89 -0
  57. data/lib/jsoncons/jsoncons/include/jsoncons/ser_context.hpp +62 -0
  58. data/lib/jsoncons/jsoncons/include/jsoncons/sink.hpp +289 -0
  59. data/lib/jsoncons/jsoncons/include/jsoncons/source.hpp +777 -0
  60. data/lib/jsoncons/jsoncons/include/jsoncons/source_adaptor.hpp +148 -0
  61. data/lib/jsoncons/jsoncons/include/jsoncons/staj2_cursor.hpp +1189 -0
  62. data/lib/jsoncons/jsoncons/include/jsoncons/staj_cursor.hpp +1254 -0
  63. data/lib/jsoncons/jsoncons/include/jsoncons/staj_iterator.hpp +449 -0
  64. data/lib/jsoncons/jsoncons/include/jsoncons/tag_type.hpp +245 -0
  65. data/lib/jsoncons/jsoncons/include/jsoncons/text_source_adaptor.hpp +144 -0
  66. data/lib/jsoncons/jsoncons/include/jsoncons/traits_extension.hpp +884 -0
  67. data/lib/jsoncons/jsoncons/include/jsoncons/typed_array_view.hpp +250 -0
  68. data/lib/jsoncons/jsoncons/include/jsoncons/unicode_traits.hpp +1330 -0
  69. data/lib/jsoncons/jsoncons/include/jsoncons/uri.hpp +635 -0
  70. data/lib/jsoncons/jsoncons/include/jsoncons/value_converter.hpp +340 -0
  71. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson.hpp +23 -0
  72. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_cursor.hpp +320 -0
  73. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_decimal128.hpp +865 -0
  74. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_encoder.hpp +585 -0
  75. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_error.hpp +103 -0
  76. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_oid.hpp +245 -0
  77. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_options.hpp +75 -0
  78. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_parser.hpp +645 -0
  79. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_reader.hpp +92 -0
  80. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_type.hpp +44 -0
  81. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/decode_bson.hpp +201 -0
  82. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/encode_bson.hpp +144 -0
  83. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor.hpp +26 -0
  84. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_cursor.hpp +351 -0
  85. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_cursor2.hpp +265 -0
  86. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_detail.hpp +93 -0
  87. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_encoder.hpp +1766 -0
  88. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_error.hpp +105 -0
  89. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_options.hpp +113 -0
  90. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_parser.hpp +1942 -0
  91. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_reader.hpp +116 -0
  92. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/decode_cbor.hpp +203 -0
  93. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/encode_cbor.hpp +151 -0
  94. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv.hpp +17 -0
  95. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_cursor.hpp +358 -0
  96. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_encoder.hpp +954 -0
  97. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_error.hpp +85 -0
  98. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_options.hpp +973 -0
  99. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_parser.hpp +2099 -0
  100. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_reader.hpp +348 -0
  101. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_serializer.hpp +12 -0
  102. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/decode_csv.hpp +208 -0
  103. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/encode_csv.hpp +122 -0
  104. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jmespath/jmespath.hpp +5215 -0
  105. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jmespath/jmespath_error.hpp +215 -0
  106. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpatch/jsonpatch.hpp +579 -0
  107. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpatch/jsonpatch_error.hpp +121 -0
  108. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/expression.hpp +3329 -0
  109. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/flatten.hpp +432 -0
  110. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/json_location.hpp +445 -0
  111. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/json_query.hpp +115 -0
  112. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath.hpp +13 -0
  113. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath_error.hpp +240 -0
  114. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath_expression.hpp +2612 -0
  115. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath_selector.hpp +1322 -0
  116. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpointer/jsonpointer.hpp +1577 -0
  117. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpointer/jsonpointer_error.hpp +119 -0
  118. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/format_validator.hpp +968 -0
  119. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/json_validator.hpp +120 -0
  120. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/jsonschema.hpp +13 -0
  121. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/jsonschema_error.hpp +105 -0
  122. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/jsonschema_version.hpp +18 -0
  123. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/keyword_validator.hpp +1745 -0
  124. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/keyword_validator_factory.hpp +556 -0
  125. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/schema_draft7.hpp +198 -0
  126. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/schema_location.hpp +200 -0
  127. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/schema_version.hpp +35 -0
  128. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/subschema.hpp +144 -0
  129. data/lib/jsoncons/jsoncons/include/jsoncons_ext/mergepatch/mergepatch.hpp +103 -0
  130. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/decode_msgpack.hpp +202 -0
  131. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/encode_msgpack.hpp +142 -0
  132. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack.hpp +24 -0
  133. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_cursor.hpp +343 -0
  134. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_cursor2.hpp +259 -0
  135. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_encoder.hpp +753 -0
  136. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_error.hpp +94 -0
  137. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_options.hpp +74 -0
  138. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_parser.hpp +748 -0
  139. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_reader.hpp +116 -0
  140. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_type.hpp +63 -0
  141. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/decode_ubjson.hpp +201 -0
  142. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/encode_ubjson.hpp +142 -0
  143. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson.hpp +23 -0
  144. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_cursor.hpp +307 -0
  145. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_encoder.hpp +502 -0
  146. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_error.hpp +100 -0
  147. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_options.hpp +87 -0
  148. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_parser.hpp +880 -0
  149. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_reader.hpp +92 -0
  150. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_type.hpp +43 -0
  151. data/lib/jsoncons/version.rb +5 -0
  152. data/lib/jsoncons.rb +33 -0
  153. data/test/jsoncons_test.rb +108 -0
  154. data/test/test_helper.rb +7 -0
  155. metadata +268 -0
@@ -0,0 +1,245 @@
1
+ #ifndef JSONCONS_BSON_BSON_OID_HPP
2
+ #define JSONCONS_BSON_BSON_OID_HPP
3
+
4
+ /*
5
+ * Implements class oid_t and non member function bson_oid_to_string
6
+ *
7
+ * Based on the libjson functions bson_oid_to_string
8
+ * and bson_oid_init_from_string_unsafe , available at
9
+ * https://github.com/mongodb/mongo-c-driver/blob/master/src/libbson/src/bson/bson-oid.h
10
+ * and https://github.com/mongodb/mongo-c-driver/blob/master/src/libbson/src/bson/bson-oid.c
11
+ *
12
+ */
13
+
14
+ /*
15
+ * Copyright 2015 MongoDB, Inc.
16
+ *
17
+ * Licensed under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing, software
24
+ * distributed under the License is distributed on an "AS IS" BASIS,
25
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
+ * See the License for the specific language governing permissions and
27
+ * limitations under the License.
28
+ */
29
+
30
+ #include <cstdlib>
31
+ #include <cstring>
32
+ #include <ctype.h>
33
+ #include <system_error>
34
+ #include <algorithm>
35
+ #include <string>
36
+ #include <type_traits>
37
+ #include <array>
38
+ #include <jsoncons/config/jsoncons_config.hpp>
39
+
40
+ namespace jsoncons { namespace bson {
41
+
42
+ class oid_t
43
+ {
44
+ std::array<uint8_t,12> bytes_;
45
+ public:
46
+ using iterator = std::array<uint8_t,12>::iterator;
47
+ using const_iterator = std::array<uint8_t,12>::const_iterator;
48
+
49
+ oid_t(const std::array<uint8_t,12>& bytes)
50
+ : bytes_(bytes)
51
+ {
52
+ }
53
+ oid_t(uint8_t data[12])
54
+ {
55
+ std::memcpy(bytes_.data(),data,12);
56
+ }
57
+
58
+ oid_t(const string_view& str)
59
+ {
60
+ for (std::size_t i = 0; i < bytes_.size(); i++)
61
+ {
62
+ bytes_[i] = ((parse_hex_char (str[2 * i]) << 4) |
63
+ (parse_hex_char (str[2 * i + 1])));
64
+ }
65
+ }
66
+
67
+ const uint8_t* data() const
68
+ {
69
+ return bytes_.data();
70
+ }
71
+
72
+ std::size_t size() const
73
+ {
74
+ return bytes_.size();
75
+ }
76
+
77
+ iterator begin()
78
+ {
79
+ return bytes_.begin();
80
+ }
81
+
82
+ iterator end()
83
+ {
84
+ return bytes_.end();
85
+ }
86
+
87
+ const_iterator begin() const
88
+ {
89
+ return bytes_.begin();
90
+ }
91
+
92
+ const_iterator end() const
93
+ {
94
+ return bytes_.end();
95
+ }
96
+
97
+ private:
98
+
99
+ static uint8_t parse_hex_char (char hex)
100
+ {
101
+ switch (hex) {
102
+ case '0':
103
+ return 0;
104
+ case '1':
105
+ return 1;
106
+ case '2':
107
+ return 2;
108
+ case '3':
109
+ return 3;
110
+ case '4':
111
+ return 4;
112
+ case '5':
113
+ return 5;
114
+ case '6':
115
+ return 6;
116
+ case '7':
117
+ return 7;
118
+ case '8':
119
+ return 8;
120
+ case '9':
121
+ return 9;
122
+ case 'a':
123
+ case 'A':
124
+ return 0xa;
125
+ case 'b':
126
+ case 'B':
127
+ return 0xb;
128
+ case 'c':
129
+ case 'C':
130
+ return 0xc;
131
+ case 'd':
132
+ case 'D':
133
+ return 0xd;
134
+ case 'e':
135
+ case 'E':
136
+ return 0xe;
137
+ case 'f':
138
+ case 'F':
139
+ return 0xf;
140
+ default:
141
+ return 0;
142
+ }
143
+ }
144
+ };
145
+
146
+ namespace detail {
147
+
148
+ inline
149
+ const uint16_t* get_hex_char_pairs(std::true_type) // big endian
150
+ {
151
+ static const uint16_t hex_char_pairs[] = {
152
+ 12336, 12337, 12338, 12339, 12340, 12341, 12342, 12343, 12344, 12345, 12385,
153
+ 12386, 12387, 12388, 12389, 12390, 12592, 12593, 12594, 12595, 12596, 12597,
154
+ 12598, 12599, 12600, 12601, 12641, 12642, 12643, 12644, 12645, 12646, 12848,
155
+ 12849, 12850, 12851, 12852, 12853, 12854, 12855, 12856, 12857, 12897, 12898,
156
+ 12899, 12900, 12901, 12902, 13104, 13105, 13106, 13107, 13108, 13109, 13110,
157
+ 13111, 13112, 13113, 13153, 13154, 13155, 13156, 13157, 13158, 13360, 13361,
158
+ 13362, 13363, 13364, 13365, 13366, 13367, 13368, 13369, 13409, 13410, 13411,
159
+ 13412, 13413, 13414, 13616, 13617, 13618, 13619, 13620, 13621, 13622, 13623,
160
+ 13624, 13625, 13665, 13666, 13667, 13668, 13669, 13670, 13872, 13873, 13874,
161
+ 13875, 13876, 13877, 13878, 13879, 13880, 13881, 13921, 13922, 13923, 13924,
162
+ 13925, 13926, 14128, 14129, 14130, 14131, 14132, 14133, 14134, 14135, 14136,
163
+ 14137, 14177, 14178, 14179, 14180, 14181, 14182, 14384, 14385, 14386, 14387,
164
+ 14388, 14389, 14390, 14391, 14392, 14393, 14433, 14434, 14435, 14436, 14437,
165
+ 14438, 14640, 14641, 14642, 14643, 14644, 14645, 14646, 14647, 14648, 14649,
166
+ 14689, 14690, 14691, 14692, 14693, 14694, 24880, 24881, 24882, 24883, 24884,
167
+ 24885, 24886, 24887, 24888, 24889, 24929, 24930, 24931, 24932, 24933, 24934,
168
+ 25136, 25137, 25138, 25139, 25140, 25141, 25142, 25143, 25144, 25145, 25185,
169
+ 25186, 25187, 25188, 25189, 25190, 25392, 25393, 25394, 25395, 25396, 25397,
170
+ 25398, 25399, 25400, 25401, 25441, 25442, 25443, 25444, 25445, 25446, 25648,
171
+ 25649, 25650, 25651, 25652, 25653, 25654, 25655, 25656, 25657, 25697, 25698,
172
+ 25699, 25700, 25701, 25702, 25904, 25905, 25906, 25907, 25908, 25909, 25910,
173
+ 25911, 25912, 25913, 25953, 25954, 25955, 25956, 25957, 25958, 26160, 26161,
174
+ 26162, 26163, 26164, 26165, 26166, 26167, 26168, 26169, 26209, 26210, 26211,
175
+ 26212, 26213, 26214};
176
+
177
+ return hex_char_pairs;
178
+ }
179
+
180
+ inline
181
+ const uint16_t* get_hex_char_pairs(std::false_type) // little endian
182
+ {
183
+ static const uint16_t hex_char_pairs[] = {
184
+ 12336, 12592, 12848, 13104, 13360, 13616, 13872, 14128, 14384, 14640, 24880,
185
+ 25136, 25392, 25648, 25904, 26160, 12337, 12593, 12849, 13105, 13361, 13617,
186
+ 13873, 14129, 14385, 14641, 24881, 25137, 25393, 25649, 25905, 26161, 12338,
187
+ 12594, 12850, 13106, 13362, 13618, 13874, 14130, 14386, 14642, 24882, 25138,
188
+ 25394, 25650, 25906, 26162, 12339, 12595, 12851, 13107, 13363, 13619, 13875,
189
+ 14131, 14387, 14643, 24883, 25139, 25395, 25651, 25907, 26163, 12340, 12596,
190
+ 12852, 13108, 13364, 13620, 13876, 14132, 14388, 14644, 24884, 25140, 25396,
191
+ 25652, 25908, 26164, 12341, 12597, 12853, 13109, 13365, 13621, 13877, 14133,
192
+ 14389, 14645, 24885, 25141, 25397, 25653, 25909, 26165, 12342, 12598, 12854,
193
+ 13110, 13366, 13622, 13878, 14134, 14390, 14646, 24886, 25142, 25398, 25654,
194
+ 25910, 26166, 12343, 12599, 12855, 13111, 13367, 13623, 13879, 14135, 14391,
195
+ 14647, 24887, 25143, 25399, 25655, 25911, 26167, 12344, 12600, 12856, 13112,
196
+ 13368, 13624, 13880, 14136, 14392, 14648, 24888, 25144, 25400, 25656, 25912,
197
+ 26168, 12345, 12601, 12857, 13113, 13369, 13625, 13881, 14137, 14393, 14649,
198
+ 24889, 25145, 25401, 25657, 25913, 26169, 12385, 12641, 12897, 13153, 13409,
199
+ 13665, 13921, 14177, 14433, 14689, 24929, 25185, 25441, 25697, 25953, 26209,
200
+ 12386, 12642, 12898, 13154, 13410, 13666, 13922, 14178, 14434, 14690, 24930,
201
+ 25186, 25442, 25698, 25954, 26210, 12387, 12643, 12899, 13155, 13411, 13667,
202
+ 13923, 14179, 14435, 14691, 24931, 25187, 25443, 25699, 25955, 26211, 12388,
203
+ 12644, 12900, 13156, 13412, 13668, 13924, 14180, 14436, 14692, 24932, 25188,
204
+ 25444, 25700, 25956, 26212, 12389, 12645, 12901, 13157, 13413, 13669, 13925,
205
+ 14181, 14437, 14693, 24933, 25189, 25445, 25701, 25957, 26213, 12390, 12646,
206
+ 12902, 13158, 13414, 13670, 13926, 14182, 14438, 14694, 24934, 25190, 25446,
207
+ 25702, 25958, 26214};
208
+
209
+ return hex_char_pairs;
210
+ }
211
+
212
+ inline
213
+ void init_hex_char_pairs(const oid_t& oid, uint16_t* data)
214
+ {
215
+ const uint8_t* bytes = oid.data();
216
+ const uint16_t* gHexCharPairs = get_hex_char_pairs(std::integral_constant<bool, jsoncons::endian::native == jsoncons::endian::big>());
217
+
218
+ data[0] = gHexCharPairs[bytes[0]];
219
+ data[1] = gHexCharPairs[bytes[1]];
220
+ data[2] = gHexCharPairs[bytes[2]];
221
+ data[3] = gHexCharPairs[bytes[3]];
222
+ data[4] = gHexCharPairs[bytes[4]];
223
+ data[5] = gHexCharPairs[bytes[5]];
224
+ data[6] = gHexCharPairs[bytes[6]];
225
+ data[7] = gHexCharPairs[bytes[7]];
226
+ data[8] = gHexCharPairs[bytes[8]];
227
+ data[9] = gHexCharPairs[bytes[9]];
228
+ data[10] = gHexCharPairs[bytes[10]];
229
+ data[11] = gHexCharPairs[bytes[11]];
230
+ }
231
+
232
+ } // namsepace detail
233
+
234
+ template <typename StringT>
235
+ inline
236
+ void to_string(const oid_t& oid, StringT& s)
237
+ {
238
+ s.resize(24);
239
+ detail::init_hex_char_pairs(oid, reinterpret_cast<uint16_t*>(&s[0]));
240
+ }
241
+
242
+ } // namespace bson
243
+ } // namespace jsoncons
244
+
245
+ #endif
@@ -0,0 +1,75 @@
1
+ // Copyright 2019 Daniel Parker
2
+ // Distributed under the Boost license, Version 1.0.
3
+ // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
+
5
+ // See https://github.com/danielaparker/jsoncons for latest version
6
+
7
+ #ifndef JSONCONS_BSON_BSON_OPTIONS_HPP
8
+ #define JSONCONS_BSON_BSON_OPTIONS_HPP
9
+
10
+ #include <string>
11
+ #include <limits> // std::numeric_limits
12
+ #include <cwchar>
13
+ #include <jsoncons/json_exception.hpp>
14
+ #include <jsoncons_ext/bson/bson_type.hpp>
15
+
16
+ namespace jsoncons { namespace bson {
17
+
18
+ class bson_options;
19
+
20
+ class bson_options_common
21
+ {
22
+ friend class bson_options;
23
+
24
+ int max_nesting_depth_;
25
+ protected:
26
+ virtual ~bson_options_common() = default;
27
+
28
+ bson_options_common()
29
+ : max_nesting_depth_(1024)
30
+ {
31
+ }
32
+
33
+ bson_options_common(const bson_options_common&) = default;
34
+ bson_options_common& operator=(const bson_options_common&) = default;
35
+ bson_options_common(bson_options_common&&) = default;
36
+ bson_options_common& operator=(bson_options_common&&) = default;
37
+ public:
38
+ int max_nesting_depth() const
39
+ {
40
+ return max_nesting_depth_;
41
+ }
42
+ };
43
+
44
+ class bson_decode_options : public virtual bson_options_common
45
+ {
46
+ friend class bson_options;
47
+ public:
48
+ bson_decode_options()
49
+ {
50
+ }
51
+ };
52
+
53
+ class bson_encode_options : public virtual bson_options_common
54
+ {
55
+ friend class bson_options;
56
+ public:
57
+ bson_encode_options()
58
+ {
59
+ }
60
+ };
61
+
62
+ class bson_options final : public bson_decode_options, public bson_encode_options
63
+ {
64
+ public:
65
+ using bson_options_common::max_nesting_depth;
66
+
67
+ bson_options& max_nesting_depth(int value)
68
+ {
69
+ this->max_nesting_depth_ = value;
70
+ return *this;
71
+ }
72
+ };
73
+
74
+ }}
75
+ #endif