• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

STEllAR-GROUP / hpx / #882

31 Aug 2023 07:44PM UTC coverage: 41.798% (-44.7%) from 86.546%
#882

push

19442 of 46514 relevant lines covered (41.8%)

126375.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

5.26
/libs/core/datastructures/src/serializable_any.cpp
1
/*=============================================================================
2
    Copyright (c) 2013 Shuangyang Yang
3
    Copyright (c) 2007-2022 Hartmut Kaiser
4
    Copyright (c) Christopher Diggins 2005
5
    Copyright (c) Pablo Aguilar 2005
6
    Copyright (c) Kevlin Henney 2001
7

8
    SPDX-License-Identifier: BSL-1.0
9
    Distributed under the Boost Software License, Version 1.0. (See accompanying
10
    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11

12
    The class hpx::any is built based on boost::spirit::hold_any class. It adds
13
    support for HPX serialization, move assignment, == operator.
14
==============================================================================*/
15

16
#include <hpx/config.hpp>
17
#include <hpx/modules/datastructures.hpp>
18
#include <hpx/modules/serialization.hpp>
19

20
#include <boost/functional/hash.hpp>
21

22
#include <cstddef>
23
#include <type_traits>
24
#include <vector>
25

26
////////////////////////////////////////////////////////////////////////////////
27
namespace hpx::util {
28

29
    ////////////////////////////////////////////////////////////////////////////
30
    namespace detail {
31

32
        struct hash_binary_filter : serialization::binary_filter
×
33
        {
34
            explicit constexpr hash_binary_filter(std::size_t seed = 0) noexcept
35
              : hash(seed)
×
36
            {
37
            }
38

39
            // compression API
40
            void set_max_length(std::size_t /* size */) override {}
×
41
            void save(void const* src, std::size_t src_count) override
×
42
            {
43
                auto const data = static_cast<char const*>(src);
44
                boost::hash_range(hash, data, data + src_count);
×
45
            }
×
46
            bool flush(void* /* dst */, std::size_t dst_count,
×
47
                std::size_t& written) override
48
            {
49
                written = dst_count;
×
50
                return true;
×
51
            }
52

53
            // decompression API
54
            std::size_t init_data(void const* /* buffer */,
×
55
                std::size_t /* size */, std::size_t /* buffer_size */) override
56
            {
57
                return 0;
×
58
            }
59
            void load(void* /* dst */, std::size_t /* dst_count */) override {}
×
60

61
            template <typename T>
62
            static constexpr void serialize(T&, unsigned) noexcept
63
            {
64
            }
65
            HPX_SERIALIZATION_POLYMORPHIC(hash_binary_filter, override)
64✔
66

67
            std::size_t hash;
68
        };
69
    }    // namespace detail
70

71
    ////////////////////////////////////////////////////////////////////////////
72
    template <typename Char>
73
    std::size_t hash_any::operator()(basic_any<serialization::input_archive,
×
74
        serialization::output_archive, Char, std::true_type> const& elem) const
75
    {
76
        detail::hash_binary_filter hasher;
×
77

78
        {
79
            std::vector<char> data;
×
80
            serialization::output_archive ar(data, 0U, nullptr, &hasher);
×
81
            ar << elem;
82
        }    // let archive go out of scope
×
83

84
        return hasher.hash;
×
85
    }
86

87
    template std::size_t hash_any::operator()(
88
        basic_any<serialization::input_archive, serialization::output_archive,
89
            char, std::true_type> const& elem) const;
90

91
    template std::size_t hash_any::operator()(
92
        basic_any<serialization::input_archive, serialization::output_archive,
93
            wchar_t, std::true_type> const& elem) const;
94
}    // namespace hpx::util
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc