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 arrow {
15 class Array;
16 class DataType;
17 class StringBuilder;
18} // namespace arrow
19
20namespace rerun::components {
21 /// **Component**: A standardized media type (RFC2046, formerly known as MIME types), encoded as a utf8 string.
22 ///
23 /// The complete reference of officially registered media types is maintained by the IANA and can be
24 /// consulted at <https://www.iana.org/assignments/media-types/media-types.xhtml>.
25 struct MediaType {
27
28 public:
29 // Extensions to generated type defined in 'media_type_ext.cpp'
30
31 /// Construct media type from a null-terminated UTF8 string.
32 MediaType(const char* media_type) : value(media_type) {}
33
34 // TODO(#2388): come up with some DSL in our flatbuffers definitions so that we can
35 // declare these constants directly in there.
36
37 /// `text/plain`
39 return "text/plain";
40 }
41
42 /// `text/markdown`
43 ///
44 /// <https://www.iana.org/assignments/media-types/text/markdown>
46 return "text/markdown";
47 }
48
49 /// `glTF`(https://en.wikipedia.org/wiki/GlTF): `model/gltf+json`.
50 ///
51 /// <https://www.iana.org/assignments/media-types/model/gltf+json>
52 static MediaType gltf() {
53 return "model/gltf+json";
54 }
55
56 /// Binary `glTF`(https://en.wikipedia.org/wiki/GlTF): `model/gltf-binary`.
57 ///
58 /// <https://www.iana.org/assignments/media-types/model/gltf-binary>
59 static MediaType glb() {
60 return "model/gltf-binary";
61 }
62
63 /// [Wavefront .obj](https://en.wikipedia.org/wiki/Wavefront_.obj_file): `model/obj`.
64 ///
65 /// <https://www.iana.org/assignments/media-types/model/obj>
66 static MediaType obj() {
67 return "model/obj";
68 }
69
70 public:
71 MediaType() = default;
72
73 MediaType(rerun::datatypes::Utf8 value_) : value(std::move(value_)) {}
74
75 MediaType& operator=(rerun::datatypes::Utf8 value_) {
76 value = std::move(value_);
77 return *this;
78 }
79
80 MediaType(std::string value_) : value(std::move(value_)) {}
81
82 MediaType& operator=(std::string value_) {
83 value = std::move(value_);
84 return *this;
85 }
86
87 /// Cast to the underlying Utf8 datatype
88 operator rerun::datatypes::Utf8() const {
89 return value;
90 }
91 };
92} // namespace rerun::components
93
94namespace rerun {
95 template <typename T>
96 struct Loggable;
97
98 /// \private
99 template <>
100 struct Loggable<components::MediaType> {
101 static constexpr const char Name[] = "rerun.components.MediaType";
102
103 /// Returns the arrow data type this type corresponds to.
104 static const std::shared_ptr<arrow::DataType>& arrow_datatype();
105
106 /// Fills an arrow array builder with an array of this type.
107 static rerun::Error fill_arrow_array_builder(
108 arrow::StringBuilder* builder, const components::MediaType* elements,
109 size_t num_elements
110 );
111
112 /// Serializes an array of `rerun::components::MediaType` into an arrow array.
113 static Result<std::shared_ptr<arrow::Array>> to_arrow(
114 const components::MediaType* instances, size_t num_instances
115 );
116 };
117} // namespace rerun
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:87
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:69
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:20
Component: A standardized media type (RFC2046, formerly known as MIME types), encoded as a utf8 strin...
Definition media_type.hpp:25
static MediaType glb()
Binary glTF(https://en.wikipedia.org/wiki/GlTF): model/gltf-binary.
Definition media_type.hpp:59
static MediaType obj()
Wavefront .obj: model/obj.
Definition media_type.hpp:66
static MediaType gltf()
glTF(https://en.wikipedia.org/wiki/GlTF): model/gltf+json.
Definition media_type.hpp:52
MediaType(const char *media_type)
Construct media type from a null-terminated UTF8 string.
Definition media_type.hpp:32
static MediaType markdown()
text/markdown
Definition media_type.hpp:45
static MediaType plain_text()
text/plain
Definition media_type.hpp:38
Datatype: A string of text, encoded as UTF-8.
Definition utf8.hpp:21