|
JSON Voorhees
Killer JSON for C++
|
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. | |
| static int | compare_booleans (bool a, bool b) |
| Compare two boolean values. | |
| static int | compare_integers (std::int64_t a, std::int64_t b) |
| Compare two integer values. | |
| static int | compare_integer_decimal (std::int64_t a, double b) |
| Compare the integer a with the decimal b by their exact numeric values. | |
| static int | compare_decimals (double a, double b) |
| Compare two decimal values exactly, without an epsilon tolerance. | |
| static int | compare_strings (std::string_view a, std::string_view b) |
| Compare two string values. | |
| static int | compare_object_keys (const std::string &a, const std::string &b) |
| Compare two strings used for the keys of objects. | |
| static int | compare_objects_meta (const value &, const value &) |
| Compare two objects before comparing the values. | |
Traits describing how to perform various aspects of comparison.
This implementation for comparison is strict and is ultimately the one used by value::compare.
Definition at line 38 of file algorithm.hpp.
|
inlinestatic |
Compare two boolean values.
Definition at line 54 of file algorithm.hpp.
|
inlinestatic |
Compare two decimal values exactly, without an epsilon tolerance.
Signed zeros compare equal and infinities follow numeric order. All NaNs compare equal to each other and greater than every non-NaN number, regardless of sign or payload. This defines a strict weak ordering for decimals.
Definition at line 105 of file algorithm.hpp.
|
inlinestatic |
Compare the integer a with the decimal b by their exact numeric values.
a is never converted to double, which would round an integer past 2^53 onto a neighbor: 9007199254740993 is greater than the decimal 9007199254740992.0, not equal to it. An integer equals a decimal only when the decimal holds exactly that integer, so both signed zeros equal 0. Infinities follow numeric order and NaN is greater than every integer, as in compare_decimals. compare calls this for both operand orders, reversing the sign of the result when the decimal is on the left.
Definition at line 78 of file algorithm.hpp.
|
inlinestatic |
Compare two integer values.
Definition at line 63 of file algorithm.hpp.
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 45 of file algorithm.hpp.
|
inlinestatic |
Compare two strings used for the keys of objects.
Definition at line 125 of file algorithm.hpp.
|
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 134 of file algorithm.hpp.
|
inlinestatic |
Compare two string values.
Definition at line 118 of file algorithm.hpp.