GCC Middle and Back End API Reference
json::object Class Reference

#include <json.h>

Inheritance diagram for json::object:
Collaboration diagram for json::object:

Public Member Functions

 ~object ()
 
enum kind get_kind () const final override
 
void print (pretty_printer *pp, bool formatted) const final override
 
void set (const char *key, value *v)
 
valueget (const char *key) const
 
void set_string (const char *key, const char *utf8_value)
 
void set_integer (const char *key, long v)
 
void set_float (const char *key, double v)
 
void set_bool (const char *key, bool v)
 
void dump (FILE *, bool formatted) const
 

Private Types

typedef hash_map< char *, value *, simple_hashmap_traits< nofree_string_hash, value * > > map_t
 

Private Attributes

map_t m_map
 
auto_vec< const char * > m_keys
 

Detailed Description

Subclass of value for objects: a collection of key/value pairs
preserving the ordering in which keys were inserted.

Preserving the order eliminates non-determinism in the output,
making it easier for the user to compare repeated invocations.   

Member Typedef Documentation

◆ map_t

Constructor & Destructor Documentation

◆ ~object()

object::~object ( )
class json::object, a subclass of json::value, representing
an ordered collection of key/value pairs.   
json:object's dtor.   

References hash_map< KeyId, Value, Traits >::begin(), hash_map< KeyId, Value, Traits >::end(), free(), ggc_alloc(), and m_map.

Member Function Documentation

◆ dump()

void value::dump ( FILE * outf,
bool formatted ) const
inherited
class json::value.   
Dump this json::value tree to OUTF.

The key/value pairs of json::objects are printed in the order
in which the keys were originally inserted.   

References ggc_alloc(), pp_buffer, pp_flush(), and json::value::print().

Referenced by json_output_format::flush_to_file(), and generate_results().

◆ get()

value * object::get ( const char * key) const
Get the json::value * for KEY.

The object retains ownership of the value.   

References gcc_assert, get(), m_map, and NULL.

Referenced by get(), and sarif_object::get_or_create_properties().

◆ get_kind()

enum kind json::object::get_kind ( ) const
inlinefinaloverridevirtual

Implements json::value.

References json::JSON_OBJECT.

◆ print()

void object::print ( pretty_printer * pp,
bool formatted ) const
finaloverridevirtual
Implementation of json::value::print for json::object.   

Implements json::value.

References FOR_EACH_VEC_ELT, ggc_alloc(), i, m_keys, m_map, pp_character(), pp_indent(), pp_indentation, pp_newline(), pp_space, pp_string(), json::value::print(), and print_escaped_json_string().

Referenced by generate_results().

◆ set()

◆ set_bool()

void object::set_bool ( const char * key,
bool v )
Set value of KEY within this object to the JSON
literal true or false, based on V.   

References set().

Referenced by sarif_invocation::prepare_to_flush().

◆ set_float()

void object::set_float ( const char * key,
double v )
Set value of KEY within this object to a JSON
floating point value based on V.   

References set().

Referenced by make_json_for_timevar_time_def().

◆ set_integer()

◆ set_string()

Field Documentation

◆ m_keys

auto_vec<const char *> json::object::m_keys
private

Referenced by print(), and set().

◆ m_map

map_t json::object::m_map
private

Referenced by get(), print(), set(), and ~object().


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