![]() |
Country Generator 3.3.2
Procedural country generation for C++23
|
A locale of a country: its tag, CLDR formats and calendar data. More...
#include <countrygen.hpp>
Public Member Functions | |
| std::string | format_date (std::chrono::year_month_day d, date_style style=date_style::short_) const |
| Write a date with one of the locale's date patterns. | |
| std::string | format_time (std::chrono::hh_mm_ss< std::chrono::seconds > t, time_style style=time_style::short_) const |
| Write a time of day with one of the locale's time patterns. | |
| std::string | format_number (double value, unsigned max_fraction=3) const |
| Write a number with the locale's decimal pattern. | |
| std::string | format_money (const core::money &m) const |
| Write an amount with the locale's currency pattern. | |
| std::uint64_t | seed () const |
| The seed this locale was drawn with. | |
| const core::seed_signature & | signature () const |
| The seed and the data this locale was drawn from. | |
| void | to_json (core::json_writer &w) const |
| Write this locale as a JSON object (doc/usage.md, "Locales"). | |
| std::string | to_json () const |
| This locale as a JSON document. | |
| operator std::string () const | |
| Implicit conversion to std::string. | |
Public Attributes | |
| std::string | tag |
| BCP 47, minimised: "pt-BR", "zh-TW", "sr-Latn-RS". | |
| std::string | language |
| ISO 639 code: "pt". | |
| std::string | script |
| ISO 15924 code when the tag needs one ("Latn"); else empty. | |
| std::string | language_name |
| English, as country::language_shares writes it: "Portuguese". | |
| std::string | country_code |
| ISO 3166-1 alpha-2: "BR". | |
| double | share {0.0} |
| Percent of the country that speaks the language (CLDR). | |
| std::string | basis |
| "cldr", "inherited" or "fallback" (doc/data.md). | |
| std::string | date_short |
| LDML short date pattern: "dd/MM/y". | |
| std::string | date_medium |
| LDML medium date pattern. | |
| std::string | date_long |
| LDML long date pattern. | |
| std::string | date_full |
| LDML full date pattern. | |
| std::string | time_short |
| LDML short time pattern: "HH:mm". | |
| std::string | time_medium |
| LDML medium time pattern: "HH:mm:ss". | |
| std::array< std::string, 12 > | months {} |
| Wide month names, format context, January first. | |
| std::array< std::string, 12 > | months_abbr {} |
| Abbreviated month names. | |
| std::array< std::string, 7 > | weekdays {} |
| Wide weekday names, format context, Sunday first. | |
| std::array< std::string, 7 > | weekdays_abbr {} |
| Abbreviated weekday names, Sunday first. | |
| std::string | am |
| Day period before noon. | |
| std::string | pm |
| Day period after noon. | |
| std::array< std::string, 2 > | eras {} |
| Abbreviated eras: BC, AD. | |
| std::string | decimal |
| Decimal symbol: ",". | |
| std::string | group |
| Grouping symbol: ".". | |
| std::string | minus |
| Minus sign: "-". | |
| std::string | number_pattern |
| CLDR decimal pattern: "#,##0.###". | |
| std::string | currency_pattern |
| CLDR currency pattern: "¤ #,##0.00". | |
| std::string | currency_spacing |
| Put between a letter symbol and the number; usually U+00A0. | |
| std::string | currency_code |
| The country's ISO 4217 code: "BRL". | |
| std::string | currency_symbol |
| This locale's symbol for it: "R$". | |
| std::uint8_t | currency_digits {2} |
| Its ISO 4217 minor unit. | |
| std::chrono::weekday | first_day {std::chrono::Monday} |
| First day of the week. | |
| std::chrono::weekday | weekend_start {std::chrono::Saturday} |
| First day of the weekend. | |
| std::chrono::weekday | weekend_end {std::chrono::Sunday} |
| Last day of the weekend. | |
| dasmig::measurement | measurement {dasmig::measurement::metric} |
| Measurement system. | |
Friends | |
| class | cntg |
| std::ostream & | operator<< (std::ostream &os, const locale &l) |
| Stream the tag. | |
A locale of a country: its tag, CLDR formats and calendar data.
Every row is complete: the build resolved CLDR's inheritance, so the formatting functions read only these fields.
Definition at line 1214 of file countrygen.hpp.
|
inline |
Write a date with one of the locale's date patterns.
| d | The date. |
| style | Which pattern. |
| std::invalid_argument | If d is not a valid date, or the pattern holds a field the formatter does not write. |
Definition at line 1261 of file countrygen.hpp.
|
inline |
Write an amount with the locale's currency pattern.
Exactly m.digits fraction digits, from the integer minor units, so nothing is rounded. The symbol is the locale's own for its currency and the ISO code for any other; CLDR's currency spacing puts currency_spacing between a symbol that ends (or starts) with a letter and the number: CHF 1,234.50 but $1,234.50 in en-US.
| m | The amount. |
| std::invalid_argument | If the pattern is not one the formatter writes. |
Definition at line 1357 of file countrygen.hpp.
|
inline |
Write a number with the locale's decimal pattern.
The value's shortest round-trip digits are rounded half-even, as text, to at most max_fraction fraction digits (and the pattern's maximum), so 2.675 at two digits is 2.68 on every platform.
| value | The number. |
| max_fraction | Most fraction digits. |
| std::invalid_argument | If value is not finite or the pattern is not one the formatter writes. |
Definition at line 1332 of file countrygen.hpp.
|
inline |
Write a time of day with one of the locale's time patterns.
| t | The time (0 to 24 hours). |
| style | Which pattern. |
| std::invalid_argument | If t is negative or 24 hours or more, or the pattern holds a field the formatter does not write. |
Definition at line 1297 of file countrygen.hpp.
|
inline |
|
inline |
The seed this locale was drawn with.
Definition at line 1371 of file countrygen.hpp.
|
inline |
The seed and the data this locale was drawn from.
Definition at line 1375 of file countrygen.hpp.
|
inline |
This locale as a JSON document.
Definition at line 1436 of file countrygen.hpp.
|
inline |
Write this locale as a JSON object (doc/usage.md, "Locales").
The month, weekday, era and day-period names are left out: they are data, reachable through cntg::find_locale().
| w | Writer positioned where a value is allowed. |
Definition at line 1383 of file countrygen.hpp.
|
friend |
Definition at line 1550 of file countrygen.hpp.
|
friend |
Stream the tag.
| os | Output stream. |
| l | Locale to stream. |
Definition at line 1454 of file countrygen.hpp.
| std::string dasmig::locale::am |
Day period before noon.
Definition at line 1235 of file countrygen.hpp.
| std::string dasmig::locale::basis |
"cldr", "inherited" or "fallback" (doc/data.md).
Definition at line 1223 of file countrygen.hpp.
| std::string dasmig::locale::country_code |
ISO 3166-1 alpha-2: "BR".
Definition at line 1221 of file countrygen.hpp.
| std::string dasmig::locale::currency_code |
The country's ISO 4217 code: "BRL".
Definition at line 1245 of file countrygen.hpp.
| std::uint8_t dasmig::locale::currency_digits {2} |
Its ISO 4217 minor unit.
Definition at line 1247 of file countrygen.hpp.
| std::string dasmig::locale::currency_pattern |
CLDR currency pattern: "¤ #,##0.00".
Definition at line 1243 of file countrygen.hpp.
| std::string dasmig::locale::currency_spacing |
Put between a letter symbol and the number; usually U+00A0.
Definition at line 1244 of file countrygen.hpp.
| std::string dasmig::locale::currency_symbol |
This locale's symbol for it: "R$".
Definition at line 1246 of file countrygen.hpp.
| std::string dasmig::locale::date_full |
LDML full date pattern.
Definition at line 1228 of file countrygen.hpp.
| std::string dasmig::locale::date_long |
LDML long date pattern.
Definition at line 1227 of file countrygen.hpp.
| std::string dasmig::locale::date_medium |
LDML medium date pattern.
Definition at line 1226 of file countrygen.hpp.
| std::string dasmig::locale::date_short |
LDML short date pattern: "dd/MM/y".
Definition at line 1225 of file countrygen.hpp.
| std::string dasmig::locale::decimal |
Decimal symbol: ",".
Definition at line 1239 of file countrygen.hpp.
| std::array<std::string, 2> dasmig::locale::eras {} |
Abbreviated eras: BC, AD.
Definition at line 1237 of file countrygen.hpp.
| std::chrono::weekday dasmig::locale::first_day {std::chrono::Monday} |
First day of the week.
Definition at line 1249 of file countrygen.hpp.
| std::string dasmig::locale::group |
Grouping symbol: ".".
Definition at line 1240 of file countrygen.hpp.
| std::string dasmig::locale::language |
ISO 639 code: "pt".
Definition at line 1218 of file countrygen.hpp.
| std::string dasmig::locale::language_name |
English, as country::language_shares writes it: "Portuguese".
Definition at line 1220 of file countrygen.hpp.
| dasmig::measurement dasmig::locale::measurement {dasmig::measurement::metric} |
Measurement system.
Definition at line 1252 of file countrygen.hpp.
| std::string dasmig::locale::minus |
Minus sign: "-".
Definition at line 1241 of file countrygen.hpp.
| std::array<std::string, 12> dasmig::locale::months {} |
Wide month names, format context, January first.
Definition at line 1231 of file countrygen.hpp.
| std::array<std::string, 12> dasmig::locale::months_abbr {} |
Abbreviated month names.
Definition at line 1232 of file countrygen.hpp.
| std::string dasmig::locale::number_pattern |
CLDR decimal pattern: "#,##0.###".
Definition at line 1242 of file countrygen.hpp.
| std::string dasmig::locale::pm |
Day period after noon.
Definition at line 1236 of file countrygen.hpp.
| std::string dasmig::locale::script |
ISO 15924 code when the tag needs one ("Latn"); else empty.
Definition at line 1219 of file countrygen.hpp.
| double dasmig::locale::share {0.0} |
Percent of the country that speaks the language (CLDR).
Definition at line 1222 of file countrygen.hpp.
| std::string dasmig::locale::tag |
BCP 47, minimised: "pt-BR", "zh-TW", "sr-Latn-RS".
Definition at line 1217 of file countrygen.hpp.
| std::string dasmig::locale::time_medium |
LDML medium time pattern: "HH:mm:ss".
Definition at line 1230 of file countrygen.hpp.
| std::string dasmig::locale::time_short |
LDML short time pattern: "HH:mm".
Definition at line 1229 of file countrygen.hpp.
| std::array<std::string, 7> dasmig::locale::weekdays {} |
Wide weekday names, format context, Sunday first.
Definition at line 1233 of file countrygen.hpp.
| std::array<std::string, 7> dasmig::locale::weekdays_abbr {} |
Abbreviated weekday names, Sunday first.
Definition at line 1234 of file countrygen.hpp.
| std::chrono::weekday dasmig::locale::weekend_end {std::chrono::Sunday} |
Last day of the weekend.
Definition at line 1251 of file countrygen.hpp.
| std::chrono::weekday dasmig::locale::weekend_start {std::chrono::Saturday} |
First day of the weekend.
Definition at line 1250 of file countrygen.hpp.