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

#pragma once

#include "../collection.hpp"
#include "../datatypes/utf8pair.hpp"
#include "../result.hpp"

#include <cstdint>
#include <memory>
#include <utility>

namespace arrow {
    class Array;
    class DataType;
    class ListBuilder;
} // namespace arrow

namespace rerun::components {
    /// **Component**: A map of string keys to string values.
    ///
    /// This component can be used to attach arbitrary metadata or annotations to entities.
    /// Each key-value pair is stored as a UTF-8 string mapping.
    ///
    /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
    ///
    struct KeyValuePairs {
        /// The key-value pairs that make up this string map.
        rerun::Collection<rerun::datatypes::Utf8Pair> pairs;

      public:
        KeyValuePairs() = default;

        KeyValuePairs(rerun::Collection<rerun::datatypes::Utf8Pair> pairs_)
            : pairs(std::move(pairs_)) {}

        KeyValuePairs& operator=(rerun::Collection<rerun::datatypes::Utf8Pair> pairs_) {
            pairs = std::move(pairs_);
            return *this;
        }
    };
} // namespace rerun::components

namespace rerun {
    template <typename T>
    struct Loggable;

    /// \private
    template <>
    struct Loggable<components::KeyValuePairs> {
        static constexpr std::string_view ComponentType = "rerun.components.KeyValuePairs";

        /// Returns the arrow data type this type corresponds to.
        static const std::shared_ptr<arrow::DataType>& arrow_datatype();

        /// Serializes an array of `rerun::components::KeyValuePairs` into an arrow array.
        static Result<std::shared_ptr<arrow::Array>> to_arrow(
            const components::KeyValuePairs* instances, size_t num_instances
        );

        /// Fills an arrow array builder with an array of this type.
        static rerun::Error fill_arrow_array_builder(
            arrow::ListBuilder* builder, const components::KeyValuePairs* elements,
            size_t num_elements
        );
    };
} // namespace rerun
