Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 7 days 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 (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-11T20:54:51.000Z (14 days ago)
- Last Synced: 2025-01-12T09:02:27.732Z (14 days ago)
- Topics: cpp, cpp20, data-generation, fake, fake-data, faker
- Language: C++
- Homepage: https://cieslarmichal.github.io/faker-cxx/
- Size: 22.7 MB
- Stars: 326
- Watchers: 8
- Forks: 166
- Open Issues: 41
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-game-engine-dev - faker-cxx - C++20 Faker library for generating fake (but realistic) data for testing and development. (Libraries / C++)
- AwesomeCppGameDev - faker-cxx - C++20 Faker library for generating fake (but realistic) data for testing and development. (C++)
- awesome-faker - C++ - faker-cxx - C++ Faker library for generating fake (but realistic) data. (Languages)
README
Faker C++
[![clang++](https://github.com/cieslarmichal/faker-cxx/actions/workflows/linux-clang-build.yml/badge.svg?branch=main)](https://github.com/cieslarmichal/faker-cxx/actions/workflows/linux-clang-build.yml?query=branch%3Amain)
[![apple clang++](https://github.com/cieslarmichal/faker-cxx/actions/workflows/macos-clang-build.yml/badge.svg?branch=main)](https://github.com/cieslarmichal/faker-cxx/actions/workflows/macos-clang-build.yml?query=branch%3Amain)
[![g++](https://github.com/cieslarmichal/faker-cxx/actions/workflows/linux-gxx-build.yml/badge.svg?branch=main)](https://github.com/cieslarmichal/faker-cxx/actions/workflows/linux-gxx-build.yml?query=branch%3Amain)
[![msvc](https://github.com/cieslarmichal/faker-cxx/actions/workflows/windows-msvc-build.yml/badge.svg?branch=main)](https://github.com/cieslarmichal/faker-cxx/actions/workflows/windows-msvc-build.yml?query=branch%3Amain)
[![bazel](https://github.com/cieslarmichal/faker-cxx/actions/workflows/linux-bazel-build.yml/badge.svg?branch=main)](https://github.com/cieslarmichal/faker-cxx/actions/workflows/linux-bazel-build.yml?query=branch%3Amain)
[![codecov](https://codecov.io/github/cieslarmichal/faker-cxx/branch/main/graph/badge.svg?token=0RTV4JFH2U)](https://codecov.io/github/cieslarmichal/faker-cxx)
[![Conan Center](https://img.shields.io/conan/v/faker-cxx)](https://conan.io/center/recipes/faker-cxx)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
[![Chat on Discord](https://img.shields.io/badge/chat-discord-blue?style=flat&logo=discord)](https://discord.gg/h2ur8H6mK6)## Table of Contents
- [Table of Contents](#table-of-contents)
- [Introduction](#introduction)
- [Key Features](#key-features)
- [๐ Usage and Documentation](#-usage-and-documentation)
- [๐ Modules](#-modules)
- [Consuming the library with CMake](#consuming-the-library-with-cmake)
- [With Git submodules and add\_library](#with-git-submodules-and-add_library)
- [With FetchContent](#with-fetchcontent)
- [โ๏ธ 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.## 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 docs can be found [here](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; // [email protected]
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:02Zreturn 0;
}
```## ๐ Modules
- ๐ฉ Airline - aircraft type, airline, airport, flight number
- ๐ผ Animal - animal type and species
- ๐ Book - title, genre, author, publisher, format, series
- ๐จ Color - name, rgb, hex, hcl, lch, cmyk, lab, hsb, hsv, hwb, yuw
- ๐ Commerce - department, product name, SKU, EAN, ISBN, price, product description, categories
- ๐ข Company - name, type, industry, catchphrase, buzz phrase
- ๐ฅ๏ธ Computer - type, manufacturer, model, CPU info, GPU info
- ๐ Crypto - SHA1, SHA256, MD5
- ๐พ Database - column names, column types, database engines
- โน๏ธ Datatype - booleans
- ๐ Date - past, future, recent, soon date, birthdate, time, month, day of week
- ๐น๏ธ E-sport - player, team, league, event, game
- ๐ฆ Finance - currency, IBAN, BIC, account name, account number, pin, credit card numbers
- ๐ Food - food category, vegetables, fruits, meats, dishes
- ๐ Git - branch name, commit messages, commit hash
- ๐จโ๐ป Hacker - hacker words
- โ Helper - random element, weighted random element
- ๐ผ๏ธ Image - images url, avatar url, image dimensions, type, lorem image, flickr image
- ๐ Internet - email, username, password, emoji, protocol, IP, HTTP, url, domain, mac address, jwt
- ๐ Location - country, continent, city, zip code, state, street address, latitude, longitude, timezone
- ๐ Lorem - words, sentences, paragraphs
- ๐ฅ Medicine - condition, medical test, specialty
- ๐ฅ Movie - title, genre, actor, actress, director, tv show
- ๐ถ Music - artist, song names, genre
- ๐ข Number - integer, decimal, hex, octal, binary
- ๐ง Person - first, last name, job title, nationality, language, passport, ssn, hobby, gender, sex, bio
- ๐ Phone - phone number, area code, IMEI, model, manufacturer
- ๐ชด Plant - plant type, tree, flower
- ๐งโ๐ฌ Science - chemical element, units
- โฝ Sport - sport name, soccer team, athletes, event
- ๐ข String - UUID (V1, V3, V4, V5, V6, V7), ULID, nanoid, alpha, alphanumeric, numeric, sample
- ๐ป System - file name, file type, file path, file extension, directory, semantic version, mime type
- ๐ Vehicle - type, model, fuel type, VIN, VRN, manufacturer, color
- ๐๏ธ Video - format name, file extension, video codec, audio codec, resolution, aspect ratio, video url
- ๐ฎ Video game - title, genre, platform, studio
- ๐ค๏ธ Weather - weather description
- ๐ฌ Word - sample, adjective, adverb, conjunction, interjection, noun, preposition, verb## Consuming the library with CMake
## With Git submodules and add_library
1. 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
```2. Link with library:
```cmake
set(BUILD_TESTING OFF)add_subdirectory(externals/faker-cxx)
add_executable(main Main.cpp)
target_link_libraries(main faker-cxx)
```## With FetchContent
```cmake
set(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)
```## โ๏ธ 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 `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:
- [Clang++](./docs/guides/clang-compilation-guide.md)
- [Apple Clang++](./docs/guides/apple-clang-compilation-guide.md)
- [G++](./docs/guides/gcc-compilation-guide.md)
- [MSVC](./docs/guides/msvc-compilation-guide.md)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.