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