rippled
Loading...
Searching...
No Matches
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 <xrpl/basics/UnorderedContainers.h>
24#include <xrpl/basics/base_uint.h>
25#include <xrpl/beast/utility/Zero.h>
26#include <xrpl/protocol/AccountID.h>
27
28namespace ripple {
29namespace detail {
30
32{
33public:
34 explicit CurrencyTag() = default;
35};
36
38{
39public:
40 explicit DirectoryTag() = default;
41};
42
44{
45public:
46 explicit NodeIDTag() = default;
47};
48
49} // namespace detail
50
54
57
60
65
68
70Currency const&
72
74Currency const&
76
79Currency const&
81
82inline bool
83isXRP(Currency const& c)
84{
85 return c == beast::zero;
86}
87
90to_string(Currency const& c);
91
99bool
101
110
111inline std::ostream&
112operator<<(std::ostream& os, Currency const& x)
113{
114 os << to_string(x);
115 return os;
116}
117
118} // namespace ripple
119
120namespace std {
121
122template <>
124{
125 hash() = default;
126};
127
128template <>
130{
131 hash() = default;
132};
133
134template <>
136{
137 hash() = default;
138};
139
140template <>
142{
143 hash() = default;
144};
145
146} // namespace std
147
148#endif
Integers of any length that is a multiple of 32-bits.
Definition base_uint.h:86
hardened_hash<> hasher
Value hashing function.
Definition base_uint.h:170
Seed functor once per construction.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
Currency const & badCurrency()
We deliberately disallow the currency that looks like "XRP" because too many people were using it ins...
bool isXRP(AccountID const &c)
Definition AccountID.h:90
Currency const & noCurrency()
A placeholder for empty currencies.
std::ostream & operator<<(std::ostream &out, base_uint< Bits, Tag > const &u)
Definition base_uint.h:647
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition UintTypes.h:56
Currency const & xrpCurrency()
XRP currency.
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:630
bool to_currency(Currency &, std::string const &)
Tries to convert a string to a Currency, returns true on success.
Definition UintTypes.cpp:84
STL namespace.