// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
// Based on "crates/store/re_sdk_types/definitions/rerun/blueprint/archetypes/text_log_format.fbs".

#include "text_log_format.hpp"

#include "../../collection_adapter_builtins.hpp"

namespace rerun::blueprint::archetypes {
    TextLogFormat TextLogFormat::clear_fields() {
        auto archetype = TextLogFormat();
        archetype.monospace_body =
            ComponentBatch::empty<rerun::blueprint::components::Enabled>(Descriptor_monospace_body)
                .value_or_throw();
        return archetype;
    }

    Collection<ComponentColumn> TextLogFormat::columns(const Collection<uint32_t>& lengths_) {
        std::vector<ComponentColumn> columns;
        columns.reserve(1);
        if (monospace_body.has_value()) {
            columns.push_back(monospace_body.value().partitioned(lengths_).value_or_throw());
        }
        return columns;
    }

    Collection<ComponentColumn> TextLogFormat::columns() {
        if (monospace_body.has_value()) {
            return columns(std::vector<uint32_t>(monospace_body.value().length(), 1));
        }
        return Collection<ComponentColumn>();
    }
} // namespace rerun::blueprint::archetypes

namespace rerun {

    Result<Collection<ComponentBatch>>
        AsComponents<blueprint::archetypes::TextLogFormat>::as_batches(
            const blueprint::archetypes::TextLogFormat& archetype
        ) {
        using namespace blueprint::archetypes;
        std::vector<ComponentBatch> cells;
        cells.reserve(1);

        if (archetype.monospace_body.has_value()) {
            cells.push_back(archetype.monospace_body.value());
        }

        return rerun::take_ownership(std::move(cells));
    }
} // namespace rerun
