diff options
| author | Josh Ferrell <josh@vector35.com> | 2024-05-08 16:19:26 -0400 |
|---|---|---|
| committer | Josh Ferrell <josh@vector35.com> | 2024-05-14 14:31:46 -0400 |
| commit | cb407be11b08c1c427fcf33a49974155e522e14a (patch) | |
| tree | 4c99b4230e375517a4742a6ac3d4bc95c9e6bd23 /undoaction.cpp | |
| parent | 3c28d7e6eaa84041ec0fe5352a618759c13e6cb3 (diff) | |
Ref count undo objects
Diffstat (limited to 'undoaction.cpp')
| -rw-r--r-- | undoaction.cpp | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/undoaction.cpp b/undoaction.cpp index 5d2e5268..8b596888 100644 --- a/undoaction.cpp +++ b/undoaction.cpp @@ -25,13 +25,63 @@ using namespace Json; using namespace std; -UndoAction::UndoAction(const BNUndoAction& action) +UndoAction::UndoAction(BNUndoAction* action) { - actionType = action.actionType; - summaryText = action.summaryText; - summaryTokens.reserve(action.summaryTokenCount); - for (size_t i = 0; i < action.summaryTokenCount; i++) + m_object = action; +} + + +std::string UndoAction::GetSummaryText() +{ + char* summary = BNUndoActionGetSummaryText(m_object); + std::string result = summary; + BNFreeString(summary); + return result; +} + + +vector<InstructionTextToken> UndoAction::GetSummary() +{ + size_t count = 0; + BNInstructionTextToken* result = BNUndoActionGetSummary(m_object, &count); + vector<InstructionTextToken> newTokens; + return InstructionTextToken::ConvertAndFreeInstructionTextTokenList(result, count); +} + + +UndoEntry::UndoEntry(BNUndoEntry* entry) +{ + m_object = entry; +} + + +std::string UndoEntry::GetId() +{ + char* id = BNUndoEntryGetId(m_object); + std::string result = id; + BNFreeString(id); + return result; +} + + +std::vector<Ref<UndoAction>> UndoEntry::GetActions() +{ + size_t count; + + BNUndoAction** actions = BNUndoEntryGetActions(m_object, &count); + std::vector<Ref<UndoAction>> result; + result.reserve(count); + for (size_t i = 0; i < count; i++) { - summaryTokens.push_back(action.summaryTokens[i]); + result.push_back(new UndoAction(BNNewUndoActionReference(actions[i]))); } + + BNFreeUndoActionList(actions, count); + return result; +} + + +uint64_t UndoEntry::GetTimestamp() +{ + return BNUndoEntryGetTimestamp(m_object); } |
