Device Generator 1.0.3
Devices, browsers, user agents and IP addresses that fit together for C++23
Loading...
Searching...
No Matches
dasmig::device Class Reference

Return type for device generation. More...

#include <devicegen.hpp>

Public Member Functions

std::uint64_t seed () const
 Retrieve the random seed used to generate this device.
 
const core::seed_signature & signature () const
 The seed and the data this device was generated from.
 
std::string to_string () const
 Human-readable summary string.
 
void to_json (core::json_writer &w) const
 Write this device as a JSON object.
 
std::string to_json () const
 This device as a JSON document.
 
 operator std::string () const
 Implicit conversion to std::string.
 

Static Public Member Functions

static std::string browser_name (std::string_view key)
 The display name of a browser key (chrome gives Chrome).
 

Public Attributes

std::string country_code
 ISO 3166-1 alpha-2 code.
 
std::string platform
 Platform key (android-phone, ...).
 
std::string platform_label
 Display label of the platform.
 
std::string kind
 phone, tablet, desktop or other.
 
std::string maker
 Maker (Samsung, Apple, Lenovo); may be empty.
 
std::string model
 Model name (Galaxy A54); empty for most desktops.
 
std::string os
 Operating system (Android, iOS, Windows, ...).
 
std::string os_version
 OS version (14, 17.5, 10.15); empty where none is modelled.
 
std::string browser
 Browser key (chrome, safari, ...); empty for other.
 
std::string browser_version
 Browser version (126, 17.5, 25.0).
 
std::string engine
 Blink, WebKit or Gecko.
 
std::string user_agent
 The User-Agent header this device sends.
 
std::string accept_language
 The Accept-Language header; empty without a locale.
 
std::string sec_ch_ua
 The Sec-CH-UA client hint (Chrome and Edge 96 and later, not on iOS); empty otherwise.
 
std::string sec_ch_ua_mobile
 The Sec-CH-UA-Mobile client hint (?1 on phones, ?0 otherwise); empty when not sent.
 
std::string sec_ch_ua_platform
 The Sec-CH-UA-Platform client hint ("Android", "Windows", ...); empty when not sent.
 
device_screen screen
 The screen.
 
std::string ip
 IP address (dotted quad or RFC 5952 text).
 
int ip_version {4}
 4 or 6.
 
bool reserved {false}
 The address is from a documentation range.
 

Friends

class dvg
 
std::ostream & operator<< (std::ostream &os, const device &v)
 Stream the summary to an output stream.
 

Detailed Description

Return type for device generation.

Supports implicit conversion to std::string (a one-line summary), streaming via operator<< and JSON output via to_json().

Definition at line 133 of file devicegen.hpp.

Member Function Documentation

◆ browser_name()

static std::string dasmig::device::browser_name ( std::string_view  key)
inlinestatic

The display name of a browser key (chrome gives Chrome).

Parameters
keyA browser key.
Returns
The name, or the key itself when it is not one of the shipped browsers.

Definition at line 252 of file devicegen.hpp.

◆ operator std::string()

dasmig::device::operator std::string ( ) const
inline

Implicit conversion to std::string.

Returns
Summary string.

Definition at line 234 of file devicegen.hpp.

◆ seed()

std::uint64_t dasmig::device::seed ( ) const
inline

Retrieve the random seed used to generate this device.

Returns
The call seed; pass it to get_device(request, seed) with the same request and data to replay this device.

Definition at line 160 of file devicegen.hpp.

◆ signature()

const core::seed_signature & dasmig::device::signature ( ) const
inline

The seed and the data this device was generated from.

Returns
The replay signature; data is dvg::data_hash() at the time of generation.

Definition at line 165 of file devicegen.hpp.

◆ to_json() [1/2]

std::string dasmig::device::to_json ( ) const
inline

This device as a JSON document.

Returns
Compact JSON.

Definition at line 225 of file devicegen.hpp.

◆ to_json() [2/2]

void dasmig::device::to_json ( core::json_writer &  w) const
inline

