Phone Generator 2.1.1
Phone numbers valid in each country's numbering plan for C++23
Loading...
Searching...
No Matches
dasmig::phone Class Reference

Return type for phone number generation. More...

#include <phonegen.hpp>

Public Member Functions

std::string e164 () const
 The number in E.164.
 
std::string international () const
 The number as written for international dialling.
 
std::string national () const
 The number as written inside its country.
 
std::string rfc3966 () const
 The number as an RFC 3966 URI.
 
std::uint64_t seed () const
 Retrieve the random seed used to generate this phone number.
 
const core::seed_signature & signature () const
 The seed and the data this number was generated from.
 
std::string to_string () const
 Human-readable summary string.
 
void to_json (core::json_writer &w) const
 Write this number as a JSON object.
 
std::string to_json () const
 This number as a JSON document.
 
 operator std::string () const
 Implicit conversion to std::string.
 

Public Attributes

std::string country_code
 ISO 3166-1 alpha-2 of the region the number belongs to.
 
std::string calling_code
 Calling code without the plus sign ("55").
 
std::string national_number
 The digits after the calling code, without a national prefix.
 
phone_type type {phone_type::mobile}
 Mobile or fixed line.
 
bool reserved {false}
 True when the number comes from a range set aside for fiction.
 

Friends

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

Detailed Description

Return type for phone number generation.

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

Definition at line 82 of file phonegen.hpp.

Member Function Documentation

◆ e164()

std::string dasmig::phone::e164 ( ) const
inline

The number in E.164.

Returns
For example +5511987654321.

Definition at line 93 of file phonegen.hpp.

◆ international()

std::string dasmig::phone::international ( ) const
inline

The number as written for international dialling.

Returns
For example +55 11 98765-4321.

Definition at line 97 of file phonegen.hpp.

◆ national()

std::string dasmig::phone::national ( ) const
inline

The number as written inside its country.

Returns
For example (11) 98765-4321; with the national prefix where the country dials one.

Definition at line 106 of file phonegen.hpp.

◆ operator std::string()

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

Implicit conversion to std::string.

Returns
Summary string.

Definition at line 173 of file phonegen.hpp.

◆ rfc3966()

std::string dasmig::phone::rfc3966 ( ) const
inline

The number as an RFC 3966 URI.

Returns
For example tel:+55-11-98765-4321.

Definition at line 110 of file phonegen.hpp.

◆ seed()

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

Retrieve the random seed used to generate this phone number.

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

Definition at line 134 of file phonegen.hpp.

◆ signature()

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

The seed and the data this number was generated from.

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

Definition at line 139 of file phonegen.hpp.

◆ to_json() [1/2]

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

This number as a JSON document.

Returns
Compact JSON, for example {"country_code":"BR","type":"mobile","e164":"+55...",...}.

Definition at line 164 of file phonegen.hpp.

◆ to_json() [2/2]

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

Write this number as a JSON object.

Parameters
wWriter positioned where a value is allowed.

Definition at line 147 of file phonegen.hpp.

◆ to_string()

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

Human-readable summary string.

Returns
The international format.

Definition at line 143 of file phonegen.hpp.

Friends And Related Symbol Documentation

◆ operator<<

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

Stream the summary to an output stream.

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

Definition at line 182 of file phonegen.hpp.

◆ phg

friend class phg
friend

Definition at line 214 of file phonegen.hpp.

Member Data Documentation

◆ calling_code

std::string dasmig::phone::calling_code

Calling code without the plus sign ("55").

Definition at line 86 of file phonegen.hpp.

◆ country_code

std::string dasmig::phone::country_code

ISO 3166-1 alpha-2 of the region the number belongs to.

Definition at line 85 of file phonegen.hpp.

◆ national_number

std::string dasmig::phone::national_number

The digits after the calling code, without a national prefix.

Definition at line 87 of file phonegen.hpp.

◆ reserved

bool dasmig::phone::reserved {false}

True when the number comes from a range set aside for fiction.

Definition at line 89 of file phonegen.hpp.

◆ type

phone_type dasmig::phone::type {phone_type::mobile}

Mobile or fixed line.

Definition at line 88 of file phonegen.hpp.


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