JSON Voorhees
Killer JSON for C++
jsonv::compare_traits Struct Reference

Traits describing how to perform various aspects of comparison. More...

#include <jsonv/algorithm.hpp>

Static Public Member Functions

static int compare_kinds (kind a, kind b)
 Compare two kinds a and b. More...
 
static int compare_booleans (bool a, bool b)
 Compare two boolean values. More...
 
static int compare_integers (std::int64_t a, std::int64_t b)
 Compare two integer values. More...
 
static int compare_decimals (double a, double b)
 Compare two decimal values. More...
 
static int compare_strings (const std::string &a, const std::string &b)
 Compare two string values. More...
 
static int compare_object_keys (const std::string &a, const std::string &b)
 Compare two strings used for the keys of objects. More...
 
static int compare_objects_meta (const value &, const value &)
 Compare two objects before comparing the values. More...
 

Detailed Description

Traits describing how to perform various aspects of comparison.

This implementation for comparison is strict and is ultimately the one used by value::compare.

See also
compare

Definition at line 38 of file algorithm.hpp.

Member Function Documentation

static int jsonv::compare_traits::compare_booleans ( bool  a,
bool  b 
)
inlinestatic

Compare two boolean values.

Definition at line 52 of file algorithm.hpp.

static int jsonv::compare_traits::compare_decimals ( double  a,
double  b 
)
inlinestatic

Compare two decimal values.

Definition at line 68 of file algorithm.hpp.

static int jsonv::compare_traits::compare_integers ( std::int64_t  a,
std::int64_t  b 
)
inlinestatic

Compare two integer values.

Definition at line 60 of file algorithm.hpp.

static int jsonv::compare_traits::compare_kinds ( kind  a,
kind  b 
)
inlinestatic

Compare two kinds a and b.

This should return 0 if the types are the same or if they are directly comparable (such as kind::integer and kind::decimal) – if you return 0 for non-comparable types, you risk getting a kind_error thrown.

Definition at line 44 of file algorithm.hpp.

static int jsonv::compare_traits::compare_object_keys ( const std::string &  a,
const std::string &  b 
)
inlinestatic

Compare two strings used for the keys of objects.

Definition at line 82 of file algorithm.hpp.

static int jsonv::compare_traits::compare_objects_meta ( const value ,
const value  
)
inlinestatic

Compare two objects before comparing the values.

The compare function will only check the contents of an object if this function returns 0.

Definition at line 90 of file algorithm.hpp.

static int jsonv::compare_traits::compare_strings ( const std::string &  a,
const std::string &  b 
)
inlinestatic

Compare two string values.

Definition at line 76 of file algorithm.hpp.


The documentation for this struct was generated from the following file: