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
67Currency const&
69
71Currency const&
73
76Currency const&
78
79inline bool
80isXRP(Currency const& c)
81{
82 return c == beast::zero;
83}
84
87to_string(Currency const& c);
88
96bool
98
107
108inline std::ostream&
109operator<<(std::ostream& os, Currency const& x)
110{
111 os << to_string(x);
112 return os;
113}
114
115} // namespace ripple
116
117namespace std {
118
119template <>
121{
122 explicit hash() = default;
123};
124
125template <>
127{
128 explicit hash() = default;
129};
130
131template <>
133{
134 explicit hash() = default;
135};
136
137template <>
139{
140 explicit hash() = default;
141};
142
143} // namespace std
144
145#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.
Definition: hardened_hash.h:97
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
Currency const & badCurrency()
We deliberately disallow the currency that looks like "XRP" because too many people were using it ins...
Definition: UintTypes.cpp:133
bool isXRP(AccountID const &c)
Definition: AccountID.h:91
Currency const & noCurrency()
A placeholder for empty currencies.
Definition: UintTypes.cpp:126
std::ostream & operator<<(std::ostream &out, base_uint< Bits, Tag > const &u)
Definition: base_uint.h:637
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition: UintTypes.h:56
Currency const & xrpCurrency()
XRP currency.
Definition: UintTypes.cpp:119
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.