diff options
| author | Peter LaFosse <peter@vector35.com> | 2019-01-20 15:06:09 -0500 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2019-01-20 15:06:32 -0500 |
| commit | 048d2212945f43eb88889feaffdcce75633d94ec (patch) | |
| tree | 746b4822a9d59064fd6d4149727c31d7fa110d4b /binaryview.cpp | |
| parent | 251c79b66fd552a7499e96d7ab13e3e36c726e00 (diff) | |
Add API for parsing multiple types with BinaryView context
Diffstat (limited to 'binaryview.cpp')
| -rw-r--r-- | binaryview.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
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<QualifiedName, Ref<Type>>& 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<QualifiedName, Ref<Type>> BinaryView::GetTypes() { size_t count; |
