Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

C++ Faker library for generating fake (but realistic) data.

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.faker-js
NotificationsYou must be signed in to change notification settings

cieslarmichal/faker-cxx

Repository files navigation

C++ Faker, a powerful tool for generating realistic and randomized fake data in C++ programming, enhancing data testing and development workflows

Faker C++

clang++apple clang++g++msvcbazelcodecovConan CenterPRs WelcomeChat on Discord

Table of Contents

Introduction

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.

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 generatespecific types of data.

🚀 Easy Integration: Seamlessly integrate with CMake, and it supports major compilers like MSVC, GCC, Clang, and AppleClang.

📖 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 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;}

💎 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, 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

Consuming the library with CMake

With Git submodules and add_library

  1. 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
  2. Link with library:

    set(BUILD_TESTINGOFF)add_subdirectory(externals/faker-cxx)add_executable(mainMain.cpp)target_link_libraries(mainfaker-cxx)

With FetchContent

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)

⚒️ Compiler support

Dependencies

  • GTest (setBUILD_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:

  1. Install required dependencies:

    conan install conanfile.txt --build=missing
  2. 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:

  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 theContributing Guidebefore making a pull request.

Additionally, we encourage you to join ourDiscord Channel for contributors.

📘 Credits

Thanks to all the people who already contributed to Faker!

📝 Changelog

Detailed changes for each release are documented in therelease notes.

🔑 License

This project is underMIT license.

About

C++ Faker library for generating fake (but realistic) data.

Topics

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.faker-js

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors110


[8]ページ先頭

©2009-2025 Movatter.jp