Country Generator 3.3.2
Procedural country generation for C++23
Loading...
Searching...
No Matches
dasmig::country Class Reference

Return type for country generation, holding all data fields. More...

#include <countrygen.hpp>

Public Member Functions

std::vector< std::string > language_list () const
 The language names of languages as a list.
 
std::vector< language_share > language_distribution () const
 The languages and the share of the population that speaks each.
 
std::string primary_language () const
 The language most of the population speaks.
 
const std::string & demonym (sex bio_sex) const
 The English demonym for a person of this country.
 
std::uint64_t seed () const
 Retrieve the random seed used to generate this country.
 
const core::seed_signature & signature () const
 The seed and the data this country was drawn from.
 
void to_json (core::json_writer &w) const
 Write this country as a JSON object.
 
std::string to_json () const
 This country as a JSON document.
 
 operator std::string () const
 Implicit conversion to std::string.
 

Public Attributes

std::string cca2
 ISO 3166-1 alpha-2 code (e.g. "BR").
 
std::string cca3
 ISO 3166-1 alpha-3 code (e.g. "BRA").
 
std::string ccn3
 ISO 3166-1 numeric code (e.g. "076").
 
std::string name_common
 Common English name (e.g. "Brazil").
 
std::string name_official
 Official English name (e.g. "Federative Republic of Brazil").
 
std::string capital
 Capital city (semicolon-separated if multiple).
 
std::string region
 UN geoscheme region (e.g. "Americas").
 
std::string subregion
 UN geoscheme subregion (e.g. "South America").
 
std::string continent
 Continent (semicolon-separated if multiple).
 
double latitude {0.0}
 WGS84 latitude in decimal degrees.
 
double longitude {0.0}
 WGS84 longitude in decimal degrees.
 
std::uint64_t area {0}
 Total land area in km².
 
std::uint64_t population {0}
 Total population.
 
bool landlocked {false}
 Whether the country is landlocked.
 
bool independent {false}
 Whether the country is an independent sovereign state.
 
bool un_member {false}
 Whether the country is a UN member.
 
std::string languages
 Semicolon-separated language names (e.g. "Portuguese").
 
std::string language_shares
 Semicolon-separated Name:percent pairs, largest first, for the languages at least 1% of the population speaks (for example "Portuguese:91;English:8"); empty when the data has none.
 
std::string currency_code
 Primary ISO 4217 currency code (e.g. "BRL").
 
std::string currency_name
 Primary currency name (e.g. "Brazilian real").
 
std::string currency_symbol
 Primary currency symbol (e.g. "R$").
 
std::string borders
 Semicolon-separated ISO alpha-3 border codes.
 
std::string timezones
 Semicolon-separated UTC offset strings.
 
std::string driving_side
 Driving side: "right" or "left".
 
std::string tld
 Country-code top-level domain (e.g. ".br").
 
std::string idd_root
 IDD root (e.g. "+5").
 
std::string idd_suffix
 IDD primary suffix (e.g. "5").
 
std::string demonym_m
 English male demonym (e.g. "Brazilian").
 
std::string demonym_f
 English female demonym (e.g. "Brazilian").
 
std::string flag_emoji
 Unicode flag emoji.
 
std::string income_level
 World Bank income level (e.g. "Upper middle income").
 
std::string start_of_week
 Start of the week: "monday", "sunday", or "saturday".
 

Friends

class cntg
 
std::ostream & operator<< (std::ostream &os, const country &c)
 Stream the common name to an output stream.
 

Detailed Description

Return type for country generation, holding all data fields.

Supports implicit conversion to std::string (returns the common name), streaming via operator<< and JSON output via to_json().

Definition at line 58 of file countrygen.hpp.

Member Function Documentation

◆ demonym()

const std::string & dasmig::country::demonym ( sex  bio_sex) const
inline

The English demonym for a person of this country.

Parameters
bio_sexThe person's sex.
Returns
demonym_m or demonym_f, falling back to the other when empty.

Definition at line 213 of file countrygen.hpp.

◆ language_distribution()

std::vector< language_share > dasmig::country::language_distribution ( ) const
inline

The languages and the share of the population that speaks each.

Returns
language_shares parsed, largest first; empty when the data has none.

Definition at line 195 of file countrygen.hpp.

◆ language_list()

std::vector< std::string > dasmig::country::language_list ( ) const
inline

The language names of languages as a list.

Returns
The official languages in the data's order; empty when none.

Definition at line 180 of file countrygen.hpp.

◆ operator std::string()

dasmig::country::operator std::string ( ) const
inline

Implicit conversion to std::string.

Returns
The common English name.

Definition at line 307 of file countrygen.hpp.

◆ primary_language()

std::string dasmig::country::primary_language ( ) const
inline

The language most of the population speaks.

Returns
The largest share's name, else the first of languages, else empty.

Definition at line 202 of file countrygen.hpp.

◆ seed()

std::uint64_t dasmig::country::seed ( ) const
inline

Retrieve the random seed used to generate this country.

Returns
The per-call seed for replay (0 for find_country()).
See also
cntg::get_country(const country_request&, std::uint64_t) const

Definition at line 224 of file countrygen.hpp.

◆ signature()

const core::seed_signature & dasmig::country::signature ( ) const
inline

The seed and the data this country was drawn from.

Returns
The replay signature; data is cntg::data_hash() at the time of generation.

Definition at line 232 of file countrygen.hpp.

◆ to_json() [1/2]

std::string dasmig::country::to_json ( ) const
inline

This country as a JSON document.

Returns
Compact JSON.

Definition at line 298 of file countrygen.hpp.

◆ to_json() [2/2]

void dasmig::country::to_json ( core::json_writer &  w) const
inline

