Rerun C++ SDK
Loading...
Searching...
No Matches
text.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/text.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 string of text, e.g. for labels and text documents.
16 struct Text {
18
19 public: // START of extensions from text_ext.cpp:
20 /// Construct `Text` from a null-terminated UTF8 string.
21 Text(const char* str) : value(str) {}
22
23 const char* c_str() const {
24 return value.c_str();
25 }
26
27 // END of extensions from text_ext.cpp, start of generated code:
28
29 public:
30 Text() = default;
31
32 Text(rerun::datatypes::Utf8 value_) : value(std::move(value_)) {}
33
34 Text& operator=(rerun::datatypes::Utf8 value_) {
35 value = std::move(value_);
36 return *this;
37 }
38
39 Text(std::string value_) : value(std::move(value_)) {}
40
41 Text& operator=(std::string value_) {
42 value = std::move(value_);
43 return *this;
44 }
45
46 /// Cast to the underlying Utf8 datatype
47 operator rerun::datatypes::Utf8() const {
48 return value;
49 }
50 };
51} // namespace rerun::components
52
53namespace rerun {
54 static_assert(sizeof(rerun::datatypes::Utf8) == sizeof(components::Text));
55
56 /// \private
57 template <>
58 struct Loggable<components::Text> {
59 static constexpr const char Name[] = "rerun.components.Text";
60
61 /// Returns the arrow data type this type corresponds to.
62 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
63 return Loggable<rerun::datatypes::Utf8>::arrow_datatype();
64 }
65
66 /// Serializes an array of `rerun::components::Text` into an arrow array.
67 static Result<std::shared_ptr<arrow::Array>> to_arrow(
68 const components::Text* instances, size_t num_instances
69 ) {
70 if (num_instances == 0) {
71 return Loggable<rerun::datatypes::Utf8>::to_arrow(nullptr, 0);
72 } else if (instances == nullptr) {
73 return rerun::Error(
74 ErrorCode::UnexpectedNullArgument,
75 "Passed array instances is null when num_elements> 0."
76 );
77 } else {
78 return Loggable<rerun::datatypes::Utf8>::to_arrow(&instances->value, num_instances);
79 }
80 }
81 };
82} // 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 string of text, e.g. for labels and text documents.
Definition text.hpp:16
Text(const char *str)
Construct Text from a null-terminated UTF8 string.
Definition text.hpp:21
Datatype: A string of text, encoded as UTF-8.
Definition utf8.hpp:21