diff options
Diffstat (limited to 'src/cppbor_parse.cpp')
-rw-r--r-- | src/cppbor_parse.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/cppbor_parse.cpp b/src/cppbor_parse.cpp index 2736b71..42d74fb 100644 --- a/src/cppbor_parse.cpp +++ b/src/cppbor_parse.cpp @@ -149,17 +149,14 @@ class IncompleteMap : public Map, public IncompleteItem { size_t mSize; }; -class IncompleteSemantic : public Semantic, public IncompleteItem { +class IncompleteSemanticTag : public SemanticTag, public IncompleteItem { public: - explicit IncompleteSemantic(uint64_t value) : Semantic(value) {} + explicit IncompleteSemanticTag(uint64_t value) : SemanticTag(value) {} // We return the "complete" size, rather than the actual size. size_t size() const override { return 1; } - void add(std::unique_ptr<Item> item) override { - mEntries.reserve(1); - mEntries.push_back(std::move(item)); - } + void add(std::unique_ptr<Item> item) override { mTaggedItem = std::move(item); } }; std::tuple<const uint8_t*, ParseClient*> handleEntries(size_t entryCount, const uint8_t* hdrBegin, @@ -254,7 +251,7 @@ std::tuple<const uint8_t*, ParseClient*> parseRecursively(const uint8_t* begin, pos, end, "map", parseClient); case SEMANTIC: - return handleCompound(std::make_unique<IncompleteSemantic>(addlData), 1, begin, pos, + return handleCompound(std::make_unique<IncompleteSemanticTag>(addlData), 1, begin, pos, end, "semantic", parseClient); case SIMPLE: @@ -326,15 +323,18 @@ class FullParseClient : public ParseClient { #if __has_feature(cxx_rtti) assert(dynamic_cast<IncompleteItem*>(parent)); #endif + + IncompleteItem* parentItem{}; if (parent->type() == ARRAY) { - static_cast<IncompleteArray*>(parent)->add(std::move(item)); + parentItem = static_cast<IncompleteArray*>(parent); } else if (parent->type() == MAP) { - static_cast<IncompleteMap*>(parent)->add(std::move(item)); - } else if (parent->type() == SEMANTIC) { - static_cast<IncompleteSemantic*>(parent)->add(std::move(item)); + parentItem = static_cast<IncompleteMap*>(parent); + } else if (parent->asSemanticTag()) { + parentItem = static_cast<IncompleteSemanticTag*>(parent); } else { CHECK(false); // Impossible to get here. } + parentItem->add(std::move(item)); } std::unique_ptr<Item> mTheItem; |