diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:06:29 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:06:29 +0000 |
commit | 94994d372d014ce4c8758b9605d63fae651bd8aa (patch) | |
tree | 51c0b708bd59f205d6b35cb2a8c24d62f0c33d77 /source/API/SBStructuredData.cpp | |
parent | 39be7ce23363d12ae3e49aeb1fdb2bfeb892e836 (diff) |
Notes
Diffstat (limited to 'source/API/SBStructuredData.cpp')
-rw-r--r-- | source/API/SBStructuredData.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/source/API/SBStructuredData.cpp b/source/API/SBStructuredData.cpp index d506410f6d80..277193424e99 100644 --- a/source/API/SBStructuredData.cpp +++ b/source/API/SBStructuredData.cpp @@ -10,9 +10,10 @@ #include "lldb/API/SBStructuredData.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/Event.h" +#include "lldb/API/SBStringList.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/Target/StructuredDataPlugin.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StructuredData.h" @@ -31,6 +32,9 @@ SBStructuredData::SBStructuredData(const lldb::SBStructuredData &rhs) SBStructuredData::SBStructuredData(const lldb::EventSP &event_sp) : m_impl_up(new StructuredDataImpl(event_sp)) {} +SBStructuredData::SBStructuredData(lldb_private::StructuredDataImpl *impl) + : m_impl_up(impl) {} + SBStructuredData::~SBStructuredData() {} SBStructuredData &SBStructuredData:: @@ -76,6 +80,33 @@ size_t SBStructuredData::GetSize() const { return (m_impl_up ? m_impl_up->GetSize() : 0); } +bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const { + if (!m_impl_up) + return false; + + if (GetType() != eStructuredDataTypeDictionary) + return false; + + StructuredData::ObjectSP obj_sp = m_impl_up->GetObjectSP(); + if (!obj_sp) + return false; + + StructuredData::Dictionary *dict = obj_sp->GetAsDictionary(); + // We claimed we were a dictionary, so this can't be null. + assert(dict); + // The return kind of GetKeys is an Array: + StructuredData::ObjectSP array_sp = dict->GetKeys(); + StructuredData::Array *key_arr = array_sp->GetAsArray(); + assert(key_arr); + + key_arr->ForEach([&keys] (StructuredData::Object *object) -> bool { + llvm::StringRef key = object->GetStringValue(""); + keys.AppendString(key.str().c_str()); + return true; + }); + return true; +} + lldb::SBStructuredData SBStructuredData::GetValueForKey(const char *key) const { if (!m_impl_up) return SBStructuredData(); |