|
1 | | -/* |
| 1 | +/* |
2 | 2 | * (c) Проект "SimJson", Александр Орефков orefkov@gmail.com |
3 | 3 | * ver. 1.0 |
4 | 4 | * Классы для работы с JSON |
@@ -96,7 +96,7 @@ concept JsonType = std::is_integral_v<std::remove_cvref_t<T>> || |
96 | 96 | std::is_constructible_v<sstring<K>, T>; |
97 | 97 |
|
98 | 98 | template<typename T, typename K> |
99 | | -concept JsonKeyType = std::convertible_to<T, simple_str<K>> || |
| 99 | +concept JsonKeyType = std::convertible_to<T, str_src<K>> || |
100 | 100 | std::same_as<std::remove_cvref_t<T>, KeyType<K>>; |
101 | 101 |
|
102 | 102 | template<typename T, typename K> |
@@ -753,7 +753,13 @@ class JsonValueTempl : public Json { |
753 | 753 | * JsonParseResult - parsing error code, Success if successful; |
754 | 754 | * unsigned line, unsigned col - in case of an error, these are the line/column numbers where the error occurred. |
755 | 755 | */ |
756 | | - static std::tuple<json_value, JsonParseResult, unsigned, unsigned> parse(ssType jsonString); |
| 756 | + struct parse_result { |
| 757 | + json_value value; |
| 758 | + JsonParseResult err; |
| 759 | + unsigned line; |
| 760 | + unsigned col; |
| 761 | + }; |
| 762 | + static parse_result parse(ssType jsonString); |
757 | 763 | /*! |
758 | 764 | * @ru @brief Сериализовать json-значение в строку. |
759 | 765 | * @param stream - строка, в которую сохранять. |
@@ -891,23 +897,26 @@ struct StreamedJsonParser : StreamedJsonParserBase { |
891 | 897 | }; |
892 | 898 |
|
893 | 899 | template<typename K> |
894 | | -std::tuple<JsonValueTempl<K>, JsonParseResult, unsigned, unsigned> JsonValueTempl<K>::parse(ssType jsonString) { |
| 900 | +JsonValueTempl<K>::parse_result JsonValueTempl<K>::parse(ssType jsonString) { |
895 | 901 | StreamedJsonParser<K> parser; |
896 | 902 | auto res = parser.parseAll(jsonString); |
897 | 903 | return {std::move(parser.result_), res, parser.line_, parser.col_}; |
898 | 904 | } |
899 | 905 |
|
900 | | -/// @ru Алиас для JsonValue с символами u8s. |
901 | | -/// @en Alias for JsonValue with u8s characters. |
| 906 | +/// @ru Алиас для JsonValue с символами char. |
| 907 | +/// @en Alias for JsonValue with char characters. |
902 | 908 | using JsonValue = JsonValueTempl<u8s>; |
903 | | -/// @ru Алиас для JsonValue с символами uws. |
904 | | -/// @en Alias for JsonValue with uws symbols. |
| 909 | +/// @ru Алиас для JsonValue с символами char8_t. |
| 910 | +/// @en Alias for JsonValue with char8_t characters. |
| 911 | +using JsonValueB = JsonValueTempl<ubs>; |
| 912 | +/// @ru Алиас для JsonValue с символами wchar_t. |
| 913 | +/// @en Alias for JsonValue with wchar_tsymbols. |
905 | 914 | using JsonValueW = JsonValueTempl<uws>; |
906 | | -/// @ru Алиас для JsonValue с символами u16s. |
907 | | -/// @en Alias for JsonValue with u16s characters. |
| 915 | +/// @ru Алиас для JsonValue с символами char16_t. |
| 916 | +/// @en Alias for JsonValue with char16_t characters. |
908 | 917 | using JsonValueU = JsonValueTempl<u16s>; |
909 | | -/// @ru Алиас для JsonValue с символами u32s. |
910 | | -/// @en Alias for JsonValue with u32s characters. |
| 918 | +/// @ru Алиас для JsonValue с символами char32_t. |
| 919 | +/// @en Alias for JsonValue with char32_t characters. |
911 | 920 | using JsonValueUU = JsonValueTempl<u32s>; |
912 | 921 |
|
913 | 922 | /// @ru Один объект "пустышка". |
|
0 commit comments