Player12
An open source football management simulator
Loading...
Searching...
No Matches
number_format.h File Reference
#include <cstdint>
#include <optional>
#include <string>
#include <string_view>

Go to the source code of this file.

Classes

struct  NumberFormat::Locale
 Separators and money units of one language. More...
 
struct  NumberFormat::MoneyParse
 Result of parseMoney(): a value, or the reason it has none. More...
 

Namespaces

namespace  NumberFormat
 Numbers and money in the conventions of the current language.
 

Enumerations

enum class  NumberFormat::MoneyError : uint8_t {
  NumberFormat::NONE , NumberFormat::EMPTY , NumberFormat::INVALID , NumberFormat::AMBIGUOUS ,
  NumberFormat::TOO_LARGE
}
 Why a money text was refused. More...
 

Functions

const Locale & NumberFormat::current ()
 Conventions of the language loaded now.
 
std::string NumberFormat::grouped (int64_t value, const Locale &locale=current())
 Integer with grouping marks, e.g. "38,500" / "38.500".
 
std::string NumberFormat::decimal (double value, int digits, const Locale &locale=current())
 Fixed decimals with the decimal mark, e.g. "7.5" / "7,5".
 
std::string NumberFormat::money (int64_t amount, const Locale &locale=current())
 Compact money, e.g. "€12.4M", "€850K", "-€3.1M", "€ 1,5 mln".
 
std::string NumberFormat::moneyFull (int64_t amount, const Locale &locale=current())
 Full money, e.g. "€1,250,000" / "€ 1.250.000".
 
MoneyParse NumberFormat::parseMoney (std::string_view text, const Locale &locale=current())
 Reads a typed amount: "1,5M", "1.5M", "1.500.000", "1,500,000", "1500k", "€ 2,25 mln", "850 mila", "3 mld".
 
const char * NumberFormat::errorKey (MoneyError error)
 Language key explaining a parse error (nullptr for NONE).