Write this country as a JSON object.

Semicolon-separated fields (capital, continent, languages, borders, timezones) are written as arrays.

Parameters
wWriter positioned where a value is allowed.

Definition at line 243 of file countrygen.hpp.

Friends And Related Symbol Documentation

◆ cntg

friend class cntg
friend

Definition at line 357 of file countrygen.hpp.

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const country &  c 
)
friend

Stream the common name to an output stream.

Parameters
osOutput stream.
cCountry to stream.
Returns
The stream.

Definition at line 316 of file countrygen.hpp.

Member Data Documentation

◆ area

std::uint64_t dasmig::country::area {0}

Total land area in km².

Definition at line 99 of file countrygen.hpp.

◆ borders

std::string dasmig::country::borders

Semicolon-separated ISO alpha-3 border codes.

Definition at line 140 of file countrygen.hpp.

◆ capital

std::string dasmig::country::capital

Capital city (semicolon-separated if multiple).

Definition at line 79 of file countrygen.hpp.

◆ cca2

std::string dasmig::country::cca2

ISO 3166-1 alpha-2 code (e.g. "BR").

Definition at line 64 of file countrygen.hpp.

◆ cca3

std::string dasmig::country::cca3

ISO 3166-1 alpha-3 code (e.g. "BRA").

Definition at line 67 of file countrygen.hpp.

◆ ccn3

std::string dasmig::country::ccn3

ISO 3166-1 numeric code (e.g. "076").

Definition at line 70 of file countrygen.hpp.

◆ continent

std::string dasmig::country::continent

Continent (semicolon-separated if multiple).

Definition at line 90 of file countrygen.hpp.

◆ currency_code

std::string dasmig::country::currency_code

Primary ISO 4217 currency code (e.g. "BRL").

Definition at line 129 of file countrygen.hpp.

◆ currency_name

std::string dasmig::country::currency_name

Primary currency name (e.g. "Brazilian real").

Definition at line 132 of file countrygen.hpp.

◆ currency_symbol

std::string dasmig::country::currency_symbol

Primary currency symbol (e.g. "R$").

Definition at line 135 of file countrygen.hpp.

◆ demonym_f

std::string dasmig::country::demonym_f

English female demonym (e.g. "Brazilian").

Definition at line 165 of file countrygen.hpp.

◆ demonym_m

std::string dasmig::country::demonym_m

English male demonym (e.g. "Brazilian").

Definition at line 162 of file countrygen.hpp.

◆ driving_side

std::string dasmig::country::driving_side

Driving side: "right" or "left".

Definition at line 146 of file countrygen.hpp.

◆ flag_emoji

std::string dasmig::country::flag_emoji

Unicode flag emoji.

Definition at line 168 of file countrygen.hpp.

◆ idd_root

std::string dasmig::country::idd_root

IDD root (e.g. "+5").

Definition at line 154 of file countrygen.hpp.

◆ idd_suffix

std::string dasmig::country::idd_suffix

IDD primary suffix (e.g. "5").

Definition at line 157 of file countrygen.hpp.

◆ income_level

std::string dasmig::country::income_level

World Bank income level (e.g. "Upper middle income").

Definition at line 171 of file countrygen.hpp.

◆ independent

bool dasmig::country::independent {false}

Whether the country is an independent sovereign state.

Definition at line 110 of file countrygen.hpp.

◆ landlocked

bool dasmig::country::landlocked {false}

Whether the country is landlocked.

Definition at line 105 of file countrygen.hpp.

◆ language_shares

std::string dasmig::country::language_shares

Semicolon-separated Name:percent pairs, largest first, for the languages at least 1% of the population speaks (for example "Portuguese:91;English:8"); empty when the data has none.

Each percent is the share of people who speak that language, so they overlap and can sum above 100. Use language_distribution() to read them.

Definition at line 126 of file countrygen.hpp.

◆ languages

std::string dasmig::country::languages

Semicolon-separated language names (e.g. "Portuguese").

Definition at line 118 of file countrygen.hpp.

◆ latitude

double dasmig::country::latitude {0.0}

WGS84 latitude in decimal degrees.

Definition at line 93 of file countrygen.hpp.

◆ longitude

double dasmig::country::longitude {0.0}

WGS84 longitude in decimal degrees.

Definition at line 96 of file countrygen.hpp.

◆ name_common

std::string dasmig::country::name_common

Common English name (e.g. "Brazil").

Definition at line 73 of file countrygen.hpp.

◆ name_official

std::string dasmig::country::name_official

Official English name (e.g. "Federative Republic of Brazil").

Definition at line 76 of file countrygen.hpp.

◆ population

std::uint64_t dasmig::country::population {0}

Total population.

Definition at line 102 of file countrygen.hpp.

◆ region

std::string dasmig::country::region

UN geoscheme region (e.g. "Americas").

Definition at line 84 of file countrygen.hpp.

◆ start_of_week

std::string dasmig::country::start_of_week

Start of the week: "monday", "sunday", or "saturday".

Definition at line 174 of file countrygen.hpp.

◆ subregion

std::string dasmig::country::subregion

UN geoscheme subregion (e.g. "South America").

Definition at line 87 of file countrygen.hpp.

◆ timezones

std::string dasmig::country::timezones

Semicolon-separated UTC offset strings.

Definition at line 143 of file countrygen.hpp.

◆ tld

std::string dasmig::country::tld

Country-code top-level domain (e.g. ".br").

Definition at line 151 of file countrygen.hpp.

◆ un_member

bool dasmig::country::un_member {false}

Whether the country is a UN member.

Definition at line 113 of file countrygen.hpp.


The documentation for this class was generated from the following file: