- 🎯 Goal
- Usage and Documentation
- 💎 Modules
- Consuming library with CMake
- Compiler support
- Dependencies
- Building the library with Conan
- ✨ Contributing
- 📘 Credits
- Examples
- 📝 Changelog
- 🔑 License
The goal of Faker C++ is to provide a library similar to Faker.js for C++ community. Faker C++ helps with the creation of realistic and customizable fake data for testing and development purposes within C++ applications.
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 files depending on the module you wish to generate data from. The module header file names can be found in docs.
Below is an example of how to use Faker C++ in your code.
#include <iostream>
#include "faker-cxx/Date.h"
#include "faker-cxx/Internet.h"
#include "faker-cxx/Location.h"
#include "faker-cxx/String.h"
int main()
{
const auto id = faker::String::uuid();
const auto email = faker::Internet::email();
const auto password = faker::Internet::password();
const auto city = faker::Location::city();
const auto streetAddress = faker::Location::streetAddress();
std::cout << id << std::endl; // 58018063-ce5a-4fa7-adfd-327eb2e2d9a5
std::cout << email << std::endl; // [email protected]
std::cout << password << std::endl; // @cWLwgM#Knalxeb
std::cout << city << std::endl; // Sayre ville
std::cout << streetAddress << std::endl; // 1716 Harriet Alley
return 0;
}
- 🛩 Airline - aircraft types, airlines, airports, flight numbers
- 🐼 Animal - animal types and species
- 📖 Book - book title, genre, author, publisher, ISBN
- 🎨 Color - color names, rgb, hex, hcl
- 🛒 Commerce - commerce department, product name, sku, price
- 🏢 Company - company name, type, industry, catchphrase, buzz phrase
- 🖥️ Computer - type, manufacturer, model, CPU info, GPU info
- 🔐 Crypto - sha256, md5
- 💾 Database - column names, column types, database engines
- ℹ️ Datatype - booleans
- 📅 Date - past, future dates
- 🏦 Finance - currency, IBAN, BIC, account name, account number, pin, credit card numbers
- 🍝 Food - food category, vegetables, fruits, meats, dishes
- 📁 Git - branch names, commit messages, commit hash
- 👨💻 Hacker - hacker words
- ✋ Helper - random element from container
- 🌐 Internet - emails, usernames, passwords, IP, HTTP
- 🖼️ Image - images urls, github avatar urls, image dimensions
- 🌍 Location - countries, cities, zip codes, street addresses
- 📚 Lorem - lorem words, sentences, paragraphs
- 🏥 Medicine - conditions, medical tests, specialties
- 🎥 Movie - actors, actresses, genres, movie titles
- 🎶 Music - artists, song names, genres
- 🔢 Number - random integers, floating point numbers
- 🧑 Person - first, last names, job titles, hobby, genders, sex, nationality, language
- 📞 Phone - phone number, IMEI
- 🪴 Plant - plant type, trees, flowers
- ⚽ Sport - sport names, athletes, events
- 🔢 String - uuids, alphanumeric, numeric, hexadecimal
- 💻 System - file paths, file extensions, file names, directories, semantic version
- 🚗 Vehicle - vehicle types, makes, models, fuel types, license plates
- 🎮 Video game - title, genre, platform, studio
- 🌤️ Weather - temperature, pressure, humidity, weather description
- 💬 Word - sample words, nouns, verbs
-
Add faker to git submodules (execute in project root):
mkdir externals && cd externals git submodule add https://github.com/cieslarmichal/faker-cxx.git git submodule update --init --recursive
-
Link with library:
set(BUILD_TESTING OFF) add_subdirectory(externals/faker-cxx) add_executable(main Main.cpp) target_link_libraries(main faker-cxx)
- MSVC➚ version 143 or newer.
- GCC➚ version 12 or newer.
- Clang➚ version 16 or newer.
- Apple Clang➚ version 16 or newer.
- GTest (set
BUILD_TESTING=OFF
CMake flag to disable this dependency) - fmt (only for compilers that don't support std::format)
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
The library can be built using Conan package manager to solve external dependencies. To build the library with Conan, follow the steps below:
-
Install required dependencies:
conan install conanfile.txt --build=missing
-
Build the library:
cmake --preset=conan-release -DUSE_SYSTEM_DEPENDENCIES:BOOL=ON cmake --build --preset=conan-release
We would love it if you contributed to Faker C++! 🚀
Check our guides on how to build the project locally:
Please make sure to read the Contributing Guide before making a pull request.
Additionally, we encourage you to join our Discord Channel for contributors.
Thanks to all the people who already contributed to Faker!
This project offers examples to demonstrate how to use the Faker C++ library. These examples can be found in the examples folder of the project repository. The examples showcase various modules of the library and provide code snippets that illustrate how to generate fake data using Faker C++.
Detailed changes for each release are documented in the release notes.
This project is under MIT license.