rippled
Loading...
Searching...
No Matches
Condition.h
1#ifndef XRPL_CONDITIONS_CONDITION_H
2#define XRPL_CONDITIONS_CONDITION_H
3
4#include <xrpld/conditions/detail/utils.h>
5
6#include <xrpl/basics/Buffer.h>
7#include <xrpl/basics/Slice.h>
8
9#include <cstdint>
10#include <set>
11
12namespace ripple {
13namespace cryptoconditions {
14
15enum class Type : std::uint8_t {
17 prefixSha256 = 1,
19 rsaSha256 = 3,
21};
22
24{
25public:
33 static constexpr std::size_t maxSerializedCondition = 128;
34
47
48public:
50
57
60
63
65 : type(t), fingerprint(fp), cost(c)
66 {
67 }
68
70 : type(t), fingerprint(std::move(fp)), cost(c)
71 {
72 }
73
74 ~Condition() = default;
75
76 Condition(Condition const&) = default;
77 Condition(Condition&&) = default;
78
79 Condition() = delete;
80};
81
82inline bool
83operator==(Condition const& lhs, Condition const& rhs)
84{
85 return lhs.type == rhs.type && lhs.cost == rhs.cost &&
86 lhs.subtypes == rhs.subtypes && lhs.fingerprint == rhs.fingerprint;
87}
88
89inline bool
90operator!=(Condition const& lhs, Condition const& rhs)
91{
92 return !(lhs == rhs);
93}
94
95} // namespace cryptoconditions
96
97} // namespace ripple
98
99#endif
Like std::vector<char> but better.
Definition Buffer.h:17
An immutable linear range of bytes.
Definition Slice.h:27
Buffer fingerprint
An identifier for this condition.
Definition Condition.h:56
Condition(Type t, std::uint32_t c, Buffer &&fp)
Definition Condition.h:69
std::set< Type > subtypes
For compound conditions, set of conditions includes.
Definition Condition.h:62
Condition(Type t, std::uint32_t c, Slice fp)
Definition Condition.h:64
Condition(Condition &&)=default
static std::unique_ptr< Condition > deserialize(Slice s, std::error_code &ec)
Load a condition from its binary form.
static constexpr std::size_t maxSerializedCondition
The largest binary condition we support.
Definition Condition.h:33
Condition(Condition const &)=default
std::uint32_t cost
The cost associated with this condition.
Definition Condition.h:59
bool operator==(Condition const &lhs, Condition const &rhs)
Definition Condition.h:83
bool operator!=(Condition const &lhs, Condition const &rhs)
Definition Condition.h:90
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
STL namespace.