xrpld
Loading...
Searching...
No Matches
Condition.h
1#pragma once
2
3#include <xrpl/basics/Buffer.h>
4#include <xrpl/basics/Slice.h>
5#include <xrpl/conditions/detail/utils.h>
6
7#include <cstdint>
8#include <set>
9
11
19
21{
22public:
30 static constexpr std::size_t kMaxSerializedCondition = 128;
31
44
45public:
47
54
57
60
62 {
63 }
64
65 Condition(Type t, std::uint32_t c, Buffer&& fp) : type(t), fingerprint(std::move(fp)), cost(c)
66 {
67 }
68
69 ~Condition() = default;
70
71 Condition(Condition const&) = default;
72 Condition(Condition&&) = default;
73
74 Condition() = delete;
75};
76
77inline bool
78operator==(Condition const& lhs, Condition const& rhs)
79{
80 return lhs.type == rhs.type && lhs.cost == rhs.cost && lhs.subtypes == rhs.subtypes &&
81 lhs.fingerprint == rhs.fingerprint;
82}
83
84inline bool
85operator!=(Condition const& lhs, Condition const& rhs)
86{
87 return !(lhs == rhs);
88}
89
90} // namespace xrpl::cryptoconditions
Like std::vector<char> but better.
Definition Buffer.h:16
An immutable linear range of bytes.
Definition Slice.h:26
Buffer fingerprint
An identifier for this condition.
Definition Condition.h:53
std::set< Type > subtypes
For compound conditions, set of conditions includes.
Definition Condition.h:59
Condition(Condition &&)=default
static constexpr std::size_t kMaxSerializedCondition
The largest binary condition we support.
Definition Condition.h:30
Condition(Type t, std::uint32_t c, Buffer &&fp)
Definition Condition.h:65
std::uint32_t cost
The cost associated with this condition.
Definition Condition.h:56
Condition(Type t, std::uint32_t c, Slice fp)
Definition Condition.h:61
static std::unique_ptr< Condition > deserialize(Slice s, std::error_code &ec)
Load a condition from its binary form.
Condition(Condition const &)=default
STL namespace.
bool operator!=(Condition const &lhs, Condition const &rhs)
Definition Condition.h:85
bool operator==(Condition const &lhs, Condition const &rhs)
Definition Condition.h:78