MCPcopy Create free account
hub / github.com/audacity/audacity / Decode

Method Decode

libraries/lib-project-file-io/ProjectSerializer.cpp:523–742  ·  view source on GitHub ↗

See ProjectFileIO::LoadProject() for explanation of the blockids arg

Source from the content-addressed store, hash-verified

521
522// See ProjectFileIO::LoadProject() for explanation of the blockids arg
523bool ProjectSerializer::Decode(BufferedStreamReader& in, XMLTagHandler* handler)
524{
525 if (handler == nullptr)
526 return false;
527
528 XMLTagHandlerAdapter adapter(handler);
529
530 std::vector<char> bytes;
531 IdMap mIds;
532 std::vector<IdMap> mIdStack;
533 char mCharSize = 0;
534
535 mIds.clear();
536
537 struct Error{}; // exception type for short-range try/catch
538 auto Lookup = [&mIds]( UShort id ) -> std::string_view
539 {
540 auto iter = mIds.find( id );
541 if (iter == mIds.end())
542 {
543 throw Error{};
544 }
545
546 return iter->second;
547 };
548
549 int64_t stringsCount = 0;
550 int64_t stringsLength = 0;
551
552 auto ReadString = [&mCharSize, &in, &bytes, &stringsCount, &stringsLength](int len) -> std::string
553 {
554 bytes.resize( len );
555 auto data = bytes.data();
556 in.Read( data, len );
557
558 stringsCount++;
559 stringsLength += len;
560
561 switch (mCharSize)
562 {
563 case 1:
564 return std::string(bytes.data(), len);
565
566 case 2:
567 return FastStringConvert<char16_t>(bytes.data(), len);
568
569 case 4:
570 return FastStringConvert<char32_t>(bytes.data(), len);
571
572 default:
573 wxASSERT_MSG(false, wxT("Characters size not 1, 2, or 4"));
574 break;
575 }
576
577 return {};
578 };
579
580 try

Callers

nothing calls this directly

Calls 14

EofMethod · 0.80
GetCMethod · 0.80
EmitStartTagMethod · 0.80
WriteRawMethod · 0.80
clearMethod · 0.45
findMethod · 0.45
endMethod · 0.45
dataMethod · 0.45
ReadMethod · 0.45
push_backMethod · 0.45
EndTagMethod · 0.45
WriteAttrMethod · 0.45

Tested by

no test coverage detected