ProductPromotion
Logo

C++ Programming

made by https://0x3d.site

GitHub - cieslarmichal/faker-cxx: C++ Faker library for generating fake (but realistic) data.
C++ Faker library for generating fake (but realistic) data. - cieslarmichal/faker-cxx
Visit Site

GitHub - cieslarmichal/faker-cxx: C++ Faker library for generating fake (but realistic) data.

GitHub - cieslarmichal/faker-cxx: C++ Faker library for generating fake (but realistic) data.

clang++ apple clang++ g++ msvc bazel codecov Conan Center PRs Welcome Chat on Discord

Table of Contents

Introduction

Faker C++ is a C++ library inspired by the popular Faker.js, 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 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.

Below is an example of how to use Faker C++ in your code.

#include <iostream>

#include "faker-cxx/faker.h" // or include specific module

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();
    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:02Z

    return 0;
}

๐Ÿ’Ž Modules

  • ๐Ÿ›ฉ 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
  • ๐Ÿ•น๏ธ Esport - 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 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 enUSTitles, 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
  • ๐ŸŽž๏ธ Video - format name, file extension, video codec, audio codec, resolution, aspect ratio, video url
  • ๐ŸŒค๏ธ Weather - temperature, pressure, humidity, weather description
  • ๐Ÿ’ฌ Word - sample words, nouns, verbs

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:

    set(BUILD_TESTING OFF)
    
    add_subdirectory(externals/faker-cxx)
    
    add_executable(main Main.cpp)
    
    target_link_libraries(main faker-cxx)
    

With FetchContent

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

Dependencies

  • 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:

  1. Install required dependencies:

    conan install conanfile.txt --build=missing
    
  2. Build the library:

    cmake --preset=conan-release -DUSE_SYSTEM_DEPENDENCIES:BOOL=ON
    cmake --build --preset=conan-release
    

Installing the library with Conan

You can install pre-built binaries for faker-cxx or build it from source using Conan. Use the following command:

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 on the ConanCenterIndex repository.

Building the library with Bazel

As alternative, this project can be built using Bazel. 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:

    cd /path/to/faker-cxx
    
  2. Build the project:

    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:

Please make sure to read the Contributing Guide before making a pull request.

Additionally, we encourage you to join our Discord Channel for contributors.

๐Ÿ“˜ Credits

Thanks to all the people who already contributed to Faker!

Examples

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++.

๐Ÿ“ Changelog

Detailed changes for each release are documented in the release notes.

๐Ÿ”‘ License

This project is under MIT license.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory