From 048d2212945f43eb88889feaffdcce75633d94ec Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Sun, 20 Jan 2019 15:06:09 -0500 Subject: Add API for parsing multiple types with BinaryView context --- binaryview.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'binaryview.cpp') diff --git a/binaryview.cpp b/binaryview.cpp index 6bd04672..8479c7d0 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -1842,6 +1842,30 @@ bool BinaryView::ParseTypeString(const string& text, QualifiedNameAndType& resul } +bool BinaryView::ParseTypeString(const string& text, std::map>& result, string& errors) +{ + BNQualifiedNameAndType* nt; + char* errorStr; + size_t count; + + if (!BNParseTypesString(m_object, text.c_str(), &nt, &count, &errorStr)) + { + errors = errorStr; + BNFreeString(errorStr); + return false; + } + + for(size_t i = 0; i < count; i++) + { + result[QualifiedName::FromAPIObject(&nt[i].name)] = new Type(BNNewTypeReference(nt[i].type)); + } + BNFreeQualifiedNameAndTypeArray(nt, count); + + errors = ""; + return true; +} + + map> BinaryView::GetTypes() { size_t count; -- cgit v1.3.1