LLVM 19.0.0git
Classes | Public Types | Public Member Functions | List of all members
llvm::json::Object Class Reference

An Object is a JSON object, which maps strings to heterogenous JSON values. More...

#include "llvm/Support/JSON.h"

Classes

struct  KV
 

Public Types

using key_type = ObjectKey
 
using mapped_type = Value
 
using value_type = Storage::value_type
 
using iterator = Storage::iterator
 
using const_iterator = Storage::const_iterator
 

Public Member Functions

 Object ()=default
 
 Object (std::initializer_list< KV > Properties)
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
bool empty () const
 
size_t size () const
 
void clear ()
 
std::pair< iterator, boolinsert (KV E)
 
template<typename... Ts>
std::pair< iterator, booltry_emplace (const ObjectKey &K, Ts &&... Args)
 
template<typename... Ts>
std::pair< iterator, booltry_emplace (ObjectKey &&K, Ts &&... Args)
 
bool erase (StringRef K)
 
void erase (iterator I)
 
iterator find (StringRef K)
 
const_iterator find (StringRef K) const
 
Valueoperator[] (const ObjectKey &K)
 
Valueoperator[] (ObjectKey &&K)
 
Valueget (StringRef K)
 
const Valueget (StringRef K) const
 
std::optional< std::nullptr_t > getNull (StringRef K) const
 
std::optional< boolgetBoolean (StringRef K) const
 
std::optional< double > getNumber (StringRef K) const
 
std::optional< int64_t > getInteger (StringRef K) const
 
std::optional< llvm::StringRefgetString (StringRef K) const
 
const json::ObjectgetObject (StringRef K) const
 
json::ObjectgetObject (StringRef K)
 
const json::ArraygetArray (StringRef K) const
 
json::ArraygetArray (StringRef K)
 

Detailed Description

An Object is a JSON object, which maps strings to heterogenous JSON values.

It simulates DenseMap<ObjectKey, Value>. ObjectKey is a maybe-owned string.

Definition at line 98 of file JSON.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 107 of file JSON.h.

◆ iterator

Definition at line 106 of file JSON.h.

◆ key_type

Definition at line 103 of file JSON.h.

◆ mapped_type

Definition at line 104 of file JSON.h.

◆ value_type

Definition at line 105 of file JSON.h.

Constructor & Destructor Documentation

◆ Object() [1/2]

llvm::json::Object::Object ( )
default

◆ Object() [2/2]

llvm::json::Object::Object ( std::initializer_list< KV Properties)
inlineexplicit

Definition at line 636 of file JSON.h.

References P, and try_emplace().

Member Function Documentation

◆ begin() [1/2]

iterator llvm::json::Object::begin ( )
inline

Definition at line 115 of file JSON.h.

◆ begin() [2/2]

const_iterator llvm::json::Object::begin ( ) const
inline

Definition at line 116 of file JSON.h.

◆ clear()

void llvm::json::Object::clear ( )
inline

Definition at line 123 of file JSON.h.

◆ empty()

bool llvm::json::Object::empty ( ) const
inline

Definition at line 120 of file JSON.h.

◆ end() [1/2]

iterator llvm::json::Object::end ( )
inline

Definition at line 117 of file JSON.h.

Referenced by get().

◆ end() [2/2]

const_iterator llvm::json::Object::end ( ) const
inline

Definition at line 118 of file JSON.h.

◆ erase() [1/2]

void llvm::json::Object::erase ( iterator  I)
inline

Definition at line 134 of file JSON.h.

References I.

◆ erase() [2/2]

bool llvm::json::Object::erase ( StringRef  K)
inline

◆ find() [1/2]

iterator llvm::json::Object::find ( StringRef  K)
inline

Definition at line 136 of file JSON.h.

Referenced by get().

◆ find() [2/2]

const_iterator llvm::json::Object::find ( StringRef  K) const
inline

Definition at line 137 of file JSON.h.

◆ get() [1/2]

Value * llvm::json::Object::get ( StringRef  K)

◆ get() [2/2]

const Value * llvm::json::Object::get ( StringRef  K) const

Definition at line 36 of file JSON.cpp.

References end(), find(), and I.

◆ getArray() [1/2]

json::Array * llvm::json::Object::getArray ( StringRef  K)

Definition at line 82 of file JSON.cpp.

References get().

◆ getArray() [2/2]

const json::Array * llvm::json::Object::getArray ( StringRef  K) const

Definition at line 77 of file JSON.cpp.

References get().

◆ getBoolean()

std::optional< bool > llvm::json::Object::getBoolean ( StringRef  K) const

Definition at line 47 of file JSON.cpp.

References get().

◆ getInteger()

std::optional< int64_t > llvm::json::Object::getInteger ( StringRef  K) const

Definition at line 57 of file JSON.cpp.

References get().

◆ getNull()

std::optional< std::nullptr_t > llvm::json::Object::getNull ( StringRef  K) const

Definition at line 42 of file JSON.cpp.

References get().

◆ getNumber()

std::optional< double > llvm::json::Object::getNumber ( StringRef  K) const

Definition at line 52 of file JSON.cpp.

References get().

◆ getObject() [1/2]

json::Object * llvm::json::Object::getObject ( StringRef  K)

Definition at line 72 of file JSON.cpp.

References get().

◆ getObject() [2/2]

const json::Object * llvm::json::Object::getObject ( StringRef  K) const

Definition at line 67 of file JSON.cpp.

References get().

Referenced by llvm::MachO::getInterfaceFileFromJSON().

◆ getString()

std::optional< llvm::StringRef > llvm::json::Object::getString ( StringRef  K) const

Definition at line 62 of file JSON.cpp.

References get().

◆ insert()

std::pair< Object::iterator, bool > llvm::json::Object::insert ( KV  E)
inline

Definition at line 643 of file JSON.h.

References E, and try_emplace().

◆ operator[]() [1/2]

Value & llvm::json::Object::operator[] ( const ObjectKey K)

Definition at line 24 of file JSON.cpp.

References try_emplace().

◆ operator[]() [2/2]

Value & llvm::json::Object::operator[] ( ObjectKey &&  K)

Definition at line 27 of file JSON.cpp.

References try_emplace().

◆ size()

size_t llvm::json::Object::size ( ) const
inline

Definition at line 121 of file JSON.h.

◆ try_emplace() [1/2]

template<typename... Ts>
std::pair< iterator, bool > llvm::json::Object::try_emplace ( const ObjectKey K,
Ts &&...  Args 
)
inline

Definition at line 126 of file JSON.h.

Referenced by insert(), Object(), operator[](), and llvm::DWARFVerifier::summarize().

◆ try_emplace() [2/2]

template<typename... Ts>
std::pair< iterator, bool > llvm::json::Object::try_emplace ( ObjectKey &&  K,
Ts &&...  Args 
)
inline

Definition at line 130 of file JSON.h.


The documentation for this class was generated from the following files: