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 ripple {
9namespace Resource {
10
12 : m_cost(cost), m_label(label)
13{
14}
15
16std::string const&
18{
19 return m_label;
20}
21
24{
25 return m_cost;
26}
27
30{
32 ss << m_label << " ($" << m_cost << ")";
33 return ss.str();
34}
35
37operator<<(std::ostream& os, Charge const& v)
38{
39 os << v.to_string();
40 return os;
41}
42
43bool
45{
46 return c.m_cost == m_cost;
47}
48
50Charge::operator<=>(Charge const& c) const
51{
52 return m_cost <=> c.m_cost;
53}
54
57{
58 return Charge(m_cost * m, m_label);
59}
60
61} // namespace Resource
62} // namespace ripple
A consumption charge.
Definition Charge.h:11
int value_type
The type used to hold a consumption charge.
Definition Charge.h:14
Charge operator*(value_type m) const
Definition Charge.cpp:56
std::string m_label
Definition Charge.h:45
std::string to_string() const
Converts this charge into a human readable string.
Definition Charge.cpp:29
bool operator==(Charge const &) const
Definition Charge.cpp:44
value_type cost() const
Return the cost of the charge in Resource::Manager units.
Definition Charge.cpp:23
std::strong_ordering operator<=>(Charge const &) const
Definition Charge.cpp:50
std::string const & label() const
Return the human readable label associated with the charge.
Definition Charge.cpp:17
std::ostream & operator<<(std::ostream &os, Charge const &v)
Definition Charge.cpp:37
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
T str(T... args)