Rerun C++ SDK
Loading...
Searching...
No Matches
text_document.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/archetypes/text_document.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/media_type.hpp"
10#include "../components/text.hpp"
11#include "../indicator_component.hpp"
12#include "../result.hpp"
13
14#include <cstdint>
15#include <optional>
16#include <utility>
17#include <vector>
18
19namespace rerun::archetypes {
20 /// **Archetype**: A text element intended to be displayed in its own text box.
21 ///
22 /// Supports raw text and markdown.
23 ///
24 /// ## Example
25 ///
26 /// ### Markdown text document
27 /// ![image](https://static.rerun.io/textdocument/babda19558ee32ed8d730495b595aee7a5e2c174/full.png)
28 ///
29 /// ```cpp
30 /// #include <rerun.hpp>
31 ///
32 /// int main() {
33 /// const auto rec = rerun::RecordingStream("rerun_example_text_document");
34 /// rec.spawn().exit_on_failure();
35 ///
36 /// rec.log("text_document", rerun::TextDocument("Hello, TextDocument!"));
37 ///
38 /// rec.log(
39 /// "markdown",
40 /// rerun::TextDocument(R"#(# Hello Markdown!
41 /// [Click here to see the raw text](recording://markdown:Text).
42 ///
43 /// Basic formatting:
44 ///
45 /// | **Feature** | **Alternative** |
46 /// | ----------------- | --------------- |
47 /// | Plain | |
48 /// | *italics* | _italics_ |
49 /// | **bold** | __bold__ |
50 /// | ~~strikethrough~~ | |
51 /// | `inline code` | |
52 ///
53 /// ----------------------------------
54 ///
55 /// ## Support
56 /// - [x] [Commonmark](https://commonmark.org/help/) support
57 /// - [x] GitHub-style strikethrough, tables, and checkboxes
58 /// - Basic syntax highlighting for:
59 /// - [x] C and C++
60 /// - [x] Python
61 /// - [x] Rust
62 /// - [ ] Other languages
63 ///
64 /// ## Links
65 /// You can link to [an entity](recording://markdown),
66 /// a [specific instance of an entity](recording://markdown[#0]),
67 /// or a [specific component](recording://markdown:Text).
68 ///
69 /// Of course you can also have [normal https links](https://github.com/rerun-io/rerun), e.g. <https://rerun.io>.
70 ///
71 /// ## Image
72 /// ![A random image](https://picsum.photos/640/480))#")
73 /// .with_media_type(rerun::MediaType::markdown())
74 /// );
75 /// }
76 /// ```
77 struct TextDocument {
78 /// Contents of the text document.
79 std::optional<ComponentBatch> text;
80
81 /// The Media Type of the text.
82 ///
83 /// For instance:
84 /// * `text/plain`
85 /// * `text/markdown`
86 ///
87 /// If omitted, `text/plain` is assumed.
88 std::optional<ComponentBatch> media_type;
89
90 public:
91 static constexpr const char IndicatorComponentName[] =
92 "rerun.components.TextDocumentIndicator";
93
94 /// Indicator component, used to identify the archetype when converting to a list of components.
96 /// The name of the archetype as used in `ComponentDescriptor`s.
97 static constexpr const char ArchetypeName[] = "rerun.archetypes.TextDocument";
98
99 /// `ComponentDescriptor` for the `text` field.
100 static constexpr auto Descriptor_text = ComponentDescriptor(
102 );
103 /// `ComponentDescriptor` for the `media_type` field.
105 ArchetypeName, "media_type",
107 );
108
109 public:
110 TextDocument() = default;
111 TextDocument(TextDocument&& other) = default;
112 TextDocument(const TextDocument& other) = default;
113 TextDocument& operator=(const TextDocument& other) = default;
114 TextDocument& operator=(TextDocument&& other) = default;
115
117 : text(ComponentBatch::from_loggable(std::move(_text), Descriptor_text).value_or_throw()
118 ) {}
119
120 /// Update only some specific fields of a `TextDocument`.
122 return TextDocument();
123 }
124
125 /// Clear all the fields of a `TextDocument`.
127
128 /// Contents of the text document.
130 text = ComponentBatch::from_loggable(_text, Descriptor_text).value_or_throw();
131 return std::move(*this);
132 }
133
134 /// This method makes it possible to pack multiple `text` in a single component batch.
135 ///
136 /// This only makes sense when used in conjunction with `columns`. `with_text` should
137 /// be used when logging a single row's worth of data.
139 text = ComponentBatch::from_loggable(_text, Descriptor_text).value_or_throw();
140 return std::move(*this);
141 }
142
143 /// The Media Type of the text.
144 ///
145 /// For instance:
146 /// * `text/plain`
147 /// * `text/markdown`
148 ///
149 /// If omitted, `text/plain` is assumed.
151 media_type =
152 ComponentBatch::from_loggable(_media_type, Descriptor_media_type).value_or_throw();
153 return std::move(*this);
154 }
155
156 /// This method makes it possible to pack multiple `media_type` in a single component batch.
157 ///
158 /// This only makes sense when used in conjunction with `columns`. `with_media_type` should
159 /// be used when logging a single row's worth of data.
162 ) && {
163 media_type =
164 ComponentBatch::from_loggable(_media_type, Descriptor_media_type).value_or_throw();
165 return std::move(*this);
166 }
167
168 /// Partitions the component data into multiple sub-batches.
169 ///
170 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
171 /// instead, via `ComponentBatch::partitioned`.
172 ///
173 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
174 ///
175 /// The specified `lengths` must sum to the total length of the component batch.
177
178 /// Partitions the component data into unit-length sub-batches.
179 ///
180 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
181 /// where `n` is automatically guessed.
183 };
184
185} // namespace rerun::archetypes
186
187namespace rerun {
188 /// \private
189 template <typename T>
190 struct AsComponents;
191
192 /// \private
193 template <>
194 struct AsComponents<archetypes::TextDocument> {
195 /// Serialize all set component batches.
196 static Result<Collection<ComponentBatch>> as_batches(
197 const archetypes::TextDocument& archetype
198 );
199 };
200} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
A class for representing either a usable value, or an error.
Definition result.hpp:14
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:76
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Arrow-encoded data of a single batch of components together with a component descriptor.
Definition component_batch.hpp:28
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor=rerun::Loggable< T >::Descriptor)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:46
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:14
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
Archetype: A text element intended to be displayed in its own text box.
Definition text_document.hpp:77
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition text_document.hpp:97
static TextDocument update_fields()
Update only some specific fields of a TextDocument.
Definition text_document.hpp:121
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
std::optional< ComponentBatch > media_type
The Media Type of the text.
Definition text_document.hpp:88
static constexpr auto Descriptor_media_type
ComponentDescriptor for the media_type field.
Definition text_document.hpp:104
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
static constexpr auto Descriptor_text
ComponentDescriptor for the text field.
Definition text_document.hpp:100
TextDocument with_text(const rerun::components::Text &_text) &&
Contents of the text document.
Definition text_document.hpp:129
std::optional< ComponentBatch > text
Contents of the text document.
Definition text_document.hpp:79
TextDocument with_many_text(const Collection< rerun::components::Text > &_text) &&
This method makes it possible to pack multiple text in a single component batch.
Definition text_document.hpp:138
TextDocument with_media_type(const rerun::components::MediaType &_media_type) &&
The Media Type of the text.
Definition text_document.hpp:150
static TextDocument clear_fields()
Clear all the fields of a TextDocument.
TextDocument with_many_media_type(const Collection< rerun::components::MediaType > &_media_type) &&
This method makes it possible to pack multiple media_type in a single component batch.
Definition text_document.hpp:160
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:32
Component: A standardized media type (RFC2046, formerly known as MIME types), encoded as a string.
Definition media_type.hpp:21
Component: A string of text, e.g. for labels and text documents.
Definition text.hpp:17