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

#include <json.h>

Inheritance diagram for json::float_number:
Collaboration diagram for json::float_number:

Public Member Functions

 float_number (double value)
 
enum kind get_kind () const final override
 
void print (pretty_printer *pp, bool formatted) const final override
 
double get () const
 
void dump (FILE *, bool formatted) const
 
void DEBUG_FUNCTION dump () const
 
virtual objectdyn_cast_object ()
 
const pointer::tokenget_pointer_token () const
 

Static Public Member Functions

static int compare (const json::value &val_a, const json::value &val_b)
 

Data Fields

pointer::token m_pointer_token
 

Private Attributes

double m_value
 

Detailed Description

Subclass of value for floating-point numbers.

Constructor & Destructor Documentation

◆ float_number()

json::float_number::float_number ( double value)
inline

References m_value.

Member Function Documentation

◆ compare()

int value::compare ( const json::value & val_a,
const json::value & val_b )
staticinherited
A deterministic total ordering for comparing json values, so that we can e.g. put them in std::map. This is intended to follow the condition for equality described in the JSON Schema standard (§4.3, “Instance equality”), as referenced by SARIF v2.1.0 (§3.7.3 "Array properties with unique values"), but has the following limitations: - numbers are supposed to be checked for "the same mathematical value", but in this implementation int vs float numbers won't compare as equal, and float number comparison is bitwise - strings are supposed to be "the same codepoint-for-codepoint", but this implementation doesn't take into account canonicalization issues.

References json::object::compare(), compare(), gcc_unreachable, json::float_number::get(), json::integer_number::get(), get_kind(), json::string::get_string(), json::JSON_ARRAY, json::JSON_FALSE, json::JSON_FLOAT, json::JSON_INTEGER, json::JSON_NULL, json::JSON_OBJECT, json::JSON_STRING, json::JSON_TRUE, and json::array::size().

Referenced by json::object::compare(), compare(), and sarif_array_of_unique< JsonElementType >::comparator_t::operator()().

◆ dump() [1/2]

void value::dump ( ) const
inherited
A convenience function for debugging. Dump to stderr with formatting, and a trailing newline.

References dump().

◆ dump() [2/2]

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 output_buffer::m_stream, pp_buffer(), pp_flush(), and print().

Referenced by dump(), generate_results(), and sarif_serialization_format_json::write_to_file().

◆ dyn_cast_object()

virtual object * json::value::dyn_cast_object ( )
inlinevirtualinherited

◆ get()

double json::float_number::get ( ) const
inline

References m_value.

Referenced by json::value::compare().

◆ get_kind()

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

Implements json::value.

References final(), and json::JSON_FLOAT.

◆ get_pointer_token()

const pointer::token & json::value::get_pointer_token ( ) const
inlineinherited

References m_pointer_token.

◆ print()

void float_number::print ( pretty_printer * pp,
bool formatted ) const
finaloverridevirtual
class json::float_number, a subclass of json::value, wrapping a double.
Implementation of json::value::print for json::float_number.

Implements json::value.

References m_value, and pp_string().

Field Documentation

◆ m_pointer_token

pointer::token json::value::m_pointer_token
inherited

◆ m_value

double json::float_number::m_value
private

Referenced by float_number(), get(), and print().


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