xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
libxrpl
resource
Charge.cpp
1
#include <xrpl/resource/Charge.h>
2
3
#include <
compare
>
4
#include <
ostream
>
5
#include <
sstream
>
6
#include <
string
>
7
#include <
utility
>
8
9
namespace
xrpl::resource
{
10
11
Charge::Charge
(
value_type
cost
,
std::string
label
) :
cost_
(
cost
),
label_
(
std
::move(
label
))
12
{
13
}
14
15
std::string
const
&
16
Charge::label
()
const
17
{
18
return
label_
;
19
}
20
21
Charge::value_type
22
Charge::cost
()
const
23
{
24
return
cost_
;
25
}
26
27
std::string
28
Charge::toString
()
const
29
{
30
std::stringstream
ss;
31
ss <<
label_
<<
" ($"
<<
cost_
<<
")"
;
32
return
ss.
str
();
33
}
34
35
std::ostream
&
36
operator<<
(
std::ostream
& os,
Charge
const
& v)
37
{
38
os << v.
toString
();
39
return
os;
40
}
41
42
bool
43
Charge::operator==
(
Charge
const
& c)
const
44
{
45
return
c.
cost_
==
cost_
;
46
}
47
48
std::strong_ordering
49
Charge::operator<=>
(
Charge
const
& c)
const
50
{
51
return
cost_ <=>
c.
cost_
;
52
}
53
54
Charge
55
Charge::operator*
(
value_type
m)
const
56
{
57
return
Charge
(
cost_
* m,
label_
);
58
}
59
60
}
// namespace xrpl::resource
std::ostream
std::string
std::stringstream
xrpl::resource::Charge
A consumption charge.
Definition
Charge.h:13
xrpl::resource::Charge::operator<=>
std::strong_ordering operator<=>(Charge const &) const
Definition
Charge.cpp:49
xrpl::resource::Charge::Charge
Charge()=delete
xrpl::resource::Charge::operator==
bool operator==(Charge const &) const
Definition
Charge.cpp:43
xrpl::resource::Charge::value_type
int value_type
The type used to hold a consumption charge.
Definition
Charge.h:18
xrpl::resource::Charge::label
std::string const & label() const
Return the human readable label associated with the charge.
Definition
Charge.cpp:16
xrpl::resource::Charge::label_
std::string label_
Definition
Charge.h:57
xrpl::resource::Charge::toString
std::string toString() const
Converts this charge into a human readable string.
Definition
Charge.cpp:28
xrpl::resource::Charge::operator*
Charge operator*(value_type m) const
Definition
Charge.cpp:55
xrpl::resource::Charge::cost
value_type cost() const
Return the cost of the charge in resource::Manager units.
Definition
Charge.cpp:22
xrpl::resource::Charge::cost_
value_type cost_
Definition
Charge.h:56
compare
std
STL namespace.
xrpl::resource
Definition
ServiceRegistry.h:21
xrpl::resource::operator<<
std::ostream & operator<<(std::ostream &os, Charge const &v)
Definition
Charge.cpp:36
ostream
sstream
std::stringstream::str
T str(T... args)
string
std::strong_ordering
utility
Generated by
1.17.0