Address Generator 2.1.2
Postal addresses with real streets by place, laid out in each country's format for C++23
Loading...
Searching...
No Matches
dasmig::address Class Reference

Return type for address generation. More...

#include <addressgen.hpp>

Public Member Functions

const std::vector< std::string > & lines () const
 The address lines in the country's order.
 
std::string formatted (std::string_view separator=", ") const
 The address on one line.
 
std::uint64_t seed () const
 Retrieve the random seed used to generate this address.
 
const core::seed_signature & signature () const
 The seed and the data this address was generated from.
 
std::string to_string () const
 Human-readable summary string.
 
void to_json (core::json_writer &w) const
 Write this address as a JSON object.
 
std::string to_json () const
 This address as a JSON document.
 
 operator std::string () const
 Implicit conversion to std::string.
 

Public Attributes

std::string country_code
 ISO 3166-1 alpha-2.
 
std::string city
 The place's name.
 
std::string region
 The region as the country writes it (an abbreviation in the US).
 
std::string street
 The street's name, with its type.
 
std::uint32_t number {0}
 House number; 0 when the street has none.
 
std::string unit
 Apartment or flat, empty when there is none.
 
std::string postcode
 In the country's format; empty where there are no postcodes.
 
bool real_street {false}
 True when the street comes from the place's own data, false when composed.
 
std::uint32_t geonameid {0}
 The place's GeoNames id (city-generator's); 0 for a place given by name only.
 

Friends

class adg
 
std::ostream & operator<< (std::ostream &os, const address &v)
 Stream the summary to an output stream.
 

Detailed Description

Return type for address generation.

Supports implicit conversion to std::string (the address on one line), streaming via operator<< and JSON output via to_json().

Definition at line 116 of file addressgen.hpp.

Member Function Documentation

◆ formatted()

std::string dasmig::address::formatted ( std::string_view  separator = ", ") const
inline

The address on one line.

Parameters
separatorPlaced between the lines.
Returns
The lines joined.

Definition at line 136 of file addressgen.hpp.

◆ lines()

const std::vector< std::string > & dasmig::address::lines ( ) const
inline

The address lines in the country's order.

Returns
One string per line, without the recipient lines.

Definition at line 131 of file addressgen.hpp.

◆ operator std::string()

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

Implicit conversion to std::string.

Returns
Summary string.

Definition at line 197 of file addressgen.hpp.

◆ seed()

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

Retrieve the random seed used to generate this address.

Returns
The call seed; pass it to get_address(request, seed) with the same request and data to replay this address.

Definition at line 150 of file addressgen.hpp.

◆ signature()

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

The seed and the data this address was generated from.

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

Definition at line 155 of file addressgen.hpp.

◆ to_json() [1/2]

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

This address as a JSON document.

Returns
Compact JSON.

Definition at line 188 of file addressgen.hpp.

◆ to_json() [2/2]

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

Write this address as a JSON object.

Parameters
wWriter positioned where a value is allowed.

Definition at line 166 of file addressgen.hpp.

◆ to_string()

std::string dasmig::address::to_string ( ) const
inline

Human-readable summary string.

Returns
The address on one line.

Definition at line 162 of file addressgen.hpp.

Friends And Related Symbol Documentation

◆ adg

friend class adg
friend

Definition at line 216 of file addressgen.hpp.

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const address &  v 
)
friend

Stream the summary to an output stream.

Parameters
osOutput stream.
vThe address to stream.
Returns
The stream.

Definition at line 206 of file addressgen.hpp.

Member Data Documentation

◆ city

std::string dasmig::address::city

The place's name.

Definition at line 120 of file addressgen.hpp.

◆ country_code

std::string dasmig::address::country_code

ISO 3166-1 alpha-2.

Definition at line 119 of file addressgen.hpp.

◆ geonameid

std::uint32_t dasmig::address::geonameid {0}

The place's GeoNames id (city-generator's); 0 for a place given by name only.

Definition at line 127 of file addressgen.hpp.

◆ number

std::uint32_t dasmig::address::number {0}

House number; 0 when the street has none.

Definition at line 123 of file addressgen.hpp.

◆ postcode

std::string dasmig::address::postcode

In the country's format; empty where there are no postcodes.

Definition at line 125 of file addressgen.hpp.

◆ real_street

bool dasmig::address::real_street {false}

True when the street comes from the place's own data, false when composed.

Definition at line 126 of file addressgen.hpp.

◆ region

std::string dasmig::address::region

The region as the country writes it (an abbreviation in the US).

Definition at line 121 of file addressgen.hpp.

◆ street

std::string dasmig::address::street

The street's name, with its type.

Definition at line 122 of file addressgen.hpp.

◆ unit

std::string dasmig::address::unit

Apartment or flat, empty when there is none.

Definition at line 124 of file addressgen.hpp.


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