GCC Code Coverage Report


Directory: ./
File: libs/capy/include/boost/capy/bcrypt/error.hpp
Date: 2025-12-30 20:31:36
Exec Total Coverage
Lines: 5 5 100.0%
Functions: 2 2 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 //
2 // Copyright (c) 2025 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/cppalliance/capy
8 //
9
10 #ifndef BOOST_CAPY_BCRYPT_ERROR_HPP
11 #define BOOST_CAPY_BCRYPT_ERROR_HPP
12
13 #include <boost/capy/detail/config.hpp>
14 #include <boost/system/error_category.hpp>
15 #include <boost/system/is_error_code_enum.hpp>
16
17 namespace boost {
18 namespace capy {
19 namespace bcrypt {
20
21 /** Error codes for bcrypt operations.
22
23 These errors indicate malformed input from untrusted sources.
24 */
25 enum class error
26 {
27 /// Success
28 ok = 0,
29
30 /// Salt string is malformed
31 invalid_salt,
32
33 /// Hash string is malformed
34 invalid_hash
35 };
36
37 } // bcrypt
38 } // capy
39
40 namespace system {
41 template<>
42 struct is_error_code_enum<
43 ::boost::capy::bcrypt::error>
44 {
45 static bool const value = true;
46 };
47 } // system
48
49 namespace capy {
50 namespace bcrypt {
51
52 namespace detail {
53
54 struct BOOST_SYMBOL_VISIBLE
55 error_cat_type
56 : system::error_category
57 {
58 BOOST_CAPY_DECL const char* name(
59 ) const noexcept override;
60 BOOST_CAPY_DECL std::string message(
61 int) const override;
62 BOOST_CAPY_DECL char const* message(
63 int, char*, std::size_t
64 ) const noexcept override;
65 10 BOOST_SYSTEM_CONSTEXPR error_cat_type()
66 10 : error_category(0xbc8f2a4e7c193d56)
67 {
68 10 }
69 };
70
71 BOOST_CAPY_DECL extern
72 error_cat_type error_cat;
73
74 } // detail
75
76 inline
77 BOOST_SYSTEM_CONSTEXPR
78 system::error_code
79 15 make_error_code(
80 error ev) noexcept
81 {
82 return system::error_code{
83 static_cast<std::underlying_type<
84 error>::type>(ev),
85 15 detail::error_cat};
86 }
87
88 } // bcrypt
89 } // capy
90 } // boost
91
92 #endif
93