JSON Voorhees
Killer JSON for C++
functional.hpp
Go to the documentation of this file.
1 /** \file jsonv/functional.hpp
2  * A collection of function objects a la `<functional>`.
3  *
4  * Copyright (c) 2015 by Travis Gockel. All rights reserved.
5  *
6  * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License
7  * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later
8  * version.
9  *
10  * \author Travis Gockel (travis@gockelhut.com)
11 **/
12 #ifndef __JSONV_FUNCTIONAL_HPP_INCLUDED__
13 #define __JSONV_FUNCTIONAL_HPP_INCLUDED__
14 
15 #include <jsonv/config.hpp>
16 
17 #include <functional>
18 
19 namespace jsonv
20 {
21 
22 class value;
23 
24 /** \addtogroup Algorithm
25  * \{
26 **/
27 
28 /** Compares a \c value to another using the standard-issue \c value::compare function. **/
30 {
31  using first_argument_type = value;
33  using result_type = int;
34 
35  int operator()(const value& a, const value& b) const;
36 };
37 
38 /** Compares two values, ignoring the case for any \c value with \c kind::string. This does \e not ignore case for the
39  * keys of objects.
40 **/
42 {
43  using first_argument_type = value;
45  using result_type = int;
46 
47  int operator()(const value& a, const value& b) const;
48 };
49 
50 template <typename FCompare, typename FResult>
52  private FCompare,
53  private FResult
54 {
55  using first_argument_type = value;
57  using result_type = bool;
58 
59  bool operator()(const value& a, const value& b) const
60  {
61  return FResult::operator()(FCompare::operator()(a, b), 0);
62  }
63 };
64 
77 
78 /** \} **/
79 
80 }
81 
82 #endif/*__JSONV_FUNCTIONAL_HPP_INCLUDED__*/
Compares a value to another using the standard-issue value::compare function.
Definition: functional.hpp:29
Compares two values, ignoring the case for any value with kind::string.
Definition: functional.hpp:41
Copyright (c) 2014-2019 by Travis Gockel.
Represents a single JSON value, which can be any one of a potential kind, each behaving slightly diff...
Definition: value.hpp:131