Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork178
C++ Faker library for generating fake (but realistic) data.
License
MIT, Unknown licenses found
Licenses found
cieslarmichal/faker-cxx
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
- Table of Contents
- Introduction
- Key Features
- 📖 Usage and Documentation
- 💎 Modules
- Consuming the library with CMake
- With Git submodules and add_library
- With FetchContent
- ⚒️ Compiler support
- Dependencies
- 📦 Building the library with Conan
- Installing the library with Conan
- Building the library with Bazel
- ✨ Contributing
- 📘 Credits
- 📝 Changelog
- 🔑 License
Faker C++ is a C++ library inspired by the popularFaker.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.
📚 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 generatespecific types of data.
🚀 Easy Integration: Seamlessly integrate with CMake, and it supports major compilers like MSVC, GCC, Clang, and AppleClang.
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 properheader filedepending on the module you wish to generate data from or use general include filefaker-cxx/faker.h
.All the docs can be foundhere.
Below is an example of how to use Faker C++ in your code.
#include<iostream>#include"faker-cxx/faker.h"// or include specific moduleintmain(){constauto id =faker::string::uuidV4();constauto email =faker::internet::email();constauto password =faker::internet::password();constauto city =faker::location::city();constauto streetAddress =faker::location::streetAddress();constauto 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:02Zreturn0;}
- 🛩 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, Organizer
- 🏦 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, MGRS grid
- 📚 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
- 🎓Education - ShoolNames, Degree Types, Fields Of Study, Courses Names
Add faker to git submodules (execute in project root):
mkdir externals && cd externalsgit submodule add https://github.com/cieslarmichal/faker-cxx.gitgit submodule update --init --recursive
Link with library:
set(BUILD_TESTINGOFF)add_subdirectory(externals/faker-cxx)add_executable(mainMain.cpp)target_link_libraries(mainfaker-cxx)
set(BUILD_TESTINGOFF)FetchContent_Declare(fakerGIT_REPOSITORYhttps://github.com/cieslarmichal/faker-cxx.gitGIT_TAGmain)FetchContent_MakeAvailable(faker)add_executable(mainMain.cpp)target_link_libraries(mainfaker-cxx)
- MSVC➚ version 143 or newer.
- GCC➚ version 13 or newer.
- Clang➚ version 16 or newer.
- Apple Clang➚ version 16 or newer.
- GTest (set
BUILD_TESTING=OFF
CMake flag to disable this dependency)
In order to use external dependencies installed in your system, you can set theUSE_SYSTEM_DEPENDENCIES
CMake flagtoON
.
📦 Building the library withConan
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=ONcmake --build --preset=conan-release
Installing the library withConan
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, pleasecreate an issue or pull requeston the ConanCenterIndex repository.
Building the library withBazel
As alternative, this project can be built usingBazel. The dependencies are managed directly byBazel modules, downloading and building all external dependencies. Follow the steps below to build the project:
Navigate to the project directory:
cd /path/to/faker-cxx
Build the project:
bazel build //:faker-cxx
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 theContributing Guidebefore making a pull request.
Additionally, we encourage you to join ourDiscord Channel for contributors.
Thanks to all the people who already contributed to Faker!
Detailed changes for each release are documented in therelease notes.
This project is underMIT license.
About
C++ Faker library for generating fake (but realistic) data.
Topics
Resources
License
MIT, Unknown licenses found
Licenses found
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.