Faker C++
Loading...
Searching...
No Matches
faker::location Namespace Reference

Functions

FAKER_CXX_EXPORT std::string_view country ()
 Returns a random country name.
 
FAKER_CXX_EXPORT std::string_view countryCode ()
 Returns a random country code.
 
FAKER_CXX_EXPORT std::string_view state (Locale locale=Locale::en_US)
 Returns a random state for a given locale.
 
FAKER_CXX_EXPORT std::string city (Locale locale=Locale::en_US)
 Returns a random city for given locale.
 
FAKER_CXX_EXPORT std::string zipCode (Locale locale=Locale::en_US)
 Returns a random zip code for given locale.
 
FAKER_CXX_EXPORT std::string streetAddress (Locale locale=Locale::en_US)
 Returns a random street address for given locale.
 
FAKER_CXX_EXPORT std::string street (Locale locale=Locale::en_US)
 Returns a random street for given locale.
 
FAKER_CXX_EXPORT std::string buildingNumber (Locale locale=Locale::en_US)
 Returns a random building number for given locale.
 
FAKER_CXX_EXPORT std::string secondaryAddress (Locale locale=Locale::en_US)
 Returns a random secondary address number for given locale. This refers to a specific location at a given address such as an apartment or room number.
 
FAKER_CXX_EXPORT std::string latitude (Precision precision=Precision::FourDp)
 Generates a random latitude.
 
FAKER_CXX_EXPORT std::string longitude (Precision precision=Precision::FourDp)
 Generates a random longitude.
 
FAKER_CXX_EXPORT std::tuple< std::string, std::string > nearbyGPSCoordinate (Precision precision=Precision::FourDp, const std::tuple< double, double > &origin={ std::numeric_limits< double >::max(), std::numeric_limits< double >::max() }, double radius=10, bool isMetric=false)
 Generates a random GPS coordinate within the specified radius from the given coordinate.
 
FAKER_CXX_EXPORT std::string_view direction ()
 Generates a random direction from cardinal and ordinal directions.
 
FAKER_CXX_EXPORT std::string_view timeZone ()
 Generates a random time zone.
 

Function Documentation

◆ buildingNumber()

FAKER_CXX_EXPORT std::string faker::location::buildingNumber ( Locale locale = Locale::en_US)

Returns a random building number for given locale.

Parameters
localeThe locale. Defaults to `Locale::en_US`.
Returns
Building number.
FAKER_CXX_EXPORT std::string buildingNumber(Locale locale=Locale::en_US)
Returns a random building number for given locale.

◆ city()

FAKER_CXX_EXPORT std::string faker::location::city ( Locale locale = Locale::en_US)

Returns a random city for given locale.

Parameters
localeThe locale. Defaults to `Locale::en_US`.
Returns
City.
faker::location::city() // "Boston"
FAKER_CXX_EXPORT std::string city(Locale locale=Locale::en_US)
Returns a random city for given locale.

◆ country()

FAKER_CXX_EXPORT std::string_view faker::location::country ( )

Returns a random country name.

Returns
Country name.
FAKER_CXX_EXPORT std::string_view country()
Returns a random country name.

◆ countryCode()

FAKER_CXX_EXPORT std::string_view faker::location::countryCode ( )

Returns a random country code.

Returns
Country code consisting two letters.
FAKER_CXX_EXPORT std::string_view countryCode()
Returns a random country code.

◆ direction()

FAKER_CXX_EXPORT std::string_view faker::location::direction ( )

Generates a random direction from cardinal and ordinal directions.

Returns
Direction.
FAKER_CXX_EXPORT std::string_view direction()
Generates a random direction from cardinal and ordinal directions.

◆ latitude()

FAKER_CXX_EXPORT std::string faker::location::latitude ( Precision precision = Precision::FourDp)

Generates a random latitude.

Parameters
precisionThe number of decimal points of precision for the latitude. Defaults to `Precision::FourDp`.
Returns
Latitude within -90 to 90 range.
FAKER_CXX_EXPORT std::string latitude(Precision precision=Precision::FourDp)
Generates a random latitude.

◆ longitude()

FAKER_CXX_EXPORT std::string faker::location::longitude ( Precision precision = Precision::FourDp)

Generates a random longitude.

Parameters
precisionThe number of decimal points of precision for the longitude. Defaults to `Precision::FourDp`.
Returns
Longitude within -180 to 180 range.
FAKER_CXX_EXPORT std::string longitude(Precision precision=Precision::FourDp)
Generates a random longitude.

◆ nearbyGPSCoordinate()

FAKER_CXX_EXPORT std::tuple< std::string, std::string > faker::location::nearbyGPSCoordinate ( Precision precision = Precision::FourDp,
const std::tuple< double, double > & origin = { std::numeric_limits< double >::max(), std::numeric_limits< double >::max() },
double radius = 10,
bool isMetric = false )

Generates a random GPS coordinate within the specified radius from the given coordinate.

Parameters
precisionThe number of decimal points of precision for the latitude and longitude. Defaults to `Precision::FourDp`.
originThe origin GPS coordinate. Defaults to a random GPS coordinate.
radiusThe radius in kilometers or miles. Defaults to 10.
isMetricThe unit of radius. Defaults to false which means miles.
Returns
GPS coordinate within the specified radius from the given coordinate.
faker::location::nearbyGPSCoordinate() // "48.8566", "2.3522"
faker::location::nearbyGPSCoordinate(Precision::FourDp, {33, -170}) // "33.0165", "-170.0636"
faker::location::nearbyGPSCoordinate(Precision::FourDp, {33, -170}, 1000, true) // "37.9163", "-179.2408"
FAKER_CXX_EXPORT std::tuple< std::string, std::string > nearbyGPSCoordinate(Precision precision=Precision::FourDp, const std::tuple< double, double > &origin={ std::numeric_limits< double >::max(), std::numeric_limits< double >::max() }, double radius=10, bool isMetric=false)
Generates a random GPS coordinate within the specified radius from the given coordinate.
Definition airline.h:9

◆ secondaryAddress()

FAKER_CXX_EXPORT std::string faker::location::secondaryAddress ( Locale locale = Locale::en_US)

Returns a random secondary address number for given locale. This refers to a specific location at a given address such as an apartment or room number.

Parameters
localeThe locale. Defaults to `Locale::en_US`.
Returns
Secondary address.
FAKER_CXX_EXPORT std::string secondaryAddress(Locale locale=Locale::en_US)
Returns a random secondary address number for given locale. This refers to a specific location at a g...

◆ state()

FAKER_CXX_EXPORT std::string_view faker::location::state ( Locale locale = Locale::en_US)

Returns a random state for a given locale.

Parameters
localeThe locale. Defaults to `Locale::en_US`.
Returns
State.
faker::location::state() // "Arizona"
FAKER_CXX_EXPORT std::string_view state(Locale locale=Locale::en_US)
Returns a random state for a given locale.

◆ street()

FAKER_CXX_EXPORT std::string faker::location::street ( Locale locale = Locale::en_US)

Returns a random street for given locale.

Parameters
localeThe locale. Defaults to `Locale::en_US`.
Returns
Street name.
faker::location::street() // "Schroeder Isle"
FAKER_CXX_EXPORT std::string street(Locale locale=Locale::en_US)
Returns a random street for given locale.

◆ streetAddress()

FAKER_CXX_EXPORT std::string faker::location::streetAddress ( Locale locale = Locale::en_US)

Returns a random street address for given locale.

Parameters
localeThe locale. Defaults to `Locale::en_US`.
Returns
Street address including building number and street name.
faker::location::streetAddress() // "34830 Erdman Hollow"
FAKER_CXX_EXPORT std::string streetAddress(Locale locale=Locale::en_US)
Returns a random street address for given locale.

◆ timeZone()

FAKER_CXX_EXPORT std::string_view faker::location::timeZone ( )

Generates a random time zone.

Returns
Time zone.
faker::location::timeZone() // "Europe/Warsaw"
FAKER_CXX_EXPORT std::string_view timeZone()
Generates a random time zone.

◆ zipCode()

FAKER_CXX_EXPORT std::string faker::location::zipCode ( Locale locale = Locale::en_US)

Returns a random zip code for given locale.

Parameters
localeThe locale. Defaults to `Locale::en_US`.
Returns
Zip code.
faker::location::zipCode() // "47683-9880"
faker::location::zipCode(Country::Poland) // "31-881"
FAKER_CXX_EXPORT std::string zipCode(Locale locale=Locale::en_US)
Returns a random zip code for given locale.