| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) | ||
| 3 | // | ||
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
| 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
| 6 | // | ||
| 7 | // Official repository: https://github.com/boostorg/json | ||
| 8 | // | ||
| 9 | |||
| 10 | #ifndef BOOST_JSON_IMPL_VISIT_HPP | ||
| 11 | #define BOOST_JSON_IMPL_VISIT_HPP | ||
| 12 | |||
| 13 | namespace boost { | ||
| 14 | namespace json { | ||
| 15 | |||
| 16 | |||
| 17 | template<class Visitor> | ||
| 18 | auto | ||
| 19 | 16 | visit( | |
| 20 | Visitor&& v, | ||
| 21 | value& jv) -> decltype( | ||
| 22 | static_cast<Visitor&&>(v)( std::declval<std::nullptr_t&>() ) ) | ||
| 23 | { | ||
| 24 |
8/8✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
|
16 | switch(jv.kind()) |
| 25 | { | ||
| 26 | 2 | default: // unreachable()? | |
| 27 | 2 | case kind::string: return static_cast<Visitor&&>(v)( jv.get_string() ); | |
| 28 | 2 | case kind::array: return static_cast<Visitor&&>(v)( jv.get_array() ); | |
| 29 | 2 | case kind::object: return static_cast<Visitor&&>(v)( jv.get_object() ); | |
| 30 | 2 | case kind::bool_: return static_cast<Visitor&&>(v)( jv.get_bool() ); | |
| 31 | 2 | case kind::int64: return static_cast<Visitor&&>(v)( jv.get_int64() ); | |
| 32 | 2 | case kind::uint64: return static_cast<Visitor&&>(v)( jv.get_uint64() ); | |
| 33 | 2 | case kind::double_: return static_cast<Visitor&&>(v)( jv.get_double() ); | |
| 34 | 2 | case kind::null: { | |
| 35 | 2 | auto np = nullptr; | |
| 36 | 2 | return static_cast<Visitor&&>(v)(np) ; | |
| 37 | } | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | template<class Visitor> | ||
| 42 | auto | ||
| 43 | 264 | visit( | |
| 44 | Visitor&& v, | ||
| 45 | value const& jv) -> decltype( | ||
| 46 | static_cast<Visitor&&>(v)( std::declval<std::nullptr_t const&>() ) ) | ||
| 47 | { | ||
| 48 |
8/8✓ Branch 1 taken 45 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 29 times.
✓ Branch 5 taken 91 times.
✓ Branch 6 taken 17 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 33 times.
|
264 | switch(jv.kind()) |
| 49 | { | ||
| 50 | 46 | default: // unreachable()? | |
| 51 | 46 | case kind::string: return static_cast<Visitor&&>(v)( jv.get_string() ); | |
| 52 | 12 | case kind::array: return static_cast<Visitor&&>(v)( jv.get_array() ); | |
| 53 | 22 | case kind::object: return static_cast<Visitor&&>(v)( jv.get_object() ); | |
| 54 | 30 | case kind::bool_: return static_cast<Visitor&&>(v)( jv.get_bool() ); | |
| 55 | 92 | case kind::int64: return static_cast<Visitor&&>(v)( jv.get_int64() ); | |
| 56 | 18 | case kind::uint64: return static_cast<Visitor&&>(v)( jv.get_uint64() ); | |
| 57 | 10 | case kind::double_: return static_cast<Visitor&&>(v)( jv.get_double() ); | |
| 58 | 34 | case kind::null: { | |
| 59 | 34 | auto const np = nullptr; | |
| 60 | 34 | return static_cast<Visitor&&>(v)(np) ; | |
| 61 | } | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | |||
| 66 | template<class Visitor> | ||
| 67 | auto | ||
| 68 | 16 | visit( | |
| 69 | Visitor&& v, | ||
| 70 | value&& jv) -> decltype( | ||
| 71 | static_cast<Visitor&&>(v)( std::declval<std::nullptr_t&&>() ) ) | ||
| 72 | { | ||
| 73 | 16 | switch(jv.kind()) | |
| 74 | { | ||
| 75 | 2 | default: // unreachable()? | |
| 76 | 2 | case kind::string: return static_cast<Visitor&&>(v)( std::move( jv.get_string() ) ); | |
| 77 | 2 | case kind::array: return static_cast<Visitor&&>(v)( std::move( jv.get_array() ) ); | |
| 78 | 2 | case kind::object: return static_cast<Visitor&&>(v)( std::move( jv.get_object() ) ); | |
| 79 | 2 | case kind::bool_: return static_cast<Visitor&&>(v)( std::move( jv.get_bool() ) ); | |
| 80 | 2 | case kind::int64: return static_cast<Visitor&&>(v)( std::move( jv.get_int64() ) ); | |
| 81 | 2 | case kind::uint64: return static_cast<Visitor&&>(v)( std::move( jv.get_uint64() ) ); | |
| 82 | 2 | case kind::double_: return static_cast<Visitor&&>(v)( std::move( jv.get_double() ) ); | |
| 83 | 2 | case kind::null: return static_cast<Visitor&&>(v)( std::nullptr_t() ) ; | |
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | } // namespace json | ||
| 88 | } // namespace boost | ||
| 89 | |||
| 90 | #endif | ||
| 91 |