// 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_rows.fbs".

#include "text_log_rows.hpp"

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

namespace rerun::blueprint::archetypes {
    TextLogRows TextLogRows::clear_fields() {
        auto archetype = TextLogRows();
        archetype.filter_by_log_level =
            ComponentBatch::empty<rerun::components::TextLogLevel>(Descriptor_filter_by_log_level)
                .value_or_throw();
        return archetype;
    }

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

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

namespace rerun {

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

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

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