制作者的介绍仅有上面的一句话。 更多详情请阅读仓库 README。 仓库 README ↗
正在加载完整 README。
查看完整 README ↗Requires C++23 (e.g.,
-std=c++23for GCC/Clang,/std:c++latestfor MSVC).
API Reference · Usage Guide · Data and Method · Releases
Employment status, education and occupation by country, age and sex. A call draws a status (employed, unemployed, student, retired or inactive), an education level and, for anyone who is not a student, a job with its ISCO-08 group, skills, gear and tags, from labour force statistics for 213 countries and territories.
Measured by Country, Sex and Age. Employment status, education and the share of each ISCO-08 occupation group come from the ILO's labour force statistics (ILOSTAT): 139 to 185 countries surveyed since 2010, and a regional mean for the rest. The job catalogue (95 jobs in lite, 320 in full, with skills, gear and tags) is curated. Data and Method says which rows are which.
Age and Education Shape the Job. A job's weight is the country's share for the sex, times how common its group is at the person's age and education. Young people do not become judges, and the educated are not often refuse collectors.
Income. An employed person has a gross annual income in their country's currency (core::money), from ILOSTAT's earnings by country, sex, occupation group, age and education, with pay within a group from four national surveys; Taiwan, Japan, Korea, Hong Kong and Macau take their level from their statistics offices, and every country's spread matches its measured Gini. 201 countries; the rest of the result is the same as without it.
Request-First Generation. Every call takes an occupation_request with country, age, sex, education and status. No mutable generation defaults; data loading and layers stay on the instance.
Deterministic Seeding. Per-call get_occupation(request, seed) for reproducible results and occupation::seed() for replaying a previous generation. For deterministic sequences, supply seeds from a caller-owned dasmig::core::rng.
Batch Generation. Generate thousands of results from one seed, on several threads with the same output for any thread count, optionally unique by a key, and stream them as JSON Lines or CSV (see the usage guide).
Identical Everywhere. A seed gives the same result on every compiler, standard library and CPU (GCC, Clang, MSVC, Emscripten; x86-64 and ARM64), checked by known-answer tests.
Extensible Data. Load your own TSV layers on top of the shipped data to add, change or remove entries (extend()), checked before they are applied.
JSON and Replay. to_json() on every result, and a signature() recording the seed and the data it came from.
. Define to build the tier into the program, for WebAssembly and other builds without files.
occupationgen.hpp is the library released here. Keep core.hpp and the core/ directory (dasmig-core) in the same directory. Add
#include <dasmig/occupationgen.hpp>
to the files you want to use it in, and supply the resources folder (or define DASMIG_OCCUPATION_EMBED).
#include <dasmig/occupationgen.hpp>
#include <iostream>
auto& gen = dasmig::ocg::instance(); // loads the lite tier
// A 35-year-old Brazilian woman: status, education and job are drawn.
const dasmig::occupation_request request{.country = "BR", .age = 35, .person_sex = dasmig::sex::female};
auto v = gen.get_occupation(request);
std::cout << v << '\n'; // the job label, for example "Shop assistant"
std::cout << v.to_json() << '\n'; // {"country_code":"BR",...,"status":"employed","job":{...},"signature":{...}}
if (v.job) std::cout << v.job->isco_label << '\n'; // "Sales workers"
// The same seed and request give the same result everywhere.
auto again = gen.get_occupation(request, v.seed());
The only generation overloads are get_occupation(request) and get_occupation(request, seed). Use get_occupation({}) for a random country at the default age of 40, or get_occupation({.country = "US"}) to specify only the country. The old no-argument, country-only and seed-only overloads and instance seed() / unseed() controls have been removed.
See the usage guide for everything else.
make # example
make test # tests
make bench # benchmarks, results in build/bench.tsv
make test-embed # tests with the lite tier compiled in
make coverage # code coverage
make lint # clang-tidy
make docs # API docs
make embed # regenerate dasmig/occupationgen_data.hpp from resources/lite
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 |
| persona-generator |
This library is released under the MIT License.
MIT License
Copyright (c) 2026 Diego Dasso Migotto
DASMIG_OCCUPATION_EMBEDliteMulti-Instance Support. Construct independent ocg instances with their own data and random engine.
| 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 |
| user-generator | Complete user records: account, username, email, phone and address |