Player12
An open source football management simulator
Loading...
Searching...
No Matches
number_format.cpp File Reference
#include "global/number_format.h"
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <format>
#include <string_view>
#include <vector>
#include "global/language_manager.h"

Namespaces

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

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).
 

Variable Documentation

◆ decimal_mark

std::optional<size_t> decimal_mark

◆ marks

std::vector<char> marks

◆ runs

std::vector<std::string> runs {1}