https://github.com/cieslarmichal/faker-cxx
C++ Faker library for generating fake (but realistic) data.
https://github.com/cieslarmichal/faker-cxx
cpp cpp20 data-generation fake fake-data faker
Last synced: 5 months ago
JSON representation
C++ Faker library for generating fake (but realistic) data.
- Host: GitHub
- URL: https://github.com/cieslarmichal/faker-cxx
- Owner: cieslarmichal
- License: mit
- Created: 2023-06-24T19:56:47.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2026-01-26T19:25:03.000Z (5 months ago)
- Last Synced: 2026-01-27T07:07:40.372Z (5 months ago)
- Topics: cpp, cpp20, data-generation, fake, fake-data, faker
- Language: C++
- Homepage: https://cieslarmichal.github.io/faker-cxx/
- Size: 24.5 MB
- Stars: 412
- Watchers: 9
- Forks: 184
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- fucking-awesome-cpp - faker-cxx - C++20 Faker library for generating fake (but realistic) data for testing and development. [MIT] (Miscellaneous)
- awesome-faker - C++ - faker-cxx - C++ Faker library for generating fake (but realistic) data. (Languages)
- AwesomeCppGameDev - faker-cxx - C++20 Faker library for generating fake (but realistic) data for testing and development. (C++)
- awesome-game-engine-dev - faker-cxx - C++20 Faker library for generating fake (but realistic) data for testing and development. (Libraries / C++)
- awesome-cpp - faker-cxx - C++20 Faker library for generating fake (but realistic) data for testing and development. [MIT] (Miscellaneous)
- awesome-cpp-with-stars - faker-cxx - 02-20 | (Miscellaneous)
README
Faker C++
[](https://github.com/cieslarmichal/faker-cxx/actions/workflows/linux-clang-build.yml?query=branch%3Amain)
[](https://github.com/cieslarmichal/faker-cxx/actions/workflows/macos-clang-build.yml?query=branch%3Amain)
[](https://github.com/cieslarmichal/faker-cxx/actions/workflows/linux-gxx-build.yml?query=branch%3Amain)
[](https://github.com/cieslarmichal/faker-cxx/actions/workflows/windows-msvc-build.yml?query=branch%3Amain)
[](https://github.com/cieslarmichal/faker-cxx/actions/workflows/linux-bazel-build.yml?query=branch%3Amain)
[](https://codecov.io/github/cieslarmichal/faker-cxx)
[](https://conan.io/center/recipes/faker-cxx)
[](https://vcpkg.link/ports/faker-cxx)
[](http://makeapullrequest.com)
[](https://discord.gg/h2ur8H6mK6)
## Table of Contents
- [Introduction](#introduction)
- [โก Quick Start](#-quick-start)
- [Key Features](#key-features)
- [๐ Usage and Documentation](#-usage-and-documentation)
- [๐ฏ Common Use Cases](#-common-use-cases)
- [๐ Modules](#-modules)
- [๐ API Reference](#-api-reference)
- [๐ Supported Locales](#-supported-locales)
- [Consuming the library with CMake](#consuming-the-library-with-cmake)
- [Installing the library with vcpkg](#installing-the-library-with-vcpkg)
- [โ๏ธ Compiler support](#๏ธ-compiler-support)
- [Dependencies](#dependencies)
- [๐ฆ Building the library with Conan](#-building-the-library-with-conan)
- [Installing the library with Conan](#installing-the-library-with-conan)
- [Building the library with Bazel](#building-the-library-with-bazel)
- [โจ Contributing](#-contributing)
- [๐ Credits](#-credits)
- [๐ Changelog](#-changelog)
- [๐ License](#-license)
## Introduction
Faker C++ is a C++ library inspired by the popular [Faker.js](https://github.com/faker-js/faker),
aimed at providing developers with a robust tool for generating fake (but realistic) data.
Whether you're building test suites, populating databases, or creating demos, Faker C++ has got you covered.
## โก Quick Start
Want to get started immediately? Check out our [**Quick Start Guide**](QUICK_START.md) for a 5-minute introduction!
```cpp
#include
#include "faker-cxx/faker.h"
int main() {
std::cout << faker::person::fullName() << std::endl; // "Jennifer Martin"
std::cout << faker::internet::email() << std::endl; // "martin.jennifer@gmail.com"
std::cout << faker::location::city() << std::endl; // "Los Angeles"
std::cout << faker::string::uuidV4() << std::endl; // "8e3a4f21-5c7b-4d9a-8f2e-1b9c7d6a5e3f"
return 0;
}
```
**๐ [Read the Quick Start Guide](QUICK_START.md)** for installation and more examples!
## Key Features
๐ Realistic Data Generation: Generate various types of data including names, addresses, emails, dates, and more.
๐ Modular Design: Choose from a wide range of modules like Internet, Location, String, Date, and more to generate
specific types of data.
๐ Easy Integration: Seamlessly integrate with CMake, and it supports major compilers like MSVC, GCC, Clang, and Apple
Clang.
## ๐ Usage and Documentation
To properly use Faker C++ you must first consume the Faker library (see Consuming Library with CMake).
Once that is done, you need to include the proper [header](https://cieslarmichal.github.io/faker-cxx/files.html) file
depending on the module you wish to generate data from or use general include file `faker-cxx/faker.h`.
All the documentation can be found at [cieslarmichal.github.io/faker-cxx](https://cieslarmichal.github.io/faker-cxx/).
Below is an example of how to use Faker C++ in your code.
```cpp
#include
#include "faker-cxx/faker.h" // or include specific module
int main()
{
const auto id = faker::string::uuidV4();
const auto email = faker::internet::email();
const auto password = faker::internet::password();
const auto city = faker::location::city();
const auto streetAddress = faker::location::streetAddress();
const auto bornDate = faker::date::birthdateByYear(1970, 2000);
std::cout << id << std::endl; // 59990db5-3a5f-40bf-8af0-7834c29ee884
std::cout << email << std::endl; // hills.rita@gmail.com
std::cout << password << std::endl; // Mf+*[(_'lHfM.$v{
std::cout << city << std::endl; // Rochester
std::cout << streetAddress << std::endl; // 643 Ricardo Creek
std::cout << bornDate << std::endl; // 1973-12-03T11:07:02Z
return 0;
}
```
## ๐ฏ Common Use Cases
### Generate Test Data for Databases
```cpp
#include "faker-cxx/faker.h"
struct User {
std::string id = faker::string::uuidV4();
std::string name = faker::person::fullName();
std::string email = faker::internet::email();
std::string address = faker::location::streetAddress();
std::string city = faker::location::city();
std::string zipCode = faker::location::zipCode();
std::string phone = faker::phone::number();
std::string birthdate = faker::date::birthdateByYear(1970, 2005);
};
```
### Mock API Responses
```cpp
struct Product {
std::string id = faker::string::uuidV4();
std::string name = faker::commerce::productFullName();
std::string price = faker::finance::amount(10, 1000, faker::Precision::TwoDp, "$");
std::string sku = faker::commerce::sku();
std::string category = faker::commerce::productCategory();
};
```
### Generate Lorem Ipsum Content
```cpp
std::string blogTitle = faker::lorem::words(5); // Blog post title
std::string author = faker::person::fullName(); // Author name
std::string content = faker::lorem::paragraphs(3); // Article content
std::string summary = faker::lorem::sentence(); // Brief summary
```
### Create Unique Identifiers
```cpp
auto uuid = faker::string::uuidV4(); // "8e3a4f21-5c7b-4d9a-8f2e-1b9c7d6a5e3f"
auto ulid = faker::string::ulid(); // "01ARZ3NDEKTSV4RRFFQ69G5FAV"
auto nanoid = faker::string::nanoId(); // "V1StGXR8_Z5jdHi6B-myT"
```
### Generate Financial Data
```cpp
std::string iban = faker::finance::iban(); // "DE89370400440532013000"
std::string creditCard = faker::finance::creditCardNumber(); // "4532-1488-0343-6467"
std::string amount = faker::finance::amount(100, 10000, faker::Precision::TwoDp, "โฌ");
```
### Localized Data Generation
```cpp
// Generate Polish names
auto plName = faker::person::firstName(faker::Locale::pl_PL); // "Krystyna"
// Generate French addresses
auto frCity = faker::location::city(faker::Locale::fr_FR); // "Lyon"
// Generate German IBAN
auto deIban = faker::finance::iban(faker::Locale::de_DE); // "DE89370400440532013000"
```
## ๐ Modules
- ๐ฉ Airline - aircraft, airlines, airports, flight numbers
- ๐ผ Animal - species by type (bear, bird, cat, dog, etc.)
- ๐ Book - title, genre, author, publisher
- ๐จ Color - name, rgb, hex, hsl, lch, cmyk
- ๐ Commerce - products, prices, SKU, EAN, ISBN
- ๐ข Company - name, type, industry, buzzwords
- ๐ฅ๏ธ Computer - type, manufacturer, CPU, GPU
- ๐ Crypto - SHA, MD5 hashes
- ๐พ Database - column names, types, engines
- โน๏ธ Datatype - booleans
- ๐
Date - past/future dates, birthdays, weekdays
- ๐น๏ธ E-sport - players, teams, leagues
- ๐ Education - schools, degrees, fields of study
- ๐ฆ Finance - currency, IBAN, BIC, credit cards
- ๐ Food - dishes, ingredients, beverages
- ๐ Git - branch, commit, SHA
- ๐จโ๐ป Hacker - abbreviations, phrases
- ๐ผ๏ธ Image - URLs, dimensions, types
- ๐ Internet - email, username, password, IP, URL
- ๐ Location - country, city, address, coordinates, MGRS grid
- ๐ Lorem - words, sentences, paragraphs
- ๐ฅ Medicine - conditions, tests, specialties
- ๐ฅ Movie - titles, genres, actors, directors
- ๐ถ Music - artists, songs, genres
- ๐ข Number - integers, decimals, hex, binary
- ๐ง Person - names, titles, bio, SSN
- ๐ Phone - numbers, IMEI
- ๐ชด Plant - trees, flowers
- ๐งโ๐ฌ Science - chemical elements, units
- โฝ Sport - sports, teams, athletes
- ๐ข String - UUID, ULID, Nano ID, alphanumeric
- ๐ป System - file names, paths, MIME types
- ๐ Vehicle - manufacturer, model, VIN
- ๐๏ธ Video - formats, codecs, resolutions
- ๐ฎ Video game - titles, genres, platforms
- ๐ค๏ธ Weather - descriptions
- ๐ฌ Word - adjectives, nouns, verbs
## ๐ API Reference
Use **Ctrl+F** (Cmd+F on Mac) to search for specific functions!
> ๐ก For detailed docs with parameters and options, see [cieslarmichal.github.io/faker-cxx](https://cieslarmichal.github.io/faker-cxx/)
### ๐ฉ๏ธ Airline Module
```cpp
faker::airline::aircraftType() // "narrowbody"
faker::airline::airplane() // {name: "Boeing 737", iataTypeCode: "737"}
faker::airline::airline() // {name: "American Airlines", iataCode: "AA"}
faker::airline::airport() // {name: "Los Angeles International Airport", iataCode: "LAX"}
faker::airline::seat(aircraftType) // "1A"
faker::airline::recordLocator() // "ABCDEF"
faker::airline::recordLocator(true) // "ABC123"
faker::airline::flightNumber() // "1234"
faker::airline::flightNumber(true) // "0123"
faker::airline::flightNumberByRange() // "234"
```
### ๐ผ Animal Module
```cpp
faker::animal::bear() // "Grizzly bear"
faker::animal::bird() // "Eagle"
faker::animal::cat() // "Siamese"
faker::animal::cetacean() // "Dolphin"
faker::animal::cow() // "Holstein"
faker::animal::crocodile() // "Nile crocodile"
faker::animal::dog() // "Golden Retriever"
faker::animal::fish() // "Salmon"
faker::animal::horse() // "Arabian"
faker::animal::insect() // "Butterfly"
faker::animal::lion() // "African Lion"
faker::animal::rabbit() // "Angora"
faker::animal::rodent() // "Hamster"
faker::animal::snake() // "Python"
faker::animal::type() // "mammal"
```
### ๐ Book Module
```cpp
faker::book::title() // "The Great Gatsby"
faker::book::genre() // "Science Fiction"
faker::book::author() // "George Orwell"
faker::book::publisher() // "Penguin Books"
faker::book::format() // "Hardcover"
faker::book::series() // "Harry Potter"
```
### ๐จ Color Module
```cpp
faker::color::name() // "Red"
faker::color::rgb() // "rgb(255, 0, 0)"
faker::color::hex() // "#FF0000"
faker::color::hsl() // "hsl(0, 100%, 50%)"
faker::color::lch() // "lch(53.24, 104.55, 40)"
faker::color::cmyk() // "cmyk(0, 100, 100, 0)"
faker::color::lab() // "lab(53.24, 80.09, 67.20)"
faker::color::hsb() // "hsb(0, 100%, 100%)"
faker::color::hsv() // "hsv(0, 100%, 100%)"
faker::color::hwb() // "hwb(0, 0%, 0%)"
faker::color::yuv() // "yuv(127, 0, 0)"
faker::color::space() // "sRGB"
```
### ๐ Commerce Module
```cpp
faker::commerce::department() // "Electronics"
faker::commerce::sku() // "ABC-12345"
faker::commerce::productAdjective() // "Awesome"
faker::commerce::productMaterial() // "Cotton"
faker::commerce::productName() // "Shirt"
faker::commerce::productFullName() // "Awesome Cotton Shirt"
faker::commerce::EAN13() // "1234567890123"
faker::commerce::EAN8() // "12345678"
faker::commerce::ISBN13() // "978-1-234-56789-0"
faker::commerce::ISBN10() // "1-234-56789-0"
faker::commerce::paymentType() // "Credit Card"
faker::commerce::paymentProvider() // "Visa"
faker::commerce::productDescription() // "Ergonomic and stylish!"
faker::commerce::productCategory() // "Clothing"
faker::commerce::productReview() // "Great product!"
faker::commerce::discountType() // "Percentage"
faker::commerce::orderStatus() // "Shipped"
faker::commerce::shippingCarrier() // "FedEx"
```
### ๐ข Company Module
```cpp
faker::company::companyName() // "Peterson Inc"
faker::company::type() // "LLC"
faker::company::industry() // "Technology"
faker::company::buzzPhrase() // "innovate cutting-edge systems"
faker::company::buzzAdjective() // "innovative"
faker::company::buzzNoun() // "synergy"
faker::company::buzzVerb() // "implement"
faker::company::catchPhrase() // "Quality-focused scalable initiative"
faker::company::catchPhraseAdjective() // "Quality-focused"
faker::company::catchPhraseDescriptor() // "scalable"
faker::company::catchPhraseNoun() // "initiative"
```
### ๐ฅ๏ธ Computer Module
```cpp
faker::computer::type() // "laptop"
faker::computer::manufacture() // "Dell"
faker::computer::model() // "XPS 15"
faker::computer::cpuManufacture() // "Intel"
faker::computer::cpuType() // "x64"
faker::computer::cpuModel() // "Core i7-9700K"
faker::computer::gpuManufacture() // "NVIDIA"
faker::computer::gpuType() // "Integrated"
faker::computer::gpuModel() // "GeForce GTX 1080"
```
### ๐ Crypto Module
```cpp
faker::crypto::sha256() // "a3c4f...(64 chars)"
faker::crypto::sha1() // "4e9d8...(40 chars)"
faker::crypto::md5() // "9b3e4...(32 chars)"
```
### ๐พ Database Module
```cpp
faker::database::columnName() // "id"
faker::database::columnType() // "INT"
faker::database::collation() // "utf8_unicode_ci"
faker::database::engine() // "InnoDB"
faker::database::mongoDbObjectId() // "507f1f77bcf86cd799439011"
```
### โน๏ธ Datatype Module
```cpp
faker::datatype::boolean() // true or false
faker::datatype::boolean(0.7) // 70% chance of true
```
### ๐
Date Module
```cpp
faker::date::anytime() // "2023-07-15T14:30:00Z"
faker::date::pastDate() // "2022-03-12T08:15:00Z"
faker::date::futureDate() // "2024-11-20T19:45:00Z"
faker::date::recentDate() // "2023-07-13T10:20:00Z"
faker::date::soonDate() // "2023-07-17T16:00:00Z"
faker::date::birthdateByAge(18, 65) // "1988-05-23T00:00:00Z"
faker::date::birthdateByYear(1990, 2000) // "1995-08-15T00:00:00Z"
faker::date::weekdayName() // "Monday"
faker::date::weekdayAbbreviatedName() // "Mon"
faker::date::monthName() // "January"
faker::date::monthAbbreviatedName() // "Jan"
faker::date::year() // 2000
faker::date::month() // 9
faker::date::hour() // 21
faker::date::minute() // 40
faker::date::second() // 40
faker::date::time() // "21:40"
faker::date::dayOfMonth() // 15
faker::date::dayOfWeek() // 5
faker::date::timezoneRandom() // "America/New_York"
faker::date::between(from, to) // Random date between two timestamps
```
### ๐ Education Module
```cpp
faker::education::school() // "Harvard University"
faker::education::degree() // "Bachelor of Science"
faker::education::field() // "Computer Science"
faker::education::term() // "Fall Semester"
faker::education::courses() // "Data Structures"
```
### ๐น๏ธ Esport Module
```cpp
faker::esport::player() // "Ninja"
faker::esport::team() // "Team Liquid"
faker::esport::league() // "League of Legends Championship Series"
faker::esport::event() // "The International"
faker::esport::game() // "Dota 2"
faker::esport::organizer() // "ESL"
```
### ๐ฆ Finance Module
```cpp
faker::finance::currency() // {name: "US Dollar", code: "USD", symbol: "$"}
faker::finance::currencyName() // "US Dollar"
faker::finance::currencyCode() // "USD"
faker::finance::currencySymbol() // "$"
faker::finance::accountType() // "Savings"
faker::finance::amount() // "720.18"
faker::finance::iban() // "DE89370400440532013000"
faker::finance::bic() // "DEUTDEFF"
faker::finance::accountNumber() // "12345678"
faker::finance::pin() // "1234"
faker::finance::routingNumber() // "123456789"
faker::finance::creditCardNumber() // "4532-1488-0343-6467"
faker::finance::creditCardCvv() // "123"
faker::finance::bitcoinAddress() // "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
faker::finance::litecoinAddress() // "LU2q3eNKx6rmFGp3uCX8EwvY7qhxBn2pLf"
faker::finance::ethereumAddress() // "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
faker::finance::creditCardExpirationDate() // "03/25"
faker::finance::creditCardType() // "Visa"
```
### ๐ Food Module
```cpp
faker::food::alcoholicBeverage() // "Beer"
faker::food::grain() // "Rice"
faker::food::milkProduct() // "Cheese"
faker::food::fruit() // "Apple"
faker::food::meat() // "Chicken"
faker::food::seafood() // "Salmon"
faker::food::vegetable() // "Carrot"
faker::food::oil() // "Olive Oil"
faker::food::nut() // "Almond"
faker::food::seed() // "Sunflower Seed"
faker::food::sugarProduct() // "Sugar"
faker::food::nonalcoholicBeverage() // "Coffee"
faker::food::dishName() // "Spaghetti Carbonara"
faker::food::foodCategory() // "Italian"
```
### ๐ Git Module
```cpp
faker::git::branch() // "feature/add-login"
faker::git::commitDate() // "Mon Nov 12 14:32:49 2018 -0500"
faker::git::commitEntry() // "commit 4e9d8c7... Author: John Doe..."
faker::git::commitMessage() // "Fix bug in login form"
faker::git::commitSha() // "4e9d8c7a6f3b2e1d0c9b8a7f6e5d4c3b2a1"
```
### ๐จโ๐ป Hacker Module
```cpp
faker::hacker::abbreviation() // "HTTP"
faker::hacker::adjective() // "cross-platform"
faker::hacker::noun() // "protocol"
faker::hacker::verb() // "parse"
faker::hacker::ingverb() // "parsing"
faker::hacker::phrase() // "Try to parse the HTTP protocol!"
```
### ๐ผ๏ธ Image Module
```cpp
faker::image::imageUrl() // "https://loremflickr.com/640/480"
faker::image::urlLoremFlickr() // "https://loremflickr.com/640/480"
faker::image::urlPicsumPhotos() // "https://picsum.photos/640/480"
faker::image::githubAvatarUrl() // "https://avatars.githubusercontent.com/u/9716558"
faker::image::dimensions() // "1920x1080"
faker::image::type() // "png"
faker::image::dataUri() // "data:image/svg+xml;charset=UTF-8,..."
```
### ๐ Internet Module
```cpp
faker::internet::username() // "Richardson.Jeffrey1997"
faker::internet::email() // "Jimenez.Clyde@gmail.com"
faker::internet::exampleEmail() // "Jimenez.Clyde@example.com"
faker::internet::password() // "gXGpe9pKfFcKy9R"
faker::internet::emoji() // "๐"
faker::internet::checkIfEmojiIsValid("๐") // true
faker::internet::protocol() // "https"
faker::internet::httpMethod() // "POST"
faker::internet::httpStatusCode() // 200
faker::internet::httpRequestHeader() // "Content-Type"
faker::internet::httpResponseHeader() // "Cache-Control"
faker::internet::httpMediaType() // "application/json"
faker::internet::ipv4() // "192.168.1.1"
faker::internet::ipv6() // "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
faker::internet::mac() // "00:1B:44:11:3A:B7"
faker::internet::port() // 8080
faker::internet::url() // "https://example.com"
faker::internet::domainName() // "example.com"
faker::internet::domainSuffix() // "com"
faker::internet::domainWord() // "example"
faker::internet::anonymousUsername(15) // "profusebrother"
faker::internet::jwtToken() // "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
faker::internet::jwtAlgorithm() // "HS256"
```
### ๐ Location Module
```cpp
faker::location::country() // "United States"
faker::location::continent() // "North America"
faker::location::countryCode() // "US"
faker::location::state() // "California"
faker::location::city() // "Los Angeles"
faker::location::zipCode() // "90210"
faker::location::streetAddress() // "123 Main St"
faker::location::street() // "Main St"
faker::location::buildingNumber() // "123"
faker::location::secondaryAddress() // "Apt. 4"
faker::location::latitude() // "34.052235"
faker::location::longitude() // "-118.243683"
faker::location::nearbyGPSCoordinate() // {"48.8566", "2.3522"}
faker::location::direction() // "North"
faker::location::ordinalDirection() // "Southeast"
faker::location::timeZone() // "America/Los_Angeles"
faker::location::mgrs() // "17SMD92712525"
```
### ๐ Lorem Module
```cpp
faker::lorem::word() // "temporibus"
faker::lorem::words() // "qui praesentium pariatur"
faker::lorem::wordVector(3) // {"temporibus", "ipsum", "alias"}
faker::lorem::sentence() // "Laborum voluptatem officiis est et."
faker::lorem::sentences() // "Two sentences here. And another one."
faker::lorem::slug() // "hello-world-test"
faker::lorem::paragraph() // "Long paragraph with multiple sentences..."
faker::lorem::paragraphs() // "Multiple paragraphs..."
```
### ๐ฅ Medicine Module
```cpp
faker::medicine::condition() // "Diabetes"
faker::medicine::medicalTest() // "Blood Test"
faker::medicine::specialty() // "Cardiology"
```
### ๐ฅ Movie Module
```cpp
faker::movie::genre() // "Action"
faker::movie::movieTitle() // "The Matrix"
faker::movie::tvShow() // "Breaking Bad"
faker::movie::director() // "Steven Spielberg"
faker::movie::actor() // "Tom Hanks"
faker::movie::actress() // "Meryl Streep"
```
### ๐ถ Music Module
```cpp
faker::music::artist() // "The Beatles"
faker::music::songName() // "Yesterday"
faker::music::genre() // "Rock"
```
### ๐ข Number Module
```cpp
faker::number::integer(1, 100) // 42
faker::number::integer(100) // 57 (0 to max)
faker::number::decimal(0.0, 1.0) // 0.573
faker::number::decimal(10.0) // 5.7 (0 to max)
faker::number::normalDistribution(10, 3) // 12.374
faker::number::hexadecimal(8) // "0xae13d044cb"
faker::number::octal(8) // "0o52561721"
faker::number::binary(8) // "0b01110101"
faker::number::binary(0, 1024) // "0b10110" (range)
faker::number::roman(1, 100) // "XLII"
```
### ๐ง Person Module
```cpp
faker::person::firstName() // "Michael"
faker::person::lastName() // "Smith"
faker::person::fullName() // "Michael Smith"
faker::person::prefix() // "Mr."
faker::person::suffix() // "Jr."
faker::person::bio() // "Software engineer passionate about..."
faker::person::sex() // Sex::Male
faker::person::gender() // "Male"
faker::person::jobTitle() // "Software Engineer"
faker::person::jobDescriptor() // "Senior"
faker::person::jobArea() // "IT"
faker::person::jobType() // "Developer"
faker::person::hobby() // "Reading"
faker::person::language() // "English"
faker::person::nationality() // "American"
faker::person::ssn() // "123-45-6789"
faker::person::westernZodiac() // "Aries"
faker::person::chineseZodiac() // "Dragon"
faker::person::passport() // "A12345678"
```
### ๐ Phone Module
```cpp
faker::phone::phoneNumberByFormat() // "961-770-7727"
faker::phone::phoneNumberByFormat("501-###-###") // "501-039-841"
faker::phone::phoneNumberByCountry() // "234-532-654"
faker::phone::platform() // "iOS"
faker::phone::modelName() // "Samsung Galaxy S22"
faker::phone::manufacturer() // "Apple"
faker::phone::imei() // "13-850175-913761-7"
faker::phone::areaCode() // "+1"
```
### ๐ชด Plant Module
```cpp
faker::plant::tree() // "Oak"
faker::plant::flower() // "Rose"
faker::plant::shrub() // "Azalea"
faker::plant::grass() // "Kentucky Bluegrass"
faker::plant::fern() // "Maidenhair"
faker::plant::succulent() // "Aloe Vera"
faker::plant::vine() // "Ivy"
faker::plant::plantType() // "tree"
```
### ๐งโ๐ฌ Science Module
```cpp
faker::science::chemicalElement() // {name: "Hydrogen", symbol: "H", atomicNumber: 1}
faker::science::unit() // {name: "meter", symbol: "m", usedToMeasure: "length"}
faker::science::distanceUnit() // {name: "meter", symbol: "m", usedToMeasure: "length"}
faker::science::timeUnit() // {name: "second", symbol: "s", usedToMeasure: "time"}
faker::science::massUnit() // {name: "gram", symbol: "g", usedToMeasure: "mass"}
faker::science::tempUnit() // {name: "celsius", symbol: "ยฐC", usedToMeasure: "temperature"}
faker::science::currentUnit() // {name: "ampere", symbol: "A", usedToMeasure: "current"}
```
### โฝ Sport Module
```cpp
faker::sport::sportName() // "Football"
faker::sport::soccerTeam() // "Manchester United"
faker::sport::maleAthlete() // "Cristiano Ronaldo"
faker::sport::femaleAthlete() // "Serena Williams"
faker::sport::sportEvent() // "Super Bowl"
```
### ๐ข String Module
```cpp
faker::string::uuidV1() // "29915d84-c5e8-11ef-9cd2-0242ac120002"
faker::string::uuidV3() // "c6437ef1-5b86-3a4e-a071-c2d4ad414e65"
faker::string::uuidV4() // "78754621-9544-4c79-9c1d-76d3ba881f53"
faker::string::uuidV5("hello") // "6c7f25c1-1f94-53df-aab6-627ed664b1a7"
faker::string::uuidV6() // "1efc5e90-f32e-6420-bab1-7bdb35fa2abb"
faker::string::uuidV7() // "0194129b-f344-783c-ab87-d1a79bcf9a4e"
faker::string::ulid() // "0001C7STHC0G2081040G208104"
faker::string::sample(10) // "Zo!.:*e>wR"
faker::string::symbol(5) // "#$%^&"
faker::string::fromCharacters("abc", 5) // "abcab"
faker::string::alpha(10) // "aBcDeFgHiJ"
faker::string::alphanumeric(10) // "aB3cD5eF7g"
faker::string::numeric(10) // "1234567890"
faker::string::nanoId() // "Hf5lN8L2wQ"
faker::string::nanoId(21) // "V2JlO7GZ1kPl9FxErRqzS"
faker::string::isValidGuarantee(...) // true/false
faker::string::generateAtLeastString(...)// "000aaaaaa"
```
### ๐ป System Module
```cpp
faker::system::fileName() // "injustice.mpeg"
faker::system::fileExtension() // "pdf"
faker::system::commonFileName() // "dollar.jpg"
faker::system::commonFileExtension() // "gif"
faker::system::mimeType() // "video/vnd.vivo"
faker::system::fileType() // "audio"
faker::system::directoryPath() // "/etc/mail"
faker::system::filePath() // "/usr/local/src/money.dotx"
faker::system::semver() // "1.1.2"
faker::system::networkInterface() // "enp2s7f8"
faker::system::cron() // "22 * ? * ?"
```
### ๐ Vehicle Module
```cpp
faker::vehicle::bicycle() // "Mountain Bike"
faker::vehicle::color() // "Red"
faker::vehicle::fuel() // "Gasoline"
faker::vehicle::manufacturer() // "Toyota"
faker::vehicle::model() // "Camry"
faker::vehicle::type() // "Sedan"
faker::vehicle::vehicleName() // "Toyota Camry"
faker::vehicle::vin() // "WBADT43452G918366"
faker::vehicle::vrm() // "AB12CDE"
```
### ๐๏ธ Video Module
```cpp
faker::video::formatName() // "MP4"
faker::video::fileExtension() // "mp4"
faker::video::videoCodec() // "H.264"
faker::video::audioCodec() // "AAC"
faker::video::resolution() // "1920x1080"
faker::video::aspectRatio() // "16:9"
faker::video::videoUrl() // "https://youtube.com/watch?v=..."
```
### ๐ฎ Video Game Module
```cpp
faker::videogame::gameTitle() // "Minecraft"
faker::videogame::genre() // "Action"
faker::videogame::platform() // "PlayStation 5"
faker::videogame::studioName() // "Mojang Studios"
```
### ๐ค๏ธ Weather Module
```cpp
faker::weather::weatherDescription() // "Partly cloudy"
```
### ๐ฌ Word Module
```cpp
faker::word::sample() // "protection"
faker::word::sample(5) // "spell"
faker::word::words(3) // "before hourly patiently"
faker::word::adjective() // "complete"
faker::word::adjectiveLocale(5, locale) // "brave" (with locale)
faker::word::adverb() // "deliberately"
faker::word::conjunction() // "because"
faker::word::interjection() // "psst"
faker::word::noun() // "pudding"
faker::word::preposition() // "besides"
faker::word::verb() // "override"
```
## ๐ Supported Locales
**40+ locales supported** including:
`en_US` (default), `en_GB`, `pl_PL`, `de_DE`, `de_AT`, `de_CH`, `fr_FR`, `fr_BE`, `fr_CH`, `it_IT`, `es_ES`, `es_MX`, `pt_PT`, `pt_BR`, `ru_RU`, `uk_UA`, `cs_CZ`, `sk_SK`, `sv_SE`, `nb_NO`, `da_DK`, `fi_FI`, `nl_NL`, `nl_BE`, `tr_TR`, `ro_RO`, `hu_HU`, `hr_HR`, `sl_SI`, `sr_RS`, `bg_BG`, `el_GR`, `hi_IN`, `en_IN`, `zh_CN`, `zh_TW`, `ja_JP`, `ko_KR`
**Usage:**
```cpp
faker::person::firstName(faker::Locale::pl_PL); // "Krystyna"
faker::location::city(faker::Locale::fr_FR); // "Lyon"
```
## Consuming the library with CMake
### With Git submodules and add_library
1. Add faker to git submodules (execute in project root):
```bash
mkdir externals && cd externals
git submodule add https://github.com/cieslarmichal/faker-cxx.git
git submodule update --init --recursive
```
2. Link with library:
```cmake
set(FAKER_BUILD_TESTING OFF)
add_subdirectory(externals/faker-cxx)
add_executable(main Main.cpp)
target_link_libraries(main faker-cxx)
```
### With FetchContent
```cmake
set(FAKER_BUILD_TESTING OFF)
FetchContent_Declare(faker
GIT_REPOSITORY https://github.com/cieslarmichal/faker-cxx.git
GIT_TAG main
)
FetchContent_MakeAvailable(faker)
add_executable(main Main.cpp)
target_link_libraries(main faker-cxx)
```
## Installing the library with [vcpkg](https://vcpkg.io/)
You can install faker-cxx using the [vcpkg](https://vcpkg.io/) dependency manager:
```bash
vcpkg install faker-cxx
```
The faker-cxx port in vcpkg is kept up to date by Microsoft team members and community contributors.
If the version is out of date, please [create an issue or pull request](https://github.com/microsoft/vcpkg) on the vcpkg repository.
Then in your CMakeLists.txt:
```cmake
find_package(faker-cxx CONFIG REQUIRED)
add_executable(main Main.cpp)
target_link_libraries(main PRIVATE faker-cxx::faker-cxx)
```
## โ๏ธ Compiler support
- [MSVCโ](https://en.wikipedia.org/wiki/Microsoft_Visual_Studio) version 143 or newer.
- [GCCโ](https://gcc.gnu.org/) version 13 or newer.
- [Clangโ](https://clang.llvm.org/) version 16 or newer.
- [Apple Clangโ](https://clang.llvm.org/) version 16 or newer.
## Dependencies
- GTest (set `FAKER_BUILD_TESTING=OFF` CMake flag to disable this dependency)
In order to use external dependencies installed in your system, you can set the `USE_SYSTEM_DEPENDENCIES` CMake flag
to `ON`.
## ๐ฆ Building the library with [Conan](https://conan.io/)
The library can be built using Conan package manager to solve external dependencies.
To build the library with Conan, follow the steps below:
1. Install required dependencies:
```bash
conan install conanfile.txt --build=missing
```
2. Build the library:
```bash
cmake --preset=conan-release -DUSE_SYSTEM_DEPENDENCIES:BOOL=ON
cmake --build --preset=conan-release
```
## Installing the library with [Conan](https://conan.io/)
You can install pre-built binaries for faker-cxx or build it from source using Conan. Use the following command:
```bash
conan install --requires="faker-cxx/[*]" --build=missing
```
The faker-cxx Conan recipe is kept up to date by Conan maintainers and community contributors.
If the version is out of date, please [create an issue or pull request](https://github.com/conan-io/conan-center-index)
on the ConanCenterIndex repository.
## Building the library with [Bazel](https://bazel.build/)
As alternative, this project can be built using [Bazel](https://bazel.build/). The dependencies are managed directly by
Bazel modules, downloading and building all external dependencies. Follow the steps below to build the project:
1. **Navigate to the project directory:**
```sh
cd /path/to/faker-cxx
```
2. **Build the project:**
```sh
bazel build //:faker-cxx
```
## โจ Contributing
We would love it if you contributed to Faker C++! ๐
Check our guides on how to build the project locally:
- **[Complete Building Guide](./docs/guides/BUILDING.md)** - All compilers in one place
- [GCC](./docs/guides/BUILDING.md#gcc-linux)
- [Clang](./docs/guides/BUILDING.md#clang-linux)
- [Apple Clang](./docs/guides/BUILDING.md#apple-clang-macos)
- [MSVC](./docs/guides/BUILDING.md#msvc-windows)
Please make sure to read the [Contributing Guide](https://github.com/cieslarmichal/faker-cxx/blob/main/CONTRIBUTING.md)
before making a pull request.
Additionally, we encourage you to join our [Discord Channel](https://discord.gg/h2ur8H6mK6) for contributors.
## ๐ Credits
Thanks to all the people who already contributed to Faker!
## ๐ Changelog
Detailed changes for each release are documented in the [release notes](CHANGELOG.md).
## ๐ License
This project is under [MIT](LICENSE) license.