rippled
Loading...
Searching...
No Matches
Charge.cpp
1#include <xrpl/resource/Charge.h>
2
3#include <compare>
4#include <ostream>
5#include <sstream>
6#include <string>
7
8namespace xrpl {
9namespace Resource {
10
11Charge::Charge(value_type cost, std::string const& label) : m_cost(cost), m_label(label)
12{
13}
14
15std::string const&
17{
18 return m_label;
19}
20
23{
24 return m_cost;
25}
26
29{
31 ss << m_label << " ($" << m_cost << ")";
32 return ss.str();
33}
34
36operator<<(std::ostream& os, Charge const& v)
37{
38 os << v.to_string();
39 return os;
40}
41
42bool
44{
45 return c.m_cost == m_cost;
46}
47
49Charge::operator<=>(Charge const& c) const
50{
51 return m_cost <=> c.m_cost;
52}
53
56{
57 return Charge(m_cost * m, m_label);
58}
59
60} // namespace Resource
61} // namespace xrpl
A consumption charge.
Definition Charge.h:11
std::string const & label() const
Return the human readable label associated with the charge.
Definition Charge.cpp:16
std::string m_label
Definition Charge.h:45
Charge operator*(value_type m) const
Definition Charge.cpp:55
value_type m_cost
Definition Charge.h:44
std::string to_string() const
Converts this charge into a human readable string.
Definition Charge.cpp:28
value_type cost() const
Return the cost of the charge in Resource::Manager units.
Definition Charge.cpp:22
std::strong_ordering operator<=>(Charge const &) const
Definition Charge.cpp:49
int value_type
The type used to hold a consumption charge.
Definition Charge.h:14
bool operator==(Charge const &) const
Definition Charge.cpp:43
std::ostream & operator<<(std::ostream &os, Charge const &v)
Definition Charge.cpp:36
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
T str(T... args)