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

Functions

FAKER_CXX_EXPORT std::string_view sample (std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
 Returns a random .
 
FAKER_CXX_EXPORT std::string words (unsigned numberOfWords=1, Locale locale=Locale::en_US)
 Returns a string containing a number of space separated random words.
 
FAKER_CXX_EXPORT std::string_view adjective (std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
 Returns a random adjective.
 
FAKER_CXX_EXPORT std::string_view adjectiveLocale (unsigned length=0, Locale locale=Locale::en_US)
 Returns a random adjective, using locale.
 
FAKER_CXX_EXPORT std::string_view adverb (std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
 Returns a random adverb.
 
FAKER_CXX_EXPORT std::string_view conjunction (std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
 Returns a random conjunction.
 
FAKER_CXX_EXPORT std::string_view interjection (std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
 Returns a random interjection.
 
FAKER_CXX_EXPORT std::string_view noun (std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
 Returns a random noun.
 
FAKER_CXX_EXPORT std::string_view preposition (std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
 Returns a random preposition.
 
FAKER_CXX_EXPORT std::string_view verb (std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
 Returns a random verb.
 
template<std::ranges::range Range>
auto sortedSizeRandomElement (std::optional< unsigned int > length, Range &&range) -> decltype(auto)
 Returns random element of length.
 

Function Documentation

◆ adjective()

FAKER_CXX_EXPORT std::string_view faker::word::adjective ( std::optional< unsigned > length = std::nullopt,
Locale locale = Locale::en_US )

Returns a random adjective.

Parameters
lengthThe expected length of the word. If no adjective with given length will be found or length is 0, it will return a random size adjective.
localeThe locale. Defaults to `Locale::en_US`.
Returns
Adjective.
faker::word::adjective() // "complete"
faker::word::adjective(3) // "bad"
FAKER_CXX_EXPORT std::string_view adjective(std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
Returns a random adjective.
Definition airline.h:9

◆ adjectiveLocale()

FAKER_CXX_EXPORT std::string_view faker::word::adjectiveLocale ( unsigned length = 0,
Locale locale = Locale::en_US )

Returns a random adjective, using locale.

Parameters
lengthThe expected length of the word. If no adjective with given length will be found or length is 0, it will return a random size adjective.
localeThe locale. Defaults to `Locale::en_US`.
Returns
Adjective.
faker::word::adjective() // "complete"
faker::word::adjective(3) // "bad"

◆ adverb()

FAKER_CXX_EXPORT std::string_view faker::word::adverb ( std::optional< unsigned > length = std::nullopt,
Locale locale = Locale::en_US )

Returns a random adverb.

Parameters
lengthThe expected length of the word. If no adverb with given length will be found or length is 0, it will return a random size adverb.
localeThe locale. Defaults to `Locale::en_US`.
Returns
Adverb.
faker::word::adverb() // "deliberately"
faker::word::adverb(5) // "almost"
FAKER_CXX_EXPORT std::string_view adverb(std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
Returns a random adverb.

◆ conjunction()

FAKER_CXX_EXPORT std::string_view faker::word::conjunction ( std::optional< unsigned > length = std::nullopt,
Locale locale = Locale::en_US )

Returns a random conjunction.

Parameters
lengthThe expected length of the word. If no conjunction with given length will be found or length is 0, it will return a random size conjunction.
localeThe locale. Defaults to `Locale::en_US`.
Returns
Conjunction.
faker::word::conjunction(6) // "indeed"
FAKER_CXX_EXPORT std::string_view conjunction(std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
Returns a random conjunction.

◆ interjection()

FAKER_CXX_EXPORT std::string_view faker::word::interjection ( std::optional< unsigned > length = std::nullopt,
Locale locale = Locale::en_US )

Returns a random interjection.

Parameters
lengthThe expected length of the word. If no interjection with given length is found or length is 0, it will return a random size interjection.
localeThe locale. Defaults to `Locale::en_US`.
Returns
Interjection.
faker::word::interjection(4) // "yuck"
FAKER_CXX_EXPORT std::string_view interjection(std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
Returns a random interjection.

◆ noun()

FAKER_CXX_EXPORT std::string_view faker::word::noun ( std::optional< unsigned > length = std::nullopt,
Locale locale = Locale::en_US )

Returns a random noun.

Parameters
lengthThe expected length of the word. If no noun with given length is found or length is 0, it will return a random size noun.
localeThe locale. Defaults to `Locale::en_US`.
Returns
Noun.
faker::word::noun() // "pudding"
faker::word::noun(8) // "distance"
FAKER_CXX_EXPORT std::string_view noun(std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
Returns a random noun.

◆ preposition()

FAKER_CXX_EXPORT std::string_view faker::word::preposition ( std::optional< unsigned > length = std::nullopt,
Locale locale = Locale::en_US )

Returns a random preposition.

Parameters
lengthThe expected length of the word. If no preposition with given length is found or length is 0, it will return a random size preposition.
localeThe locale. Defaults to `Locale::en_US`.
Returns
Preposition.
faker::word::preposition(4) // "from"
FAKER_CXX_EXPORT std::string_view preposition(std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
Returns a random preposition.

◆ sample()

FAKER_CXX_EXPORT std::string_view faker::word::sample ( std::optional< unsigned > length = std::nullopt,
Locale locale = Locale::en_US )

Returns a random .

Parameters
lengthThe expected length of the . If no word with given length will be found or length is 0, it will return a random size word.
localeThe locale. Defaults to `Locale::en_US`.
Returns
Random sample word.
faker::word::sample() // "protection"
faker::word::sample(5) // "spell"
FAKER_CXX_EXPORT std::string_view sample(std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
Returns a random .

◆ sortedSizeRandomElement()

template<std::ranges::range Range>
auto faker::word::sortedSizeRandomElement ( std::optional< unsigned int > length,
Range && range ) -> decltype(auto)

Returns random element of length.

Parameters
lengthThe length of the elements to be picked from
localeThe locale. Defaults to `Locale::en_US`.

@ range The range of elements

Returns
An element of the range value type
faker::word::sortedSizeRandomElement(3, {"hi, "hello", "hey"}) // "hey" - Since "hey" is the only element of length 3
auto sortedSizeRandomElement(std::optional< unsigned int > length, Range &&range) -> decltype(auto)
Returns random element of length.
Definition word.h:191

◆ verb()

FAKER_CXX_EXPORT std::string_view faker::word::verb ( std::optional< unsigned > length = std::nullopt,
Locale locale = Locale::en_US )

Returns a random verb.

Parameters
lengthThe expected length of the word. If no verb with given length is found or length is 0, it will return a random size verb.
localeThe locale. Defaults to `Locale::en_US`.
Returns
Verb.
faker::word::verb() // "override"
faker::word::verb(9) // "stabilise"
FAKER_CXX_EXPORT std::string_view verb(std::optional< unsigned > length=std::nullopt, Locale locale=Locale::en_US)
Returns a random verb.

◆ words()

FAKER_CXX_EXPORT std::string faker::word::words ( unsigned numberOfWords = 1,
Locale locale = Locale::en_US )

Returns a string containing a number of space separated random words.

Parameters
numberOfWordsThe number of words to generate.
localeThe locale. Defaults to `Locale::en_US`.
Returns
Random words separated with spaces.
faker::word::words() // "protection"
faker::word::words(5) // "before hourly patiently dribble equal"
FAKER_CXX_EXPORT std::string words(unsigned numberOfWords=1, Locale locale=Locale::en_US)
Returns a string containing a number of space separated random words.