|
User Generator 2.1.2
Synthetic user records for apps and test data, composed from the other dasmig generators for C++23
|
Requires C++23 (e.g.,
-std=c++23for GCC/Clang,/std:c++latestfor MSVC).
API Reference · Usage Guide · Data and Method · Releases
Synthetic user records for apps, test databases and demos, composed from the other dasmig generators: one call draws a country, a birth and a name, then a username, an email, a phone number, a postal address and an account (password, sign-up and last-login times, status, platform, locale, time zone, currency), and returns them as typed results and one JSON document.
request.device adds the device of the last sign-in from device-generator: a model, OS and browser that fit together at the date of the last login, the user agent and client hints they send, the Accept-Language of the account's locale, a screen and an IP address in the country, on the account's platform. Off by default; turning it on changes nothing else.safe makes the email use a reserved domain (example.com, .net, .org) and the phone number a number from the range regulators set aside for fiction, where the country has one, so a generated user cannot reach anyone; a device then has an IP address from a documentation range.user_request can fix the country, the sex, an age range, the reference date, the password policy, the youngest sign-up age, the service start and the status, and ask for the device. What is left out is drawn.get_user(request, seed) is a pure function of the request, the seed and the data, and user::seed() replays a previous user. Each part draws from its own stream split from the seed, so forcing one choice, such as the status, does not shift the others.extend()); the libraries it composes keep theirs, and their tiers and layers are the user's.to_json() writes each library's result as that library writes it; signature() records the seed and a hash of the data of all seven libraries and the account tables (and device-generator's, for a user with a device).DASMIG_USER_EMBED to build the lite tier of the user tables into the program, for WebAssembly and other builds without files. The libraries it composes have their own DASMIG_*_EMBED switches.usg instances, each with its own tables and its own set of source libraries (usg::sources).usergen.hpp is the library released here. Keep core.hpp and the core/ directory (dasmig-core) in the same directory. Add
to the files you want to use it in, and supply the resources folder (or define DASMIG_USER_EMBED).
user-generator composes these libraries directly and does not use persona-generator: a user has no body, traits, interests, job or city. The two share only the identity core (country, birth, name, nickname).
See the usage guide for everything else.
Tested with:
-std=c++23)-std=c++23)/std:c++latest)| Dependency | Version | Bundled | Purpose |
|---|---|---|---|
| dasmig-core | 1.4 | Yes (core.hpp, core/) | Platform-independent random engine and distributions, data layers, JSON |
| Catch2 | 3.x | Yes (amalgamated) | Unit testing |
| Library | Description |
|---|---|
| address-generator | Postal addresses with real streets by place |
| biodata-generator | Procedural human physical characteristics |
| birth-generator | Demographically plausible birthdays |
| city-generator | Weighted city selection by population |
| country-generator | Weighted country selection by population |
| device-generator | Devices, browsers, user agents and IP addresses that fit together |
| email-generator | Email addresses in each country's style |
| entity-generator | ECS-based entity generation |
| interest-generator | Religion, hobbies and favourite media by country, age and sex |
| name-generator | Culturally appropriate full names |
| nickname-generator | Gamer-style nicknames |
| occupation-generator | Employment status, education and occupation by country, age and sex |
| persona-generator | Complete characters composed from the other generators |
| phone-generator | Phone numbers valid in each country's numbering plan |
| relationship-generator | Families around a person: parents, siblings, partners and children |
| trait-generator | Personality traits with conflicts, synergies and Big Five axes |
This library is released under the MIT License.