Faker C++
Loading...
Searching...
No Matches
internet.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <ctime>
5#include <map>
6#include <optional>
7#include <string>
8#include <string_view>
9
10#include "faker-cxx/export.h"
11#include "faker-cxx/types/locale.h"
12
14{
23
24enum class WebProtocol
25{
26 Http,
27 Https
28};
29
30enum class IPv4Class
31{
32 A,
33 B,
34 C
35};
36
37struct FAKER_CXX_EXPORT PasswordOptions
38{
39 bool upperLetters = true;
40 bool lowerLetters = true;
41 bool numbers = true;
42 bool symbols = true;
43};
44
61FAKER_CXX_EXPORT std::string username(std::optional<std::string> firstName = std::nullopt,
62 std::optional<std::string> lastName = std::nullopt,
63 Locale locale = Locale::en_US);
64
82FAKER_CXX_EXPORT std::string email(std::optional<std::string> firstName = std::nullopt,
83 std::optional<std::string> lastName = std::nullopt,
84 std::optional<std::string> emailHost = std::nullopt, Locale locale = Locale::en_US);
85
98FAKER_CXX_EXPORT std::string exampleEmail(std::optional<std::string> firstName = std::nullopt,
99 std::optional<std::string> lastName = std::nullopt,
100 Locale locale = Locale::en_US);
101
117FAKER_CXX_EXPORT std::string password(int length = 16, const PasswordOptions& options = {});
118
119enum class EmojiType
120{
121 Activity,
122 Body,
123 Flag,
124 Food,
125 Nature,
126 Object,
127 Person,
128 Smiley,
129 Symbol,
130 Travel,
131};
132
145FAKER_CXX_EXPORT std::string_view emoji(std::optional<EmojiType> type = std::nullopt);
146
158FAKER_CXX_EXPORT bool checkIfEmojiIsValid(const std::string& emojiToCheck);
159
169FAKER_CXX_EXPORT std::string_view protocol();
170
180FAKER_CXX_EXPORT std::string_view httpMethod();
181
194FAKER_CXX_EXPORT unsigned httpStatusCode(std::optional<HttpResponseType> responseType = std::nullopt);
195
205FAKER_CXX_EXPORT std::string_view httpRequestHeader(Locale locale = Locale::en_US);
206
216FAKER_CXX_EXPORT std::string_view httpResponseHeader(Locale locale = Locale::en_US);
217
227FAKER_CXX_EXPORT std::string_view httpMediaType(Locale locale = Locale::en_US);
228
241FAKER_CXX_EXPORT std::string ipv4(const IPv4Class& ipv4class = IPv4Class::C);
242
260FAKER_CXX_EXPORT std::string ipv4(const std::array<unsigned int, 4>& baseIpv4Address,
261 const std::array<unsigned int, 4>& generationMask);
262
272FAKER_CXX_EXPORT std::string ipv6();
273
285FAKER_CXX_EXPORT std::string mac(const std::string& sep = ":");
286
296FAKER_CXX_EXPORT unsigned port();
297
309FAKER_CXX_EXPORT std::string url(const WebProtocol& webProtocol = WebProtocol::Https, Locale locale = Locale::en_US);
310
320FAKER_CXX_EXPORT std::string domainName(Locale locale = Locale::en_US);
321
331FAKER_CXX_EXPORT std::string domainWord();
332
342FAKER_CXX_EXPORT std::string_view domainSuffix(Locale locale = Locale::en_US);
343
355FAKER_CXX_EXPORT std::string anonymousUsername(unsigned maxLength);
356
376FAKER_CXX_EXPORT std::string
377getJWTToken(const std::optional<std::map<std::string, std::string>>& header = std::nullopt,
378 const std::optional<std::map<std::string, std::string>>& payload = std::nullopt,
379 const std::optional<std::string>& refDate = std::nullopt);
380
392FAKER_CXX_EXPORT std::string_view getJWTAlgorithm(Locale locale = Locale::en_US);
393}
Definition internet.h:14
IPv4Class
Definition internet.h:31
FAKER_CXX_EXPORT std::string anonymousUsername(unsigned maxLength)
Generates a random username.
FAKER_CXX_EXPORT unsigned httpStatusCode(std::optional< HttpResponseType > responseType=std::nullopt)
Returns a random http status code.
FAKER_CXX_EXPORT std::string domainName(Locale locale=Locale::en_US)
Generates a random domain name.
HttpResponseType
Definition internet.h:16
FAKER_CXX_EXPORT std::string url(const WebProtocol &webProtocol=WebProtocol::Https, Locale locale=Locale::en_US)
Generates a random url.
FAKER_CXX_EXPORT std::string_view httpMethod()
Generates a random http method name.
FAKER_CXX_EXPORT std::string_view emoji(std::optional< EmojiType > type=std::nullopt)
Returns a random emoji.
FAKER_CXX_EXPORT std::string domainWord()
Generates a random domain word.
FAKER_CXX_EXPORT std::string_view httpMediaType(Locale locale=Locale::en_US)
Generates a random http media type.
FAKER_CXX_EXPORT std::string_view getJWTAlgorithm(Locale locale=Locale::en_US)
Returns the algorithm used for signing the JWT.
FAKER_CXX_EXPORT std::string_view httpResponseHeader(Locale locale=Locale::en_US)
Generates a random http response header.
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 password(int length=16, const PasswordOptions &options={})
Generates a random password-like string. Do not use this method for generating actual passwords for u...
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 ipv6()
Returns a string containing randomized ipv6 address.
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.
EmojiType
Definition internet.h:120
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, Locale locale=Locale::en_US)
Generates an email address using the given person's name as base.
FAKER_CXX_EXPORT std::string_view domainSuffix(Locale locale=Locale::en_US)
Generates a random domain suffix.
FAKER_CXX_EXPORT std::string_view httpRequestHeader(Locale locale=Locale::en_US)
Generates a random http request header.
WebProtocol
Definition internet.h:25
FAKER_CXX_EXPORT std::string_view protocol()
Returns a random web protocol. Either `http` or `https`.
FAKER_CXX_EXPORT bool checkIfEmojiIsValid(const std::string &emojiToCheck)
Verify that a given emoji is valid.
FAKER_CXX_EXPORT std::string mac(const std::string &sep=":")
Returns a generated random mac address.
FAKER_CXX_EXPORT std::string exampleEmail(std::optional< std::string > firstName=std::nullopt, std::optional< std::string > lastName=std::nullopt, Locale locale=Locale::en_US)
Generates an email address using the given person's name as base with example domain.
FAKER_CXX_EXPORT unsigned port()
Generates a random port.
Definition internet.h:38