Skip to content

Commit f070f95

Browse files
committed
Change json_type enumerator names
1 parent 9708b5d commit f070f95

20 files changed

+183
-151
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@
2525
is any string value tagged as `bigint`, `bigdec`, `float128`, or `bigfloat`
2626
(previously only `bigint`.)
2727

28+
- `basic_json` has a function `type()` that returns a `json_type` enumeration,
29+
and the names of its enumerators have been changed. `null_value`, `bool_value`,
30+
`int64_value`, `uint64_value`, `half_value`, `double_value`, `string_value`,
31+
`byte_string_value`, `array_value` and `object_value` have been changed to
32+
`null`, `boolean`, `int64`, `uint64`, `float16`, `float64`, `string`,
33+
`byte_string`, `array` and `object` respectively. It's unlikely that we have
34+
many users of `json_type`, it isn't used in any of our examples, but for
35+
backwards compatability the old names, now deprecated, have been typedefed to
36+
the new names.
37+
2838
- Enhancements
2939

3040
- Git Discussions #594: Updated reflection traits to supports `boost::optional`

doc/ref/corelib/json_type.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,26 @@
55

66
enum class json_type : uint8_t
77
{
8-
null_value,
9-
bool_value,
10-
int64_value,
11-
uint64_value,
12-
half_value,
13-
double_value,
14-
string_value,
15-
byte_string_value,
16-
array_value,
17-
object_value
8+
null, // (since 1.5.0)
9+
boolean, // (since 1.5.0)
10+
int64, // (since 1.5.0)
11+
uint64, // (since 1.5.0)
12+
float16, // (since 1.5.0)
13+
float64, // (since 1.5.0)
14+
string, // (since 1.5.0)
15+
byte_string, // (since 1.5.0)
16+
array, // (since 1.5.0)
17+
object, // (since 1.5.0)
18+
null_value = null, // (dprecated in 1.5.0)
19+
bool_value = boolean, // (dprecated in 1.5.0)
20+
int64_value = int64, // (dprecated in 1.5.0)
21+
uint64_value = uint64, // (dprecated in 1.5.0)
22+
half_value = float16, // (dprecated in 1.5.0)
23+
double_value = float64, // (dprecated in 1.5.0)
24+
string_value = string, // (dprecated in 1.5.0)
25+
byte_string_value = byte_string, // (dprecated in 1.5.0)
26+
array_value = array, // (dprecated in 1.5.0)
27+
object_value = object // (dprecated in 1.5.0)
1828
};
1929
```
2030

include/jsoncons/basic_json.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,27 +1440,27 @@ namespace jsoncons {
14401440
switch(storage_kind())
14411441
{
14421442
case json_storage_kind::null:
1443-
return json_type::null_value;
1443+
return json_type::null;
14441444
case json_storage_kind::boolean:
1445-
return json_type::bool_value;
1445+
return json_type::boolean;
14461446
case json_storage_kind::int64:
1447-
return json_type::int64_value;
1447+
return json_type::int64;
14481448
case json_storage_kind::uint64:
1449-
return json_type::uint64_value;
1449+
return json_type::uint64;
14501450
case json_storage_kind::half_float:
1451-
return json_type::half_value;
1451+
return json_type::float16;
14521452
case json_storage_kind::float64:
1453-
return json_type::double_value;
1453+
return json_type::float64;
14541454
case json_storage_kind::short_str:
14551455
case json_storage_kind::long_str:
1456-
return json_type::string_value;
1456+
return json_type::string;
14571457
case json_storage_kind::byte_str:
1458-
return json_type::byte_string_value;
1458+
return json_type::byte_string;
14591459
case json_storage_kind::array:
1460-
return json_type::array_value;
1460+
return json_type::array;
14611461
case json_storage_kind::empty_object:
14621462
case json_storage_kind::object:
1463-
return json_type::object_value;
1463+
return json_type::object;
14641464
case json_storage_kind::json_const_ref:
14651465
return cast<json_const_reference_storage>().value().type();
14661466
case json_storage_kind::json_ref:

include/jsoncons/json_type.hpp

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,80 +16,92 @@ namespace jsoncons {
1616

1717
enum class json_type : uint8_t
1818
{
19-
null_value,
20-
bool_value,
21-
int64_value,
22-
uint64_value,
23-
half_value,
24-
double_value,
25-
string_value,
26-
byte_string_value,
27-
array_value,
28-
object_value
19+
null,
20+
boolean,
21+
int64,
22+
uint64,
23+
float16,
24+
float64,
25+
string,
26+
byte_string,
27+
array,
28+
object
29+
#if !defined(JSONCONS_NO_DEPRECATED)
30+
, null_value = null,
31+
bool_value = boolean,
32+
int64_value = int64,
33+
uint64_value = uint64,
34+
half_value = float16,
35+
double_value = float64,
36+
string_value = string,
37+
byte_string_value = byte_string,
38+
array_value = array,
39+
object_value = object
40+
#endif
2941
};
3042

3143
template <typename CharT>
3244
std::basic_ostream<CharT>& operator<<(std::basic_ostream<CharT>& os, json_type type)
3345
{
3446
static constexpr const CharT* null_value = JSONCONS_CSTRING_CONSTANT(CharT, "null");
35-
static constexpr const CharT* bool_value = JSONCONS_CSTRING_CONSTANT(CharT, "bool");
47+
static constexpr const CharT* bool_value = JSONCONS_CSTRING_CONSTANT(CharT, "boolean");
3648
static constexpr const CharT* int64_value = JSONCONS_CSTRING_CONSTANT(CharT, "int64");
3749
static constexpr const CharT* uint64_value = JSONCONS_CSTRING_CONSTANT(CharT, "uint64");
38-
static constexpr const CharT* half_value = JSONCONS_CSTRING_CONSTANT(CharT, "half");
39-
static constexpr const CharT* double_value = JSONCONS_CSTRING_CONSTANT(CharT, "double");
50+
static constexpr const CharT* half_value = JSONCONS_CSTRING_CONSTANT(CharT, "float16");
51+
static constexpr const CharT* double_value = JSONCONS_CSTRING_CONSTANT(CharT, "float64");
4052
static constexpr const CharT* string_value = JSONCONS_CSTRING_CONSTANT(CharT, "string");
4153
static constexpr const CharT* byte_string_value = JSONCONS_CSTRING_CONSTANT(CharT, "byte_string");
4254
static constexpr const CharT* array_value = JSONCONS_CSTRING_CONSTANT(CharT, "array");
4355
static constexpr const CharT* object_value = JSONCONS_CSTRING_CONSTANT(CharT, "object");
4456

4557
switch (type)
4658
{
47-
case json_type::null_value:
59+
case json_type::null:
4860
{
4961
os << null_value;
5062
break;
5163
}
52-
case json_type::bool_value:
64+
case json_type::boolean:
5365
{
5466
os << bool_value;
5567
break;
5668
}
57-
case json_type::int64_value:
69+
case json_type::int64:
5870
{
5971
os << int64_value;
6072
break;
6173
}
62-
case json_type::uint64_value:
74+
case json_type::uint64:
6375
{
6476
os << uint64_value;
6577
break;
6678
}
67-
case json_type::half_value:
79+
case json_type::float16:
6880
{
6981
os << half_value;
7082
break;
7183
}
72-
case json_type::double_value:
84+
case json_type::float64:
7385
{
7486
os << double_value;
7587
break;
7688
}
77-
case json_type::string_value:
89+
case json_type::string:
7890
{
7991
os << string_value;
8092
break;
8193
}
82-
case json_type::byte_string_value:
94+
case json_type::byte_string:
8395
{
8496
os << byte_string_value;
8597
break;
8698
}
87-
case json_type::array_value:
99+
case json_type::array:
88100
{
89101
os << array_value;
90102
break;
91103
}
92-
case json_type::object_value:
104+
case json_type::object:
93105
{
94106
os << object_value;
95107
break;

include/jsoncons/reflect/json_conv_traits.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,10 +1344,10 @@ has_can_convert = ext_traits::is_detected<traits_can_convert_t, Json, T>;
13441344
{
13451345
switch (j.type())
13461346
{
1347-
case json_type::string_value:
1347+
case json_type::string:
13481348
return jsoncons::utility::is_base10(j.as_string_view().data(), j.as_string_view().length());
1349-
case json_type::int64_value:
1350-
case json_type::uint64_value:
1349+
case json_type::int64:
1350+
case json_type::uint64:
13511351
return true;
13521352
default:
13531353
return false;
@@ -1359,7 +1359,7 @@ has_can_convert = ext_traits::is_detected<traits_can_convert_t, Json, T>;
13591359
{
13601360
switch (j.type())
13611361
{
1362-
case json_type::string_value:
1362+
case json_type::string:
13631363
{
13641364
auto sv = j.as_string_view();
13651365
std::error_code ec;
@@ -1371,18 +1371,18 @@ has_can_convert = ext_traits::is_detected<traits_can_convert_t, Json, T>;
13711371
}
13721372
return result_type(std::move(val));
13731373
}
1374-
case json_type::half_value:
1375-
case json_type::double_value:
1374+
case json_type::float16:
1375+
case json_type::float64:
13761376
{
13771377
auto res = j.template try_as<int64_t>(aset);
13781378
return res ? result_type(jsoncons::in_place, *res) : result_type(jsoncons::unexpect, conv_errc::not_bigint);
13791379
}
1380-
case json_type::int64_value:
1380+
case json_type::int64:
13811381
{
13821382
auto res = j.template try_as<int64_t>(aset);
13831383
return res ? result_type(jsoncons::in_place, *res) : result_type(jsoncons::unexpect, conv_errc::not_bigint);
13841384
}
1385-
case json_type::uint64_value:
1385+
case json_type::uint64:
13861386
{
13871387
auto res = j.template try_as<uint64_t>(aset);
13881388
return res ? result_type(jsoncons::in_place, *res) : result_type(jsoncons::unexpect, conv_errc::not_bigint);

include/jsoncons/staj_cursor.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ read_result<Json> to_json_container(const allocator_set<Alloc,TempAlloc>& aset,
945945
{
946946
return result_type(std::move(cont));
947947
}
948-
if (stack.back()->type() == json_type::object_value)
948+
if (stack.back()->type() == json_type::object)
949949
{
950950
goto begin_object;
951951
}
@@ -1042,7 +1042,7 @@ read_result<Json> to_json_container(const allocator_set<Alloc,TempAlloc>& aset,
10421042
{
10431043
return cont;
10441044
}
1045-
if (stack.back()->type() == json_type::object_value)
1045+
if (stack.back()->type() == json_type::object)
10461046
{
10471047
goto begin_object;
10481048
}

0 commit comments

Comments
 (0)