dasmig-core 1.2.0
Shared random engine, distributions and data tiers for the dasmig generator libraries
Loading...
Searching...
No Matches
sex.hpp File Reference

The sex enum shared by every generator library, and its text form. More...

#include <cstdint>
#include <optional>
#include <string_view>

Go to the source code of this file.

Enumerations

enum class  dasmig::sex : std::uint8_t { male , female }
 Biological sex. More...
 

Functions

constexpr std::string_view dasmig::core::sex_name (sex s) noexcept
 The lower-case name of a sex, as written in data files and JSON.
 
constexpr std::optional< sex > dasmig::core::parse_sex (std::string_view text) noexcept
 Reads the name written by sex_name().
 

Detailed Description

The sex enum shared by every generator library, and its text form.

Author
Diego Dasso Migotto (diegomigotto at hotmail dot com)

Definition in file sex.hpp.

Macro Definition Documentation

◆ DASMIG_SEX_DEFINED

#define DASMIG_SEX_DEFINED

Definition at line 18 of file sex.hpp.

Enumeration Type Documentation

◆ sex

enum class dasmig::sex : std::uint8_t
strong

Biological sex.

Enumerator
male 

Male.

female 

Female.

Definition at line 24 of file sex.hpp.

Function Documentation

◆ parse_sex()

constexpr std::optional< sex > dasmig::core::parse_sex ( std::string_view  text)
constexprnoexcept

Reads the name written by sex_name().

Exact and case-sensitive: only "male" and "female" are accepted.

Parameters
textText to read.
Returns
The sex, or an empty optional for any other text.

Definition at line 56 of file sex.hpp.

◆ sex_name()

constexpr std::string_view dasmig::core::sex_name ( sex  s)
constexprnoexcept

The lower-case name of a sex, as written in data files and JSON.

Parameters
sSex.
Returns
"male" or "female"; "unknown" for a value outside the enum.

Definition at line 40 of file sex.hpp.