Changeset View
Changeset View
Standalone View
Standalone View
src/amount.h
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Copyright (c) 2017-2019 The Bitcoin developers | // Copyright (c) 2017-2019 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_AMOUNT_H | #ifndef BITCOIN_AMOUNT_H | ||||
#define BITCOIN_AMOUNT_H | #define BITCOIN_AMOUNT_H | ||||
#include <serialize.h> | #include <serialize.h> | ||||
#include <cstdlib> | #include <cstdlib> | ||||
#include <ostream> | #include <ostream> | ||||
#include <string> | #include <string> | ||||
#include <type_traits> | #include <type_traits> | ||||
class UniValue; | |||||
struct Amount { | struct Amount { | ||||
private: | private: | ||||
int64_t amount; | int64_t amount; | ||||
explicit constexpr Amount(int64_t _amount) : amount(_amount) {} | explicit constexpr Amount(int64_t _amount) : amount(_amount) {} | ||||
public: | public: | ||||
constexpr Amount() : amount(0) {} | constexpr Amount() : amount(0) {} | ||||
constexpr Amount(const Amount &other) : amount(other.amount) {} | constexpr Amount(const Amount &other) : amount(other.amount) {} | ||||
/** | /** | ||||
* Convenient implicit UniValue conversion operator | |||||
*/ | |||||
operator UniValue() const; | |||||
/** | |||||
* Assignement operator. | * Assignement operator. | ||||
*/ | */ | ||||
constexpr Amount &operator=(const Amount &other) { | constexpr Amount &operator=(const Amount &other) { | ||||
amount = other.amount; | amount = other.amount; | ||||
return *this; | return *this; | ||||
} | } | ||||
static constexpr Amount zero() { return Amount(0); } | static constexpr Amount zero() { return Amount(0); } | ||||
▲ Show 20 Lines • Show All 130 Lines • Show Last 20 Lines |