| 104 | } |
| 105 | |
| 106 | std::string DataParser::readString(void) |
| 107 | { |
| 108 | const uint8_t units = readU8(); |
| 109 | if (units == 0) { |
| 110 | return ""; |
| 111 | } |
| 112 | |
| 113 | std::u16string utf16; |
| 114 | utf16.reserve(units); |
| 115 | for (uint8_t i = 0; i < units; i++) { |
| 116 | const uint16_t unit = readU16(); |
| 117 | if (!mOk) { |
| 118 | return ""; |
| 119 | } |
| 120 | // The terminator is included in the count; stop at it rather than |
| 121 | // carrying an embedded null into the std::string. |
| 122 | if (unit == 0) { |
| 123 | break; |
| 124 | } |
| 125 | utf16.push_back((char16_t)unit); |
| 126 | } |
| 127 | return StringUtils::UTF16toUTF8(utf16); |
| 128 | } |
| 129 | |
| 130 | void DataParser::skip(size_t count) |
| 131 | { |
no test coverage detected