* See ISO/IEC 24778:2008 Section 8 */
| 221 | * See ISO/IEC 24778:2008 Section 8 |
| 222 | */ |
| 223 | static StructuredAppendInfo ParseStructuredAppend(ByteArray& bytes) |
| 224 | { |
| 225 | std::string text(bytes.begin(), bytes.end()); |
| 226 | StructuredAppendInfo sai; |
| 227 | std::string::size_type i = 0; |
| 228 | |
| 229 | if (text[0] == ' ') { // Space-delimited id |
| 230 | std::string::size_type sp = text.find(' ', 1); |
| 231 | if (sp == std::string::npos) |
| 232 | return {}; |
| 233 | |
| 234 | sai.id = text.substr(1, sp - 1); // Strip space delimiters |
| 235 | i = sp + 1; |
| 236 | } |
| 237 | if (i + 1 >= text.size() || !std::isupper(text[i]) || !std::isupper(text[i + 1])) |
| 238 | return {}; |
| 239 | |
| 240 | sai.index = text[i] - 'A'; |
| 241 | sai.count = text[i + 1] - 'A' + 1; |
| 242 | |
| 243 | if (sai.count == 1 || sai.count <= sai.index) // If info doesn't make sense |
| 244 | sai.count = 0; // Choose to mark count as unknown |
| 245 | |
| 246 | text.erase(0, i + 2); // Remove |
| 247 | bytes = ByteArray(text); |
| 248 | |
| 249 | return sai; |
| 250 | } |
| 251 | |
| 252 | static void DecodeContent(const BitArray& bits, Content& res) |
| 253 | { |