rippled
ripple
resource
impl
Charge.cpp
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of rippled: https://github.com/ripple/rippled
4
Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6
Permission to use, copy, modify, and/or distribute this software for any
7
purpose with or without fee is hereby granted, provided that the above
8
copyright notice and this permission notice appear in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
//==============================================================================
19
20
#include <ripple/resource/Charge.h>
21
#include <
sstream
>
22
23
namespace
ripple
{
24
namespace
Resource {
25
26
Charge::Charge
(
value_type
cost,
std::string
const
& label)
27
: m_cost(cost), m_label(label)
28
{
29
}
30
31
std::string
const
&
32
Charge::label
()
const
33
{
34
return
m_label
;
35
}
36
37
Charge::value_type
38
Charge::cost
()
const
39
{
40
return
m_cost
;
41
}
42
43
std::string
44
Charge::to_string
()
const
45
{
46
std::stringstream
ss;
47
ss <<
m_label
<<
" ($"
<<
m_cost
<<
")"
;
48
return
ss.
str
();
49
}
50
51
std::ostream
&
52
operator<<
(
std::ostream
& os,
Charge
const
& v)
53
{
54
os << v.
to_string
();
55
return
os;
56
}
57
58
bool
59
Charge::operator==
(
Charge
const
& c)
const
60
{
61
return
c.
m_cost
==
m_cost
;
62
}
63
64
bool
65
Charge::operator!=
(
Charge
const
& c)
const
66
{
67
return
c.
m_cost
!=
m_cost
;
68
}
69
70
}
// namespace Resource
71
}
// namespace ripple
sstream
ripple::Resource::Charge::operator==
bool operator==(Charge const &) const
Definition:
Charge.cpp:59
std::string
STL class.
ripple::Resource::Charge::value_type
int value_type
The type used to hold a consumption charge.
Definition:
Charge.h:34
ripple::Resource::Charge::to_string
std::string to_string() const
Converts this charge into a human readable string.
Definition:
Charge.cpp:44
ripple::Resource::Charge::operator!=
bool operator!=(Charge const &) const
Definition:
Charge.cpp:65
std::stringstream
STL class.
ripple::Resource::Charge::m_cost
value_type m_cost
Definition:
Charge.h:60
ripple::Resource::operator<<
std::ostream & operator<<(std::ostream &os, Charge const &v)
Definition:
Charge.cpp:52
std::ostream
STL class.
ripple::Resource::Charge::Charge
Charge()=delete
ripple::Resource::Charge::cost
value_type cost() const
Return the cost of the charge in Resource::Manager units.
Definition:
Charge.cpp:38
ripple::Resource::Charge::m_label
std::string m_label
Definition:
Charge.h:61
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition:
RCLCensorshipDetector.h:29
ripple::Resource::Charge::label
std::string const & label() const
Return the human readable label associated with the charge.
Definition:
Charge.cpp:32
ripple::Resource::Charge
A consumption charge.
Definition:
Charge.h:30
std::stringstream::str
T str(T... args)
Generated by
1.8.17