JSON Voorhees
Killer JSON for C++
algorithm.hpp File Reference

A collection of algorithms a la <algorithm>. More...

#include <jsonv/config.hpp>
#include <jsonv/value.hpp>
#include <jsonv/path.hpp>
#include <cmath>
#include <functional>
#include <limits>

Go to the source code of this file.

Classes

struct  jsonv::compare_traits
 Traits describing how to perform various aspects of comparison. More...
 
struct  jsonv::diff_result
 The results of the diff operation. More...
 
class  jsonv::merge_rules
 This class is used in merge_explicit for defining what the function should do in the cases of conflicts. More...
 
class  jsonv::dynamic_merge_rules
 An implementation of merge_rules that allows you to bind whatever functions you want to resolve conflicts. More...
 
class  jsonv::throwing_merge_rules
 These rules throw an exception on all conflicts. More...
 
class  jsonv::recursive_merge_rules
 These rules will recursively merge everything they can and coerce all values. More...
 
class  jsonv::validation_error
 Error thrown when an unrepresentable value is encountered in a JSON AST. More...
 

Functions

template<typename TCompareTraits >
int jsonv::compare (const value &a, const value &b, const TCompareTraits &traits)
 Compare the values a and b using the comparison traits. More...
 
JSONV_PUBLIC int jsonv::compare (const value &a, const value &b)
 Compare the values a and b with strict comparison traits. More...
 
JSONV_PUBLIC int jsonv::compare_icase (const value &a, const value &b)
 Compare the values a and b, but use case-insensitive matching on kind::string values. More...
 
JSONV_PUBLIC diff_result jsonv::diff (value left, value right)
 Find the differences and similarities between the structures of left and right. More...
 
JSONV_PUBLIC value jsonv::map (const std::function< value(const value &)> &func, const value &input)
 Run a function over the values in the input. More...
 
JSONV_PUBLIC value jsonv::map (const std::function< value(value)> &func, value &&input)
 Run a function over the values in the input. More...
 
JSONV_PUBLIC void jsonv::traverse (const value &tree, const std::function< void(const path &, const value &)> &func, const path &base_path, bool leafs_only=false)
 Recursively walk the provided tree and call func for each item in the tree. More...
 
JSONV_PUBLIC void jsonv::traverse (const value &tree, const std::function< void(const path &, const value &)> &func, bool leafs_only=false)
 Recursively walk the provided tree and call func for each item in the tree. More...
 
JSONV_PUBLIC value jsonv::merge_explicit (const merge_rules &rules, path current_path, value a, value b)
 Merges two values, a and b into a single value. More...
 
JSONV_PUBLIC value jsonv::merge_explicit (const merge_rules &, const path &, value a)
 
JSONV_PUBLIC value jsonv::merge_explicit (const merge_rules &, const path &)
 
template<typename... TValue>
value jsonv::merge_explicit (const merge_rules &rules, path current_path, value a, value b, value c, TValue &&...rest)
 
template<typename... TValue>
value jsonv::merge (TValue &&...values)
 Merges all the provided values into a single value. More...
 
template<typename... TValue>
value jsonv::merge_recursive (TValue &&...values)
 Merges all the provided values into a single value. More...
 
JSONV_PUBLIC std::ostream & jsonv::operator<< (std::ostream &os, const validation_error::code &code)
 
JSONV_PUBLIC void jsonv::validate (const value &val)
 Check that the provided val is perfectly representable as a JSON string. More...
 

Detailed Description

A collection of algorithms a la <algorithm>.

Copyright (c) 2014-2018 by Travis Gockel. All rights reserved.

This program is free software: you can redistribute it and/or modify it under the terms of the Apache License as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later version.

Author
Travis Gockel (travi.nosp@m.s@go.nosp@m.ckelh.nosp@m.ut.c.nosp@m.om)

Definition in file algorithm.hpp.