| 978 | } |
| 979 | |
| 980 | JSONCONS_VISITOR_RETURN_TYPE visit_byte_string(const byte_string_view& b, |
| 981 | semantic_tag tag, |
| 982 | const ser_context&, |
| 983 | std::error_code&) override |
| 984 | { |
| 985 | byte_string_chars_format encoding_hint; |
| 986 | switch (tag) |
| 987 | { |
| 988 | case semantic_tag::base16: |
| 989 | encoding_hint = byte_string_chars_format::base16; |
| 990 | break; |
| 991 | case semantic_tag::base64: |
| 992 | encoding_hint = byte_string_chars_format::base64; |
| 993 | break; |
| 994 | case semantic_tag::base64url: |
| 995 | encoding_hint = byte_string_chars_format::base64url; |
| 996 | break; |
| 997 | default: |
| 998 | encoding_hint = byte_string_chars_format::none; |
| 999 | break; |
| 1000 | } |
| 1001 | switch (encoding_hint) |
| 1002 | { |
| 1003 | case byte_string_chars_format::base64url: |
| 1004 | write_tag(21); |
| 1005 | break; |
| 1006 | case byte_string_chars_format::base64: |
| 1007 | write_tag(22); |
| 1008 | break; |
| 1009 | case byte_string_chars_format::base16: |
| 1010 | write_tag(23); |
| 1011 | break; |
| 1012 | default: |
| 1013 | break; |
| 1014 | } |
| 1015 | if (pack_strings_ && b.size() >= jsoncons::cbor::detail::min_length_for_stringref(next_stringref_)) |
| 1016 | { |
| 1017 | byte_string_type bs(b.data(), b.size(), alloc_); |
| 1018 | auto it = bytestringref_map_.find(bs); |
| 1019 | if (it == bytestringref_map_.end()) |
| 1020 | { |
| 1021 | bytestringref_map_.emplace(std::make_pair(bs, next_stringref_++)); |
| 1022 | write_byte_string(bs); |
| 1023 | } |
| 1024 | else |
| 1025 | { |
| 1026 | write_tag(25); |
| 1027 | write_uint64_value((*it).second); |
| 1028 | } |
| 1029 | } |
| 1030 | else |
| 1031 | { |
| 1032 | write_byte_string(b); |
| 1033 | } |
| 1034 | |
| 1035 | end_value(); |
| 1036 | JSONCONS_VISITOR_RETURN; |
| 1037 | } |
nothing calls this directly
no test coverage detected