Rerun C++ SDK
Loading...
Searching...
No Matches
media_type.hpp
1// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/re_types/definitions/rerun/components/media_type.fbs".
3
4#pragma once
5
6#include "../datatypes/utf8.hpp"
7#include "../result.hpp"
8
9#include <cstdint>
10#include <memory>
11#include <string>
12#include <utility>
13
14namespace rerun::components {
15 /// **Component**: A standardized media type (RFC2046, formerly known as MIME types), encoded as a utf8 string.
16 ///
17 /// The complete reference of officially registered media types is maintained by the IANA and can be
18 /// consulted at <https://www.iana.org/assignments/media-types/media-types.xhtml>.
19 struct MediaType {
21
22 public:
23 // Extensions to generated type defined in 'media_type_ext.cpp'
24
25 /// Construct media type from a null-terminated UTF8 string.
26 MediaType(const char* media_type) : value(media_type) {}
27
28 // TODO(#2388): come up with some DSL in our flatbuffers definitions so that we can
29 // declare these constants directly in there.
30
31 /// `text/plain`
33 return "text/plain";
34 }
35
36 /// `text/markdown`
37 ///
38 /// <https://www.iana.org/assignments/media-types/text/markdown>
40 return "text/markdown";
41 }
42
43 /// [`glTF`](https://en.wikipedia.org/wiki/GlTF): `model/gltf+json`.
44 ///
45 /// <https://www.iana.org/assignments/media-types/model/gltf+json>
46 static MediaType gltf() {
47 return "model/gltf+json";
48 }
49
50 /// [Binary `glTF`](https://en.wikipedia.org/wiki/GlTF): `model/gltf-binary`.
51 ///
52 /// <https://www.iana.org/assignments/media-types/model/gltf-binary>
53 static MediaType glb() {
54 return "model/gltf-binary";
55 }
56
57 /// [Wavefront `obj`](https://en.wikipedia.org/wiki/Wavefront_.obj_file): `model/obj`.
58 ///
59 /// <https://www.iana.org/assignments/media-types/model/obj>
60 static MediaType obj() {
61 return "model/obj";
62 }
63
64 /// [Stereolithography Model `stl`](https://en.wikipedia.org/wiki/STL_(file_format)): `model/stl`.
65 ///
66 /// Either binary or ASCII.
67 /// <https://www.iana.org/assignments/media-types/model/stl>
68 static MediaType stl() {
69 return "model/stl";
70 }
71
72 public:
73 MediaType() = default;
74
75 MediaType(rerun::datatypes::Utf8 value_) : value(std::move(value_)) {}
76
77 MediaType& operator=(rerun::datatypes::Utf8 value_) {
78 value = std::move(value_);
79 return *this;
80 }
81
82 MediaType(std::string value_) : value(std::move(value_)) {}
83
84 MediaType& operator=(std::string value_) {
85 value = std::move(value_);
86 return *this;
87 }
88
89 /// Cast to the underlying Utf8 datatype
90 operator rerun::datatypes::Utf8() const {
91 return value;
92 }
93 };
94} // namespace rerun::components
95
96namespace rerun {
97 static_assert(sizeof(rerun::datatypes::Utf8) == sizeof(components::MediaType));
98
99 /// \private
100 template <>
101 struct Loggable<components::MediaType> {
102 static constexpr const char Name[] = "rerun.components.MediaType";
103
104 /// Returns the arrow data type this type corresponds to.
105 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
106 return Loggable<rerun::datatypes::Utf8>::arrow_datatype();
107 }
108
109 /// Serializes an array of `rerun::components::MediaType` into an arrow array.
110 static Result<std::shared_ptr<arrow::Array>> to_arrow(
111 const components::MediaType* instances, size_t num_instances
112 ) {
113 return Loggable<rerun::datatypes::Utf8>::to_arrow(&instances->value, num_instances);
114 }
115 };
116} // namespace rerun
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:75
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:21
Component: A standardized media type (RFC2046, formerly known as MIME types), encoded as a utf8 strin...
Definition media_type.hpp:19
static MediaType glb()
Binary glTF: model/gltf-binary.
Definition media_type.hpp:53
static MediaType obj()
Wavefront obj: model/obj.
Definition media_type.hpp:60
static MediaType gltf()
glTF: model/gltf+json.
Definition media_type.hpp:46
MediaType(const char *media_type)
Construct media type from a null-terminated UTF8 string.
Definition media_type.hpp:26
static MediaType markdown()
text/markdown
Definition media_type.hpp:39
static MediaType stl()
Stereolithography Model stl: model/stl.
Definition media_type.hpp:68
static MediaType plain_text()
text/plain
Definition media_type.hpp:32
Datatype: A string of text, encoded as UTF-8.
Definition utf8.hpp:21