Write this device as a JSON object.

Parameters
wWriter positioned where a value is allowed.

Definition at line 187 of file devicegen.hpp.

◆ to_string()

std::string dasmig::device::to_string ( ) const
inline

Human-readable summary string.

Returns
For example Chrome 126 on Android 14 (Samsung Galaxy A54), 203.0.113.7.

Definition at line 169 of file devicegen.hpp.

Friends And Related Symbol Documentation

◆ dvg

friend class dvg
friend

Definition at line 266 of file devicegen.hpp.

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const device &  v 
)
friend

Stream the summary to an output stream.

Parameters
osOutput stream.
vThe device to stream.
Returns
The stream.

Definition at line 243 of file devicegen.hpp.

Member Data Documentation

◆ accept_language

std::string dasmig::device::accept_language

The Accept-Language header; empty without a locale.

Definition at line 148 of file devicegen.hpp.

◆ browser

std::string dasmig::device::browser

Browser key (chrome, safari, ...); empty for other.

Definition at line 144 of file devicegen.hpp.

◆ browser_version

std::string dasmig::device::browser_version

Browser version (126, 17.5, 25.0).

Definition at line 145 of file devicegen.hpp.

◆ country_code

std::string dasmig::device::country_code

ISO 3166-1 alpha-2 code.

Definition at line 136 of file devicegen.hpp.

◆ engine

std::string dasmig::device::engine

Blink, WebKit or Gecko.

Definition at line 146 of file devicegen.hpp.

◆ ip

std::string dasmig::device::ip

IP address (dotted quad or RFC 5952 text).

Definition at line 153 of file devicegen.hpp.

◆ ip_version

int dasmig::device::ip_version {4}

4 or 6.

Definition at line 154 of file devicegen.hpp.

◆ kind

std::string dasmig::device::kind

phone, tablet, desktop or other.

Definition at line 139 of file devicegen.hpp.

◆ maker

std::string dasmig::device::maker

Maker (Samsung, Apple, Lenovo); may be empty.

Definition at line 140 of file devicegen.hpp.

◆ model

std::string dasmig::device::model

Model name (Galaxy A54); empty for most desktops.

Definition at line 141 of file devicegen.hpp.

◆ os

std::string dasmig::device::os

Operating system (Android, iOS, Windows, ...).

Definition at line 142 of file devicegen.hpp.

◆ os_version

std::string dasmig::device::os_version

OS version (14, 17.5, 10.15); empty where none is modelled.

Definition at line 143 of file devicegen.hpp.

◆ platform

std::string dasmig::device::platform

Platform key (android-phone, ...).

Definition at line 137 of file devicegen.hpp.

◆ platform_label

std::string dasmig::device::platform_label

Display label of the platform.

Definition at line 138 of file devicegen.hpp.

◆ reserved

bool dasmig::device::reserved {false}

The address is from a documentation range.

Definition at line 155 of file devicegen.hpp.

◆ screen

device_screen dasmig::device::screen

The screen.

Definition at line 152 of file devicegen.hpp.

◆ sec_ch_ua

std::string dasmig::device::sec_ch_ua

The Sec-CH-UA client hint (Chrome and Edge 96 and later, not on iOS); empty otherwise.

Definition at line 149 of file devicegen.hpp.

◆ sec_ch_ua_mobile

std::string dasmig::device::sec_ch_ua_mobile

The Sec-CH-UA-Mobile client hint (?1 on phones, ?0 otherwise); empty when not sent.

Definition at line 150 of file devicegen.hpp.

◆ sec_ch_ua_platform

std::string dasmig::device::sec_ch_ua_platform

The Sec-CH-UA-Platform client hint ("Android", "Windows", ...); empty when not sent.

Definition at line 151 of file devicegen.hpp.

◆ user_agent

std::string dasmig::device::user_agent

The User-Agent header this device sends.

Definition at line 147 of file devicegen.hpp.


The documentation for this class was generated from the following file: