Faker C++
|
Classes | |
struct | PasswordOptions |
Enumerations | |
enum class | HttpResponseType { ClientError , Informational , Redirection , ServerError , Success } |
enum class | WebProtocol { Http , Https } |
enum class | IPv4Class { A , B , C } |
enum class | EmojiType { Activity , Body , Flag , Food , Nature , Object , Person , Smiley , Symbol , Travel } |
Functions | |
FAKER_CXX_EXPORT std::string | username (std::optional< std::string > firstName=std::nullopt, std::optional< std::string > lastName=std::nullopt, Locale locale=Locale::en_US) |
Generates a username using the given person's name as base. | |
FAKER_CXX_EXPORT std::string | email (std::optional< std::string > firstName=std::nullopt, std::optional< std::string > lastName=std::nullopt, std::optional< std::string > emailHost=std::nullopt) |
Generates an email address using the given person's name as base. | |
FAKER_CXX_EXPORT std::string | exampleEmail (std::optional< std::string > firstName=std::nullopt, std::optional< std::string > lastName=std::nullopt) |
Generates an email address using the given person's name as base with example domain. | |
FAKER_CXX_EXPORT std::string | password (int length=16, const PasswordOptions &options={}) |
Generates a random password-like string. Do not use this method for generating actual passwords for users. Since the source of the randomness is not cryptographically secure, neither is this generator. | |
FAKER_CXX_EXPORT std::string_view | emoji (std::optional< EmojiType > type=std::nullopt) |
Returns a random emoji. | |
FAKER_CXX_EXPORT bool | checkIfEmojiIsValid (const std::string &emojiToCheck) |
Verify that a given emoji is valid. | |
FAKER_CXX_EXPORT std::string_view | protocol () |
Returns a random web protocol. Either `http` or `https`. | |
FAKER_CXX_EXPORT std::string_view | httpMethod () |
Generates a random http method name. | |
FAKER_CXX_EXPORT unsigned | httpStatusCode (std::optional< HttpResponseType > responseType=std::nullopt) |
Returns a random http status code. | |
FAKER_CXX_EXPORT std::string_view | httpRequestHeader () |
Generates a random http request header. | |
FAKER_CXX_EXPORT std::string_view | httpResponseHeader () |
Generates a random http response header. | |
FAKER_CXX_EXPORT std::string_view | httpMediaType () |
Generates a random http media type. | |
FAKER_CXX_EXPORT std::string | ipv4 (const IPv4Class &ipv4class=IPv4Class::C) |
Returns a string containing randomized ipv4 address of the given class. | |
FAKER_CXX_EXPORT std::string | ipv4 (const std::array< unsigned int, 4 > &baseIpv4Address, const std::array< unsigned int, 4 > &generationMask) |
Returns a string containing randomized ipv4 address based on given base address and mask. | |
FAKER_CXX_EXPORT std::string | ipv6 () |
Returns a string containing randomized ipv6 address. | |
FAKER_CXX_EXPORT std::string | mac (const std::string &sep=":") |
Returns a generated random mac address. | |
FAKER_CXX_EXPORT unsigned | port () |
Generates a random port. | |
FAKER_CXX_EXPORT std::string | url (const WebProtocol &webProtocol=WebProtocol::Https) |
Generates a random url. | |
FAKER_CXX_EXPORT std::string | domainName () |
Generates a random domain name. | |
FAKER_CXX_EXPORT std::string | domainWord () |
Generates a random domain word. | |
FAKER_CXX_EXPORT std::string_view | domainSuffix () |
Generates a random domain suffix. | |
FAKER_CXX_EXPORT std::string | anonymousUsername (unsigned maxLength) |
Generates a random username. | |
FAKER_CXX_EXPORT std::string | getJWTToken (const std::optional< std::map< std::string, std::string > > &header=std::nullopt, const std::optional< std::map< std::string, std::string > > &payload=std::nullopt, const std::optional< std::string > &refDate=std::nullopt) |
Generates a JSON Web Token (JWT). | |
FAKER_CXX_EXPORT std::string_view | getJWTAlgorithm () |
Returns the algorithm used for signing the JWT. | |
|
strong |
|
strong |
|
strong |
|
strong |
FAKER_CXX_EXPORT std::string faker::internet::anonymousUsername | ( | unsigned | maxLength | ) |
Generates a random username.
maxLength | maxLength of the generated username. |
FAKER_CXX_EXPORT bool faker::internet::checkIfEmojiIsValid | ( | const std::string & | emojiToCheck | ) |
Verify that a given emoji is valid.
emojiToCheck | the emoji to check. |
FAKER_CXX_EXPORT std::string faker::internet::domainName | ( | ) |
Generates a random domain name.
FAKER_CXX_EXPORT std::string_view faker::internet::domainSuffix | ( | ) |
Generates a random domain suffix.
FAKER_CXX_EXPORT std::string faker::internet::domainWord | ( | ) |
Generates a random domain word.
FAKER_CXX_EXPORT std::string faker::internet::email | ( | std::optional< std::string > | firstName = std::nullopt, |
std::optional< std::string > | lastName = std::nullopt, | ||
std::optional< std::string > | emailHost = std::nullopt ) |
Generates an email address using the given person's name as base.
firstName | The optional first name to use. If not specified, a random one will be chosen. |
lastName | The optional last name to use. If not specified, a random one will be chosen. |
emailHost | The optional email host name to use. If not specified, a random one will be chosen. |
FAKER_CXX_EXPORT std::string_view faker::internet::emoji | ( | std::optional< EmojiType > | type = std::nullopt | ) |
Returns a random emoji.
type | The optional type of them emoji to be generated. |
FAKER_CXX_EXPORT std::string faker::internet::exampleEmail | ( | std::optional< std::string > | firstName = std::nullopt, |
std::optional< std::string > | lastName = std::nullopt ) |
Generates an email address using the given person's name as base with example domain.
firstName | The optional first name to use. If not specified, a random one will be chosen. |
lastName | The optional last name to use. If not specified, a random one will be chosen. |
FAKER_CXX_EXPORT std::string_view faker::internet::getJWTAlgorithm | ( | ) |
Returns the algorithm used for signing the JWT.
This function provides the algorithm that is used to sign the JSON Web Token (JWT).
FAKER_CXX_EXPORT std::string faker::internet::getJWTToken | ( | const std::optional< std::map< std::string, std::string > > & | header = std::nullopt, |
const std::optional< std::map< std::string, std::string > > & | payload = std::nullopt, | ||
const std::optional< std::string > & | refDate = std::nullopt ) |
Generates a JSON Web Token (JWT).
This function generates a JWT using the provided header, payload, and reference date. If no header or payload is provided, default values will be used. The reference date is optional and can be used to set the "iat" (issued at) claim in the payload.
header | The optional header map to include in the JWT. Defaults to a standard header. |
payload | The optional payload map to include in the JWT. Defaults to a standard payload. |
refDate | The optional reference date to set the "iat" claim. Defaults to the current date and time. |
FAKER_CXX_EXPORT std::string_view faker::internet::httpMediaType | ( | ) |
Generates a random http media type.
FAKER_CXX_EXPORT std::string_view faker::internet::httpMethod | ( | ) |
Generates a random http method name.
FAKER_CXX_EXPORT std::string_view faker::internet::httpRequestHeader | ( | ) |
Generates a random http request header.
FAKER_CXX_EXPORT std::string_view faker::internet::httpResponseHeader | ( | ) |
Generates a random http response header.
FAKER_CXX_EXPORT unsigned faker::internet::httpStatusCode | ( | std::optional< HttpResponseType > | responseType = std::nullopt | ) |
Returns a random http status code.
responseType | The type of the http response. |
FAKER_CXX_EXPORT std::string faker::internet::ipv4 | ( | const IPv4Class & | ipv4class = IPv4Class::C | ) |
Returns a string containing randomized ipv4 address of the given class.
ipv4class | Address class to be generated. |
FAKER_CXX_EXPORT std::string faker::internet::ipv4 | ( | const std::array< unsigned int, 4 > & | baseIpv4Address, |
const std::array< unsigned int, 4 > & | generationMask ) |
Returns a string containing randomized ipv4 address based on given base address and mask.
Generated result is compliant with the ipv4 classes. Bits of the baseIpv4Address not covered by the generationMask will be ignored and replaced during generation. Bits covered by the mask will be kept in the result. Mask should be provided in the same format as regular ipv4 mask.
generationMask | Mask deciding which bits of the base address should be kept during randomization. |
baseIpv4Address | Address to randomize from. |
FAKER_CXX_EXPORT std::string faker::internet::ipv6 | ( | ) |
Returns a string containing randomized ipv6 address.
FAKER_CXX_EXPORT std::string faker::internet::mac | ( | const std::string & | sep = ":" | ) |
Returns a generated random mac address.
sep | Separator to use. Defaults to ":". Also can be "-" or "". |
FAKER_CXX_EXPORT std::string faker::internet::password | ( | int | length = 16, |
const PasswordOptions & | options = {} ) |
Generates a random password-like string. Do not use this method for generating actual passwords for users. Since the source of the randomness is not cryptographically secure, neither is this generator.
length | The length of the password to generate. Defaults to `16`. |
options | The optional password options to use. Options include whether to include upperLetters, lowerLetters, numbers and symbols in password generation. Defaults to include all. |
FAKER_CXX_EXPORT unsigned faker::internet::port | ( | ) |
FAKER_CXX_EXPORT std::string_view faker::internet::protocol | ( | ) |
Returns a random web protocol. Either `http` or `https`.
FAKER_CXX_EXPORT std::string faker::internet::url | ( | const WebProtocol & | webProtocol = WebProtocol::Https | ) |
Generates a random url.
webProtocol | Web protocol to generate url with. Defaults to `WebProtocolHttps`. |
FAKER_CXX_EXPORT std::string faker::internet::username | ( | std::optional< std::string > | firstName = std::nullopt, |
std::optional< std::string > | lastName = std::nullopt, | ||
Locale | locale = Locale::en_US ) |
Generates a username using the given person's name as base.
firstName | The optional first name to include in username. |
lastName | The optional last name to include in username. |
locale | The locale. Defaults to `Locale::en_US`. |