Fastly Compute C++ SDK
Loading...
Searching...
No Matches
device_detection.h
Go to the documentation of this file.
1#ifndef FASTLY_DEVICE_DETECTION_H
2#define FASTLY_DEVICE_DETECTION_H
3
4#include <fastly/error.h>
5#include <fastly/sdk-sys.h>
6#include <optional>
7#include <string>
8#include <string_view>
9
11
13class Device {
15 lookup(std::string_view user_agent);
16
17public:
19 std::optional<std::string> device_name();
20
23 std::optional<std::string> brand();
24
26 std::optional<std::string> model();
27
34 std::optional<std::string> hwtype();
35
37 std::optional<bool> is_ereader();
38
40 std::optional<bool> is_gameconsole();
41
44 std::optional<bool> is_mediaplayer();
45
47 std::optional<bool> is_mobile();
48
50 std::optional<bool> is_smarttv();
51
53 std::optional<bool> is_tablet();
54
57 std::optional<bool> is_tvplayer();
58
60 std::optional<bool> is_desktop();
61
63 std::optional<bool> is_touchscreen();
64
65private:
66 rust::Box<fastly::sys::device_detection::Device> dev;
67 Device(rust::Box<fastly::sys::device_detection::Device> d)
68 : dev(std::move(d)) {};
69};
70
72fastly::expected<std::optional<Device>> lookup(std::string_view user_agent);
73
74} // namespace fastly::device_detection
75
76#endif
std::optional< bool > is_gameconsole()
The client device is a video game console (like a PlayStation or Xbox).
friend fastly::expected< std::optional< Device > > lookup(std::string_view user_agent)
Look up the data associated with a particular User-Agent string.
std::optional< bool > is_tvplayer()
std::optional< std::string > model()
The model of the client device.
std::optional< std::string > hwtype()
std::optional< bool > is_mobile()
The client device is a mobile phone.
std::optional< bool > is_mediaplayer()
std::optional< bool > is_desktop()
The client is a desktop web browser.
std::optional< bool > is_ereader()
The client device is a reading device (like a Kindle).
std::optional< bool > is_smarttv()
The client device is a smart TV.
std::optional< std::string > device_name()
The name of the client device.
std::optional< std::string > brand()
std::optional< bool > is_touchscreen()
The client device's screen is touch sensitive.
std::optional< bool > is_tablet()
The client device is a tablet (like an iPad).
Definition device_detection.h:10
fastly::expected< std::optional< Device > > lookup(std::string_view user_agent)
Look up the data associated with a particular User-Agent string.
tl::expected< T, FastlyError > expected
Definition error.h:25