diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-01-21 22:30:58 +0200 |
---|---|---|
committer | William Casarin <jb55@jb55.com> | 2022-02-22 13:50:30 -0800 |
commit | ffbc2fe459034024cb2fce9fd94bff457b7a7d49 (patch) | |
tree | 065f63f8b182009b4b9ded50a745fc423cd8b017 /src/qt | |
parent | 152d5bad50f145af922011f6ec1fd9afd9076ceb (diff) | |
download | bitcoin-ffbc2fe459034024cb2fce9fd94bff457b7a7d49.tar.xz |
qt, refactor: Remove default cases for scoped enum
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/bitcoinunits.cpp | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp index 94722ee9f6..fe3eb3240b 100644 --- a/src/qt/bitcoinunits.cpp +++ b/src/qt/bitcoinunits.cpp @@ -30,60 +30,57 @@ QList<BitcoinUnit> BitcoinUnits::availableUnits() QString BitcoinUnits::longName(Unit unit) { - switch(unit) - { + switch (unit) { case Unit::BTC: return QString("BTC"); case Unit::mBTC: return QString("mBTC"); case Unit::uBTC: return QString::fromUtf8("µBTC (bits)"); case Unit::SAT: return QString("Satoshi (sat)"); - default: return QString("???"); - } + } // no default case, so the compiler can warn about missing cases + assert(false); } QString BitcoinUnits::shortName(Unit unit) { - switch(unit) - { - case Unit::uBTC: return QString::fromUtf8("bits"); + switch (unit) { + case Unit::BTC: return longName(unit); + case Unit::mBTC: return longName(unit); + case Unit::uBTC: return QString("bits"); case Unit::SAT: return QString("sat"); - default: return longName(unit); - } + } // no default case, so the compiler can warn about missing cases + assert(false); } QString BitcoinUnits::description(Unit unit) { - switch(unit) - { + switch (unit) { case Unit::BTC: return QString("Bitcoins"); case Unit::mBTC: return QString("Milli-Bitcoins (1 / 1" THIN_SP_UTF8 "000)"); case Unit::uBTC: return QString("Micro-Bitcoins (bits) (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)"); case Unit::SAT: return QString("Satoshi (sat) (1 / 100" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)"); - default: return QString("???"); - } + } // no default case, so the compiler can warn about missing cases + assert(false); } qint64 BitcoinUnits::factor(Unit unit) { - switch(unit) - { + switch (unit) { case Unit::BTC: return 100'000'000; case Unit::mBTC: return 100'000; case Unit::uBTC: return 100; case Unit::SAT: return 1; - default: return 100'000'000; - } + } // no default case, so the compiler can warn about missing cases + assert(false); } int BitcoinUnits::decimals(Unit unit) { - switch(unit) - { + switch (unit) { case Unit::BTC: return 8; case Unit::mBTC: return 5; case Unit::uBTC: return 2; case Unit::SAT: return 0; - default: return 0; - } + } // no default case, so the compiler can warn about missing cases + assert(false); } QString BitcoinUnits::format(Unit unit, const CAmount& nIn, bool fPlus, SeparatorStyle separators, bool justify) |