MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / get_cbor_string

Method get_cbor_string

native/thirdpart/json/json.hpp:5839–5921  ·  view source on GitHub ↗

! @brief reads a CBOR string This function first reads starting bytes to determine the expected string length and then copies this number of bytes into a string. Additionally, CBOR's strings with indefinite lengths are supported. @param[out] result created string @return whether string creation completed */

Source from the content-addressed store, hash-verified

5837 @return whether string creation completed
5838 */
5839 bool get_cbor_string(string_t& result)
5840 {
5841 if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string")))
5842 {
5843 return false;
5844 }
5845
5846 switch (current)
5847 {
5848 // UTF-8 string (0x00..0x17 bytes follow)
5849 case 0x60:
5850 case 0x61:
5851 case 0x62:
5852 case 0x63:
5853 case 0x64:
5854 case 0x65:
5855 case 0x66:
5856 case 0x67:
5857 case 0x68:
5858 case 0x69:
5859 case 0x6A:
5860 case 0x6B:
5861 case 0x6C:
5862 case 0x6D:
5863 case 0x6E:
5864 case 0x6F:
5865 case 0x70:
5866 case 0x71:
5867 case 0x72:
5868 case 0x73:
5869 case 0x74:
5870 case 0x75:
5871 case 0x76:
5872 case 0x77:
5873 {
5874 return get_string(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result);
5875 }
5876
5877 case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
5878 {
5879 std::uint8_t len;
5880 return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
5881 }
5882
5883 case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
5884 {
5885 std::uint16_t len;
5886 return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
5887 }
5888
5889 case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
5890 {
5891 std::uint32_t len;
5892 return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
5893 }
5894
5895 case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
5896 {

Callers

nothing calls this directly

Calls 3

getFunction · 0.85
createFunction · 0.85
parse_errorMethod · 0.45

Tested by

no test coverage detected