LLDB  mainline
StructuredData.h
Go to the documentation of this file.
1 //===-- StructuredData.h ----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_UTILITY_STRUCTUREDDATA_H
10 #define LLDB_UTILITY_STRUCTUREDDATA_H
11 
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/Support/JSON.h"
14 
16 #include "lldb/Utility/FileSpec.h"
17 #include "lldb/Utility/Stream.h"
18 #include "lldb/lldb-enumerations.h"
19 
20 #include <cassert>
21 #include <cstddef>
22 #include <cstdint>
23 #include <functional>
24 #include <map>
25 #include <memory>
26 #include <string>
27 #include <type_traits>
28 #include <utility>
29 #include <vector>
30 
31 namespace lldb_private {
32 class Status;
33 }
34 
35 namespace lldb_private {
36 
37 /// \class StructuredData StructuredData.h "lldb/Utility/StructuredData.h"
38 /// A class which can hold structured data
39 ///
40 /// The StructuredData class is designed to hold the data from a JSON or plist
41 /// style file -- a serialized data structure with dictionaries (maps,
42 /// hashes), arrays, and concrete values like integers, floating point
43 /// numbers, strings, booleans.
44 ///
45 /// StructuredData does not presuppose any knowledge of the schema for the
46 /// data it is holding; it can parse JSON data, for instance, and other parts
47 /// of lldb can iterate through the parsed data set to find keys and values
48 /// that may be present.
49 
51 public:
52  class Object;
53  class Array;
54  class Integer;
55  class Float;
56  class Boolean;
57  class String;
58  class Dictionary;
59  class Generic;
60 
61  typedef std::shared_ptr<Object> ObjectSP;
62  typedef std::shared_ptr<Array> ArraySP;
63  typedef std::shared_ptr<Integer> IntegerSP;
64  typedef std::shared_ptr<Float> FloatSP;
65  typedef std::shared_ptr<Boolean> BooleanSP;
66  typedef std::shared_ptr<String> StringSP;
67  typedef std::shared_ptr<Dictionary> DictionarySP;
68  typedef std::shared_ptr<Generic> GenericSP;
69 
70  class Object : public std::enable_shared_from_this<Object> {
71  public:
73  : m_type(t) {}
74 
75  virtual ~Object() = default;
76 
77  virtual bool IsValid() const { return true; }
78 
80 
82 
84 
87  ? static_cast<Array *>(this)
88  : nullptr);
89  }
90 
93  ? static_cast<Dictionary *>(this)
94  : nullptr);
95  }
96 
99  ? static_cast<Integer *>(this)
100  : nullptr);
101  }
102 
103  uint64_t GetIntegerValue(uint64_t fail_value = 0) {
105  return ((integer != nullptr) ? integer->GetValue() : fail_value);
106  }
107 
110  ? static_cast<Float *>(this)
111  : nullptr);
112  }
113 
114  double GetFloatValue(double fail_value = 0.0) {
115  Float *f = GetAsFloat();
116  return ((f != nullptr) ? f->GetValue() : fail_value);
117  }
118 
121  ? static_cast<Boolean *>(this)
122  : nullptr);
123  }
124 
125  bool GetBooleanValue(bool fail_value = false) {
126  Boolean *b = GetAsBoolean();
127  return ((b != nullptr) ? b->GetValue() : fail_value);
128  }
129 
132  ? static_cast<String *>(this)
133  : nullptr);
134  }
135 
136  llvm::StringRef GetStringValue(const char *fail_value = nullptr) {
137  String *s = GetAsString();
138  if (s)
139  return s->GetValue();
140 
141  return fail_value;
142  }
143 
146  ? static_cast<Generic *>(this)
147  : nullptr);
148  }
149 
150  ObjectSP GetObjectForDotSeparatedPath(llvm::StringRef path);
151 
152  void DumpToStdout(bool pretty_print = true) const;
153 
154  virtual void Serialize(llvm::json::OStream &s) const = 0;
155 
156  void Dump(lldb_private::Stream &s, bool pretty_print = true) const {
157  llvm::json::OStream jso(s.AsRawOstream(), pretty_print ? 2 : 0);
158  Serialize(jso);
159  }
160 
161  private:
163  };
164 
165  class Array : public Object {
166  public:
168 
169  ~Array() override = default;
170 
171  bool
172  ForEach(std::function<bool(Object *object)> const &foreach_callback) const {
173  for (const auto &object_sp : m_items) {
174  if (!foreach_callback(object_sp.get()))
175  return false;
176  }
177  return true;
178  }
179 
180  size_t GetSize() const { return m_items.size(); }
181 
182  ObjectSP operator[](size_t idx) {
183  if (idx < m_items.size())
184  return m_items[idx];
185  return ObjectSP();
186  }
187 
188  ObjectSP GetItemAtIndex(size_t idx) const {
189  assert(idx < GetSize());
190  if (idx < m_items.size())
191  return m_items[idx];
192  return ObjectSP();
193  }
194 
195  template <class IntType>
196  bool GetItemAtIndexAsInteger(size_t idx, IntType &result) const {
197  ObjectSP value_sp = GetItemAtIndex(idx);
198  if (value_sp.get()) {
199  if (auto int_value = value_sp->GetAsInteger()) {
200  result = static_cast<IntType>(int_value->GetValue());
201  return true;
202  }
203  }
204  return false;
205  }
206 
207  template <class IntType>
208  bool GetItemAtIndexAsInteger(size_t idx, IntType &result,
209  IntType default_val) const {
210  bool success = GetItemAtIndexAsInteger(idx, result);
211  if (!success)
212  result = default_val;
213  return success;
214  }
215 
216  bool GetItemAtIndexAsString(size_t idx, llvm::StringRef &result) const {
217  ObjectSP value_sp = GetItemAtIndex(idx);
218  if (value_sp.get()) {
219  if (auto string_value = value_sp->GetAsString()) {
220  result = string_value->GetValue();
221  return true;
222  }
223  }
224  return false;
225  }
226 
227  bool GetItemAtIndexAsString(size_t idx, llvm::StringRef &result,
228  llvm::StringRef default_val) const {
229  bool success = GetItemAtIndexAsString(idx, result);
230  if (!success)
231  result = default_val;
232  return success;
233  }
234 
235  bool GetItemAtIndexAsString(size_t idx, ConstString &result) const {
236  ObjectSP value_sp = GetItemAtIndex(idx);
237  if (value_sp.get()) {
238  if (auto string_value = value_sp->GetAsString()) {
239  result = ConstString(string_value->GetValue());
240  return true;
241  }
242  }
243  return false;
244  }
245 
246  bool GetItemAtIndexAsString(size_t idx, ConstString &result,
247  const char *default_val) const {
248  bool success = GetItemAtIndexAsString(idx, result);
249  if (!success)
250  result.SetCString(default_val);
251  return success;
252  }
253 
254  bool GetItemAtIndexAsDictionary(size_t idx, Dictionary *&result) const {
255  result = nullptr;
256  ObjectSP value_sp = GetItemAtIndex(idx);
257  if (value_sp.get()) {
258  result = value_sp->GetAsDictionary();
259  return (result != nullptr);
260  }
261  return false;
262  }
263 
264  bool GetItemAtIndexAsArray(size_t idx, Array *&result) const {
265  result = nullptr;
266  ObjectSP value_sp = GetItemAtIndex(idx);
267  if (value_sp.get()) {
268  result = value_sp->GetAsArray();
269  return (result != nullptr);
270  }
271  return false;
272  }
273 
274  void Push(const ObjectSP &item) { m_items.push_back(item); }
275 
276  void AddItem(const ObjectSP &item) { m_items.push_back(item); }
277 
278  void Serialize(llvm::json::OStream &s) const override;
279 
280  protected:
281  typedef std::vector<ObjectSP> collection;
283  };
284 
285  class Integer : public Object {
286  public:
287  Integer(uint64_t i = 0)
289 
290  ~Integer() override = default;
291 
292  void SetValue(uint64_t value) { m_value = value; }
293 
294  uint64_t GetValue() { return m_value; }
295 
296  void Serialize(llvm::json::OStream &s) const override;
297 
298  protected:
299  uint64_t m_value;
300  };
301 
302  class Float : public Object {
303  public:
304  Float(double d = 0.0)
306 
307  ~Float() override = default;
308 
309  void SetValue(double value) { m_value = value; }
310 
311  double GetValue() { return m_value; }
312 
313  void Serialize(llvm::json::OStream &s) const override;
314 
315  protected:
316  double m_value;
317  };
318 
319  class Boolean : public Object {
320  public:
321  Boolean(bool b = false)
323 
324  ~Boolean() override = default;
325 
326  void SetValue(bool value) { m_value = value; }
327 
328  bool GetValue() { return m_value; }
329 
330  void Serialize(llvm::json::OStream &s) const override;
331 
332  protected:
333  bool m_value;
334  };
335 
336  class String : public Object {
337  public:
339  explicit String(llvm::StringRef S)
341 
342  void SetValue(llvm::StringRef S) { m_value = std::string(S); }
343 
344  llvm::StringRef GetValue() { return m_value; }
345 
346  void Serialize(llvm::json::OStream &s) const override;
347 
348  protected:
350  };
351 
352  class Dictionary : public Object {
353  public:
355 
358  if (!obj_sp || obj_sp->GetType() != lldb::eStructuredDataTypeDictionary) {
360  return;
361  }
362 
363  Dictionary *dict = obj_sp->GetAsDictionary();
364  m_dict = dict->m_dict;
365  }
366 
367  ~Dictionary() override = default;
368 
369  size_t GetSize() const { return m_dict.size(); }
370 
371  void ForEach(std::function<bool(ConstString key, Object *object)> const
372  &callback) const {
373  for (const auto &pair : m_dict) {
374  if (!callback(pair.first, pair.second.get()))
375  break;
376  }
377  }
378 
379  ObjectSP GetKeys() const {
380  auto object_sp = std::make_shared<Array>();
381  collection::const_iterator iter;
382  for (iter = m_dict.begin(); iter != m_dict.end(); ++iter) {
383  auto key_object_sp = std::make_shared<String>();
384  key_object_sp->SetValue(iter->first.AsCString());
385  object_sp->Push(key_object_sp);
386  }
387  return object_sp;
388  }
389 
390  ObjectSP GetValueForKey(llvm::StringRef key) const {
391  ObjectSP value_sp;
392  if (!key.empty()) {
393  ConstString key_cs(key);
394  collection::const_iterator iter = m_dict.find(key_cs);
395  if (iter != m_dict.end())
396  value_sp = iter->second;
397  }
398  return value_sp;
399  }
400 
401  bool GetValueForKeyAsBoolean(llvm::StringRef key, bool &result) const {
402  bool success = false;
403  ObjectSP value_sp = GetValueForKey(key);
404  if (value_sp.get()) {
405  Boolean *result_ptr = value_sp->GetAsBoolean();
406  if (result_ptr) {
407  result = result_ptr->GetValue();
408  success = true;
409  }
410  }
411  return success;
412  }
413  template <class IntType>
414  bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const {
415  ObjectSP value_sp = GetValueForKey(key);
416  if (value_sp) {
417  if (auto int_value = value_sp->GetAsInteger()) {
418  result = static_cast<IntType>(int_value->GetValue());
419  return true;
420  }
421  }
422  return false;
423  }
424 
425  template <class IntType>
426  bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result,
427  IntType default_val) const {
428  bool success = GetValueForKeyAsInteger<IntType>(key, result);
429  if (!success)
430  result = default_val;
431  return success;
432  }
433 
434  bool GetValueForKeyAsString(llvm::StringRef key,
435  llvm::StringRef &result) const {
436  ObjectSP value_sp = GetValueForKey(key);
437  if (value_sp.get()) {
438  if (auto string_value = value_sp->GetAsString()) {
439  result = string_value->GetValue();
440  return true;
441  }
442  }
443  return false;
444  }
445 
446  bool GetValueForKeyAsString(llvm::StringRef key, llvm::StringRef &result,
447  const char *default_val) const {
448  bool success = GetValueForKeyAsString(key, result);
449  if (!success) {
450  if (default_val)
451  result = default_val;
452  else
453  result = llvm::StringRef();
454  }
455  return success;
456  }
457 
458  bool GetValueForKeyAsString(llvm::StringRef key,
459  ConstString &result) const {
460  ObjectSP value_sp = GetValueForKey(key);
461  if (value_sp.get()) {
462  if (auto string_value = value_sp->GetAsString()) {
463  result = ConstString(string_value->GetValue());
464  return true;
465  }
466  }
467  return false;
468  }
469 
470  bool GetValueForKeyAsString(llvm::StringRef key, ConstString &result,
471  const char *default_val) const {
472  bool success = GetValueForKeyAsString(key, result);
473  if (!success)
474  result.SetCString(default_val);
475  return success;
476  }
477 
478  bool GetValueForKeyAsDictionary(llvm::StringRef key,
479  Dictionary *&result) const {
480  result = nullptr;
481  ObjectSP value_sp = GetValueForKey(key);
482  if (value_sp.get()) {
483  result = value_sp->GetAsDictionary();
484  return (result != nullptr);
485  }
486  return false;
487  }
488 
489  bool GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const {
490  result = nullptr;
491  ObjectSP value_sp = GetValueForKey(key);
492  if (value_sp.get()) {
493  result = value_sp->GetAsArray();
494  return (result != nullptr);
495  }
496  return false;
497  }
498 
499  bool HasKey(llvm::StringRef key) const {
500  ConstString key_cs(key);
501  collection::const_iterator search = m_dict.find(key_cs);
502  return search != m_dict.end();
503  }
504 
505  void AddItem(llvm::StringRef key, ObjectSP value_sp) {
506  ConstString key_cs(key);
507  m_dict[key_cs] = std::move(value_sp);
508  }
509 
510  void AddIntegerItem(llvm::StringRef key, uint64_t value) {
511  AddItem(key, std::make_shared<Integer>(value));
512  }
513 
514  void AddFloatItem(llvm::StringRef key, double value) {
515  AddItem(key, std::make_shared<Float>(value));
516  }
517 
518  void AddStringItem(llvm::StringRef key, llvm::StringRef value) {
519  AddItem(key, std::make_shared<String>(std::move(value)));
520  }
521 
522  void AddBooleanItem(llvm::StringRef key, bool value) {
523  AddItem(key, std::make_shared<Boolean>(value));
524  }
525 
526  void Serialize(llvm::json::OStream &s) const override;
527 
528  protected:
529  typedef std::map<ConstString, ObjectSP> collection;
531  };
532 
533  class Null : public Object {
534  public:
536 
537  ~Null() override = default;
538 
539  bool IsValid() const override { return false; }
540 
541  void Serialize(llvm::json::OStream &s) const override;
542  };
543 
544  class Generic : public Object {
545  public:
546  explicit Generic(void *object = nullptr)
548 
549  void SetValue(void *value) { m_object = value; }
550 
551  void *GetValue() const { return m_object; }
552 
553  bool IsValid() const override { return m_object != nullptr; }
554 
555  void Serialize(llvm::json::OStream &s) const override;
556 
557  private:
558  void *m_object;
559  };
560 
561  static ObjectSP ParseJSON(const std::string &json_text);
562  static ObjectSP ParseJSONFromFile(const FileSpec &file, Status &error);
563 };
564 
565 } // namespace lldb_private
566 
567 #endif // LLDB_UTILITY_STRUCTUREDDATA_H
lldb_private::StructuredData::Float::~Float
~Float() override=default
lldb::eStructuredDataTypeBoolean
@ eStructuredDataTypeBoolean
Definition: lldb-enumerations.h:792
lldb_private::StructuredData::Boolean::m_value
bool m_value
Definition: StructuredData.h:333
lldb::StructuredDataType
StructuredDataType
Definition: lldb-enumerations.h:785
lldb_private::StructuredData::Dictionary
Definition: StructuredData.h:352
lldb_private::StructuredData::Object::IsValid
virtual bool IsValid() const
Definition: StructuredData.h:77
lldb_private::StructuredData::Array
Definition: StructuredData.h:165
lldb_private::StructuredData::Dictionary::GetValueForKey
ObjectSP GetValueForKey(llvm::StringRef key) const
Definition: StructuredData.h:390
lldb_private::StructuredData::GenericSP
std::shared_ptr< Generic > GenericSP
Definition: StructuredData.h:68
lldb::eStructuredDataTypeString
@ eStructuredDataTypeString
Definition: lldb-enumerations.h:793
lldb_private::StructuredData::Array::Serialize
void Serialize(llvm::json::OStream &s) const override
Definition: StructuredData.cpp:134
lldb::eStructuredDataTypeDictionary
@ eStructuredDataTypeDictionary
Definition: lldb-enumerations.h:794
lldb_private::StructuredData::Integer
Definition: StructuredData.h:285
lldb_private::StructuredData::Object::GetAsGeneric
Generic * GetAsGeneric()
Definition: StructuredData.h:144
lldb_private::StructuredData::Dictionary::m_dict
collection m_dict
Definition: StructuredData.h:530
lldb_private::StructuredData::Array::GetItemAtIndexAsDictionary
bool GetItemAtIndexAsDictionary(size_t idx, Dictionary *&result) const
Definition: StructuredData.h:254
lldb_private::StructuredData::Boolean::~Boolean
~Boolean() override=default
lldb_private::StructuredData::Object::GetType
lldb::StructuredDataType GetType() const
Definition: StructuredData.h:81
lldb_private::StructuredData::String::String
String(llvm::StringRef S)
Definition: StructuredData.h:339
lldb_private::StructuredData::Object::DumpToStdout
void DumpToStdout(bool pretty_print=true) const
Definition: StructuredData.cpp:129
lldb_private::StructuredData::Object::GetFloatValue
double GetFloatValue(double fail_value=0.0)
Definition: StructuredData.h:114
lldb_private::StructuredData::Array::GetItemAtIndexAsInteger
bool GetItemAtIndexAsInteger(size_t idx, IntType &result, IntType default_val) const
Definition: StructuredData.h:208
lldb_private::StructuredData::Array::Array
Array()
Definition: StructuredData.h:167
lldb_private::ConstString::SetCString
void SetCString(const char *cstr)
Set the C string value.
Definition: ConstString.cpp:302
lldb_private::StructuredData::Dictionary::Serialize
void Serialize(llvm::json::OStream &s) const override
Definition: StructuredData.cpp:158
lldb_private::StructuredData::Dictionary::Dictionary
Dictionary()
Definition: StructuredData.h:354
lldb_private::Stream
Definition: Stream.h:28
lldb_private::StructuredData::Integer::Serialize
void Serialize(llvm::json::OStream &s) const override
Definition: StructuredData.cpp:142
lldb_private::StructuredData::Array::collection
std::vector< ObjectSP > collection
Definition: StructuredData.h:281
lldb_private::StructuredData::Object::GetAsInteger
Integer * GetAsInteger()
Definition: StructuredData.h:97
lldb_private::StructuredData::Dictionary::Dictionary
Dictionary(ObjectSP obj_sp)
Definition: StructuredData.h:356
lldb_private::StructuredData::Array::GetItemAtIndexAsString
bool GetItemAtIndexAsString(size_t idx, ConstString &result) const
Definition: StructuredData.h:235
lldb_private::StructuredData::Object::GetAsString
String * GetAsString()
Definition: StructuredData.h:130
lldb_private::StructuredData::Null::Serialize
void Serialize(llvm::json::OStream &s) const override
Definition: StructuredData.cpp:168
lldb::eStructuredDataTypeInvalid
@ eStructuredDataTypeInvalid
Definition: lldb-enumerations.h:786
lldb_private::StructuredData::Boolean
Definition: StructuredData.h:319
lldb_private::StructuredData::Dictionary::GetValueForKeyAsInteger
bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const
Definition: StructuredData.h:414
lldb_private::StructuredData::Dictionary::AddBooleanItem
void AddBooleanItem(llvm::StringRef key, bool value)
Definition: StructuredData.h:522
lldb_private::StructuredData::Dictionary::~Dictionary
~Dictionary() override=default
lldb_private::StructuredData::Object::Clear
virtual void Clear()
Definition: StructuredData.h:79
lldb::eStructuredDataTypeGeneric
@ eStructuredDataTypeGeneric
Definition: lldb-enumerations.h:788
lldb_private::StructuredData::Integer::GetValue
uint64_t GetValue()
Definition: StructuredData.h:294
lldb_private::StructuredData::String::String
String()
Definition: StructuredData.h:338
lldb_private::FileSpec
Definition: FileSpec.h:56
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::StructuredData::StringSP
std::shared_ptr< String > StringSP
Definition: StructuredData.h:66
lldb_private::StructuredData::String
Definition: StructuredData.h:336
lldb_private::StructuredData::ParseJSONFromFile
static ObjectSP ParseJSONFromFile(const FileSpec &file, Status &error)
Definition: StructuredData.cpp:35
lldb_private::StructuredData::Null
Definition: StructuredData.h:533
lldb_private::StructuredData::Object::Dump
void Dump(lldb_private::Stream &s, bool pretty_print=true) const
Definition: StructuredData.h:156
object
lldb_private::StructuredData::Object::GetStringValue
llvm::StringRef GetStringValue(const char *fail_value=nullptr)
Definition: StructuredData.h:136
lldb_private::StructuredData::Dictionary::GetValueForKeyAsString
bool GetValueForKeyAsString(llvm::StringRef key, ConstString &result, const char *default_val) const
Definition: StructuredData.h:470
lldb_private::StructuredData::Integer::Integer
Integer(uint64_t i=0)
Definition: StructuredData.h:287
lldb_private::StructuredData::Float::SetValue
void SetValue(double value)
Definition: StructuredData.h:309
lldb_private::StructuredData::Object::GetAsFloat
Float * GetAsFloat()
Definition: StructuredData.h:108
lldb_private::StructuredData::ObjectSP
std::shared_ptr< Object > ObjectSP
Definition: StructuredData.h:59
lldb_private::StructuredData::Float::m_value
double m_value
Definition: StructuredData.h:316
lldb_private::StructuredData::Dictionary::GetKeys
ObjectSP GetKeys() const
Definition: StructuredData.h:379
lldb_private::StructuredData::Array::GetItemAtIndexAsString
bool GetItemAtIndexAsString(size_t idx, ConstString &result, const char *default_val) const
Definition: StructuredData.h:246
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::StructuredData::Boolean::SetValue
void SetValue(bool value)
Definition: StructuredData.h:326
lldb_private::StructuredData::Dictionary::GetValueForKeyAsInteger
bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result, IntType default_val) const
Definition: StructuredData.h:426
lldb-enumerations.h
lldb_private::StructuredData::Array::GetItemAtIndexAsArray
bool GetItemAtIndexAsArray(size_t idx, Array *&result) const
Definition: StructuredData.h:264
lldb_private::StructuredData::Boolean::Serialize
void Serialize(llvm::json::OStream &s) const override
Definition: StructuredData.cpp:150
lldb_private::StructuredData::Array::AddItem
void AddItem(const ObjectSP &item)
Definition: StructuredData.h:276
lldb_private::StructuredData::Null::~Null
~Null() override=default
lldb_private::StructuredData::Object::GetIntegerValue
uint64_t GetIntegerValue(uint64_t fail_value=0)
Definition: StructuredData.h:103
lldb_private::StructuredData::DictionarySP
std::shared_ptr< Dictionary > DictionarySP
Definition: StructuredData.h:67
lldb_private::StructuredData::Array::Push
void Push(const ObjectSP &item)
Definition: StructuredData.h:274
lldb_private::StructuredData::Dictionary::GetSize
size_t GetSize() const
Definition: StructuredData.h:369
lldb_private::StructuredData::Generic::Generic
Generic(void *object=nullptr)
Definition: StructuredData.h:546
lldb_private::StructuredData::String::m_value
std::string m_value
Definition: StructuredData.h:349
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::StructuredData::String::GetValue
llvm::StringRef GetValue()
Definition: StructuredData.h:344
lldb_private::StructuredData::Null::IsValid
bool IsValid() const override
Definition: StructuredData.h:539
lldb_private::StructuredData::Generic
Definition: StructuredData.h:544
lldb_private::StructuredData
Definition: StructuredData.h:50
lldb_private::StructuredData::Dictionary::AddItem
void AddItem(llvm::StringRef key, ObjectSP value_sp)
Definition: StructuredData.h:505
lldb_private::StructuredData::Object::Object
Object(lldb::StructuredDataType t=lldb::eStructuredDataTypeInvalid)
Definition: StructuredData.h:72
lldb_private::StructuredData::Null::Null
Null()
Definition: StructuredData.h:535
lldb_private::StructuredData::Array::operator[]
ObjectSP operator[](size_t idx)
Definition: StructuredData.h:182
lldb_private::StructuredData::Object::GetAsArray
Array * GetAsArray()
Definition: StructuredData.h:85
lldb_private::StructuredData::Object::~Object
virtual ~Object()=default
lldb_private::StructuredData::Object::GetBooleanValue
bool GetBooleanValue(bool fail_value=false)
Definition: StructuredData.h:125
lldb_private::StructuredData::Float
Definition: StructuredData.h:302
lldb_private::StructuredData::FloatSP
std::shared_ptr< Float > FloatSP
Definition: StructuredData.h:64
lldb_private::Status
Definition: Status.h:44
lldb_private::StructuredData::Boolean::GetValue
bool GetValue()
Definition: StructuredData.h:328
lldb_private::StructuredData::Integer::m_value
uint64_t m_value
Definition: StructuredData.h:299
lldb_private::StructuredData::Float::GetValue
double GetValue()
Definition: StructuredData.h:311
lldb_private::StructuredData::Dictionary::AddFloatItem
void AddFloatItem(llvm::StringRef key, double value)
Definition: StructuredData.h:514
lldb_private::StructuredData::Dictionary::ForEach
void ForEach(std::function< bool(ConstString key, Object *object)> const &callback) const
Definition: StructuredData.h:371
lldb_private::StructuredData::Dictionary::GetValueForKeyAsString
bool GetValueForKeyAsString(llvm::StringRef key, llvm::StringRef &result, const char *default_val) const
Definition: StructuredData.h:446
lldb_private::StructuredData::Object::SetType
void SetType(lldb::StructuredDataType t)
Definition: StructuredData.h:83
lldb_private::StructuredData::Object::GetAsDictionary
Dictionary * GetAsDictionary()
Definition: StructuredData.h:91
lldb_private::StructuredData::String::Serialize
void Serialize(llvm::json::OStream &s) const override
Definition: StructuredData.cpp:154
lldb_private::StructuredData::Array::m_items
collection m_items
Definition: StructuredData.h:282
lldb_private::StructuredData::Array::GetItemAtIndexAsInteger
bool GetItemAtIndexAsInteger(size_t idx, IntType &result) const
Definition: StructuredData.h:196
lldb_private::StructuredData::Object::Serialize
virtual void Serialize(llvm::json::OStream &s) const =0
lldb_private::Stream::AsRawOstream
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition: Stream.h:357
lldb_private::StructuredData::Dictionary::HasKey
bool HasKey(llvm::StringRef key) const
Definition: StructuredData.h:499
lldb_private::StructuredData::BooleanSP
std::shared_ptr< Boolean > BooleanSP
Definition: StructuredData.h:65
lldb_private::StructuredData::Float::Float
Float(double d=0.0)
Definition: StructuredData.h:304
lldb::eStructuredDataTypeInteger
@ eStructuredDataTypeInteger
Definition: lldb-enumerations.h:790
lldb::eStructuredDataTypeFloat
@ eStructuredDataTypeFloat
Definition: lldb-enumerations.h:791
lldb_private::StructuredData::Dictionary::AddStringItem
void AddStringItem(llvm::StringRef key, llvm::StringRef value)
Definition: StructuredData.h:518
lldb_private::StructuredData::String::SetValue
void SetValue(llvm::StringRef S)
Definition: StructuredData.h:342
lldb_private::StructuredData::Array::GetItemAtIndexAsString
bool GetItemAtIndexAsString(size_t idx, llvm::StringRef &result, llvm::StringRef default_val) const
Definition: StructuredData.h:227
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::StructuredData::Object::GetObjectForDotSeparatedPath
ObjectSP GetObjectForDotSeparatedPath(llvm::StringRef path)
Definition: StructuredData.cpp:96
lldb_private::StructuredData::Dictionary::GetValueForKeyAsDictionary
bool GetValueForKeyAsDictionary(llvm::StringRef key, Dictionary *&result) const
Definition: StructuredData.h:478
lldb_private::StructuredData::Dictionary::AddIntegerItem
void AddIntegerItem(llvm::StringRef key, uint64_t value)
Definition: StructuredData.h:510
FileSpec.h
lldb_private::StructuredData::Dictionary::collection
std::map< ConstString, ObjectSP > collection
Definition: StructuredData.h:529
lldb_private::StructuredData::Object::GetAsBoolean
Boolean * GetAsBoolean()
Definition: StructuredData.h:119
lldb::eStructuredDataTypeArray
@ eStructuredDataTypeArray
Definition: lldb-enumerations.h:789
ConstString.h
lldb_private::StructuredData::Generic::m_object
void * m_object
Definition: StructuredData.h:558
lldb_private::StructuredData::Generic::GetValue
void * GetValue() const
Definition: StructuredData.h:551
lldb_private::StructuredData::Array::GetItemAtIndexAsString
bool GetItemAtIndexAsString(size_t idx, llvm::StringRef &result) const
Definition: StructuredData.h:216
Stream.h
lldb_private::StructuredData::ParseJSON
static ObjectSP ParseJSON(const std::string &json_text)
Definition: StructuredData.cpp:25
lldb_private::StructuredData::ArraySP
std::shared_ptr< Array > ArraySP
Definition: StructuredData.h:62
lldb_private::StructuredData::Integer::~Integer
~Integer() override=default
lldb_private::StructuredData::Dictionary::GetValueForKeyAsString
bool GetValueForKeyAsString(llvm::StringRef key, llvm::StringRef &result) const
Definition: StructuredData.h:434
lldb_private::StructuredData::Dictionary::GetValueForKeyAsArray
bool GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const
Definition: StructuredData.h:489
lldb_private::StructuredData::Array::GetItemAtIndex
ObjectSP GetItemAtIndex(size_t idx) const
Definition: StructuredData.h:188
lldb_private::StructuredData::Boolean::Boolean
Boolean(bool b=false)
Definition: StructuredData.h:321
lldb_private::StructuredData::Generic::SetValue
void SetValue(void *value)
Definition: StructuredData.h:549
lldb_private::StructuredData::Array::GetSize
size_t GetSize() const
Definition: StructuredData.h:180
integer
#define integer
Definition: EmulateInstructionARM64.cpp:75
lldb_private::StructuredData::Generic::Serialize
void Serialize(llvm::json::OStream &s) const override
Definition: StructuredData.cpp:172
lldb_private::StructuredData::Dictionary::GetValueForKeyAsString
bool GetValueForKeyAsString(llvm::StringRef key, ConstString &result) const
Definition: StructuredData.h:458
lldb_private::StructuredData::Generic::IsValid
bool IsValid() const override
Definition: StructuredData.h:553
lldb::eStructuredDataTypeNull
@ eStructuredDataTypeNull
Definition: lldb-enumerations.h:787
lldb_private::StructuredData::Dictionary::GetValueForKeyAsBoolean
bool GetValueForKeyAsBoolean(llvm::StringRef key, bool &result) const
Definition: StructuredData.h:401
lldb_private::StructuredData::Object::m_type
lldb::StructuredDataType m_type
Definition: StructuredData.h:162
lldb_private::LineStatus::Status
@ Status
lldb_private::StructuredData::IntegerSP
std::shared_ptr< Integer > IntegerSP
Definition: StructuredData.h:63
lldb_private::StructuredData::Object
Definition: StructuredData.h:70
lldb
Definition: SBAddress.h:15
lldb_private::StructuredData::Array::~Array
~Array() override=default
lldb_private::StructuredData::Array::ForEach
bool ForEach(std::function< bool(Object *object)> const &foreach_callback) const
Definition: StructuredData.h:172
lldb_private::StructuredData::Float::Serialize
void Serialize(llvm::json::OStream &s) const override
Definition: StructuredData.cpp:146
lldb_private::StructuredData::Integer::SetValue
void SetValue(uint64_t value)
Definition: StructuredData.h:292