Rerun C++ SDK
Loading...
Searching...
No Matches
media_type.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/store/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 <filesystem>
11#include <memory>
12#include <string>
13#include <utility>
14
15namespace rerun::components {
16 /// **Component**: A standardized media type (RFC2046, formerly known as MIME types), encoded as a string.
17 ///
18 /// The complete reference of officially registered media types is maintained by the IANA and can be
19 /// consulted at <https://www.iana.org/assignments/media-types/media-types.xhtml>.
20 struct MediaType {
22
23 public: // START of extensions from media_type_ext.cpp:
24 /// Construct media type from a null-terminated UTF8 string.
25 MediaType(const char* media_type) : value(media_type) {}
26
27 // TODO(#2388): come up with some DSL in our flatbuffers definitions so that we can
28 // declare these constants directly in there.
29
30 /// `text/plain`
32 return "text/plain";
33 }
34
35 /// `text/markdown`
36 ///
37 /// <https://www.iana.org/assignments/media-types/text/markdown>
39 return "text/markdown";
40 }
41
42 // ------------------------------------------------
43 // Images:
44
45 /// [JPEG image](https://en.wikipedia.org/wiki/JPEG): `image/jpeg`.
46 static MediaType jpeg() {
47 return "image/jpeg";
48 }
49
50 /// [PNG image](https://en.wikipedia.org/wiki/PNG): `image/png`.
51 ///
52 /// <https://www.iana.org/assignments/media-types/image/png>
53 static MediaType png() {
54 return "image/png";
55 }
56
57 // ------------------------------------------------
58 // Meshes:
59
60 /// [`glTF`](https://en.wikipedia.org/wiki/GlTF): `model/gltf+json`.
61 ///
62 /// <https://www.iana.org/assignments/media-types/model/gltf+json>
63 static MediaType gltf() {
64 return "model/gltf+json";
65 }
66
67 /// [Binary `glTF`](https://en.wikipedia.org/wiki/GlTF): `model/gltf-binary`.
68 ///
69 /// <https://www.iana.org/assignments/media-types/model/gltf-binary>
70 static MediaType glb() {
71 return "model/gltf-binary";
72 }
73
74 /// [Wavefront `obj`](https://en.wikipedia.org/wiki/Wavefront_.obj_file): `model/obj`.
75 ///
76 /// <https://www.iana.org/assignments/media-types/model/obj>
77 static MediaType obj() {
78 return "model/obj";
79 }
80
81 /// [Stereolithography Model `stl`](https://en.wikipedia.org/wiki/STL_(file_format)): `model/stl`.
82 ///
83 /// Either binary or ASCII.
84 /// <https://www.iana.org/assignments/media-types/model/stl>
85 static MediaType stl() {
86 return "model/stl";
87 }
88
89 // -------------------------------------------------------
90 /// Videos:
91
92 /// [MP4 video](https://en.wikipedia.org/wiki/MP4_file_format): `video/mp4`.
93 ///
94 /// <https://www.iana.org/assignments/media-types/video/mp4>
95 static MediaType mp4() {
96 return "video/mp4";
97 }
98
99 static std::optional<MediaType> guess_from_path(const std::filesystem::path& path);
100
101 // END of extensions from media_type_ext.cpp, start of generated code:
102
103 public:
104 MediaType() = default;
105
106 MediaType(rerun::datatypes::Utf8 value_) : value(std::move(value_)) {}
107
108 MediaType& operator=(rerun::datatypes::Utf8 value_) {
109 value = std::move(value_);
110 return *this;
111 }
112
113 MediaType(std::string value_) : value(std::move(value_)) {}
114
115 MediaType& operator=(std::string value_) {
116 value = std::move(value_);
117 return *this;
118 }
119
120 /// Cast to the underlying Utf8 datatype
121 operator rerun::datatypes::Utf8() const {
122 return value;
123 }
124 };
125} // namespace rerun::components
126
127namespace rerun {
128 static_assert(sizeof(rerun::datatypes::Utf8) == sizeof(components::MediaType));
129
130 /// \private
131 template <>
132 struct Loggable<components::MediaType> {
133 static constexpr const char Name[] = "rerun.components.MediaType";
134
135 /// Returns the arrow data type this type corresponds to.
136 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
137 return Loggable<rerun::datatypes::Utf8>::arrow_datatype();
138 }
139
140 /// Serializes an array of `rerun::components::MediaType` into an arrow array.
141 static Result<std::shared_ptr<arrow::Array>> to_arrow(
142 const components::MediaType* instances, size_t num_instances
143 ) {
144 if (num_instances == 0) {
145 return Loggable<rerun::datatypes::Utf8>::to_arrow(nullptr, 0);
146 } else if (instances == nullptr) {
147 return rerun::Error(
148 ErrorCode::UnexpectedNullArgument,
149 "Passed array instances is null when num_elements> 0."
150 );
151 } else {
152 return Loggable<rerun::datatypes::Utf8>::to_arrow(&instances->value, num_instances);
153 }
154 }
155 };
156} // namespace rerun
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:95
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:79
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:22
Component: A standardized media type (RFC2046, formerly known as MIME types), encoded as a string.
Definition media_type.hpp:20
static MediaType glb()
Binary glTF: model/gltf-binary.
Definition media_type.hpp:70
static MediaType obj()
Wavefront obj: model/obj.
Definition media_type.hpp:77
static MediaType gltf()
glTF: model/gltf+json.
Definition media_type.hpp:63
MediaType(const char *media_type)
Construct media type from a null-terminated UTF8 string.
Definition media_type.hpp:25
static MediaType mp4()
Videos:
Definition media_type.hpp:95
static MediaType markdown()
text/markdown
Definition media_type.hpp:38
static MediaType stl()
Stereolithography Model stl: model/stl.
Definition media_type.hpp:85
static MediaType jpeg()
JPEG image: image/jpeg.
Definition media_type.hpp:46
static MediaType png()
PNG image: image/png.
Definition media_type.hpp:53
static MediaType plain_text()
text/plain
Definition media_type.hpp:31
Datatype: A string of text, encoded as UTF-8.
Definition utf8.hpp:21