rippled
UintTypes.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2014 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 #ifndef RIPPLE_PROTOCOL_UINTTYPES_H_INCLUDED
21 #define RIPPLE_PROTOCOL_UINTTYPES_H_INCLUDED
22 
23 #include <ripple/basics/UnorderedContainers.h>
24 #include <ripple/basics/base_uint.h>
25 #include <ripple/beast/utility/Zero.h>
26 #include <ripple/protocol/AccountID.h>
27 
28 namespace ripple {
29 namespace detail {
30 
32 {
33 public:
34  explicit CurrencyTag() = default;
35 };
36 
38 {
39 public:
40  explicit DirectoryTag() = default;
41 };
42 
43 class NodeIDTag
44 {
45 public:
46  explicit NodeIDTag() = default;
47 };
48 
49 } // namespace detail
50 
54 
57 
60 
62 Currency const&
63 xrpCurrency();
64 
66 Currency const&
67 noCurrency();
68 
71 Currency const&
72 badCurrency();
73 
74 inline bool
75 isXRP(Currency const& c)
76 {
77  return c == beast::zero;
78 }
79 
82 to_string(Currency const& c);
83 
91 bool
93 
100 Currency
101 to_currency(std::string const&);
102 
103 inline std::ostream&
104 operator<<(std::ostream& os, Currency const& x)
105 {
106  os << to_string(x);
107  return os;
108 }
109 
110 } // namespace ripple
111 
112 namespace std {
113 
114 template <>
116 {
117  explicit hash() = default;
118 };
119 
120 template <>
122 {
123  explicit hash() = default;
124 };
125 
126 template <>
128 {
129  explicit hash() = default;
130 };
131 
132 } // namespace std
133 
134 #endif
ripple::badCurrency
Currency const & badCurrency()
We deliberately disallow the currency that looks like "XRP" because too many people were using it ins...
Definition: UintTypes.cpp:135
ripple::to_currency
bool to_currency(Currency &currency, std::string const &code)
Tries to convert a string to a Currency, returns true on success.
Definition: UintTypes.cpp:80
std::string
STL class.
ripple::detail::DirectoryTag::DirectoryTag
DirectoryTag()=default
ripple::noCurrency
Currency const & noCurrency()
A placeholder for empty currencies.
Definition: UintTypes.cpp:128
ripple::detail::CurrencyTag::CurrencyTag
CurrencyTag()=default
ripple::operator<<
std::ostream & operator<<(std::ostream &os, TOffer< TIn, TOut > const &offer)
Definition: Offer.h:242
ripple::base_uint
Integers of any length that is a multiple of 32-bits.
Definition: base_uint.h:82
std::ostream
STL class.
ripple::hardened_hash
Seed functor once per construction.
Definition: hardened_hash.h:96
ripple::detail::DirectoryTag
Definition: UintTypes.h:37
ripple::detail::CurrencyTag
Definition: UintTypes.h:31
ripple::isXRP
bool isXRP(AccountID const &c)
Definition: AccountID.h:89
ripple::Currency
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition: UintTypes.h:56
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
std
STL namespace.
ripple::to_string
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
Definition: app/misc/impl/Manifest.cpp:41
ripple::detail::NodeIDTag
Definition: UintTypes.h:43
ripple::xrpCurrency
Currency const & xrpCurrency()
XRP currency.
Definition: UintTypes.cpp:121
std::hash
ripple::detail::NodeIDTag::NodeIDTag
NodeIDTag()=default