#pragma once

// @generated by thrift-lite.py; do not edit.

#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <utility>

#include <dwarfs/thrift_lite/detail/protocol_helpers.h>
#include <dwarfs/thrift_lite/detail/protocol_methods.h>

namespace dwarfs::thrift::compression {

inline void flac_block_header::write(::dwarfs::thrift_lite::protocol_writer_type auto& w) const {
  auto const& opts = w.options();

  w.write_struct_begin("flac_block_header");

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, num_channels_)) {
    w.write_field_begin("num_channels", ::dwarfs::thrift_lite::ttype::i16_t, 1);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(num_channels_)>>::write(w, num_channels_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, bits_per_sample_)) {
    w.write_field_begin("bits_per_sample", ::dwarfs::thrift_lite::ttype::byte_t, 2);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(bits_per_sample_)>>::write(w, bits_per_sample_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, flags_)) {
    w.write_field_begin("flags", ::dwarfs::thrift_lite::ttype::byte_t, 3);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(flags_)>>::write(w, flags_);
    w.write_field_end();
  }

  w.write_field_stop();
  w.write_struct_end();
}

inline void flac_block_header::read(::dwarfs::thrift_lite::protocol_reader_type auto& r) {
  num_channels_ = {};
  bits_per_sample_ = {};
  flags_ = {};

  r.read_struct_begin();

  for (;;) {
    auto field_type = ::dwarfs::thrift_lite::ttype{};
    auto field_id = std::int16_t{};

    r.read_field_begin(field_type, field_id);

    if (field_type == ::dwarfs::thrift_lite::ttype::stop_t) {
      break;
    }

    bool skip = true;

    switch (field_id) {
      case 1:
        if (field_type == ::dwarfs::thrift_lite::ttype::i16_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(num_channels_)>>::read(r, num_channels_);
          skip = false;
        }
        break;

      case 2:
        if (field_type == ::dwarfs::thrift_lite::ttype::byte_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(bits_per_sample_)>>::read(r, bits_per_sample_);
          skip = false;
        }
        break;

      case 3:
        if (field_type == ::dwarfs::thrift_lite::ttype::byte_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(flags_)>>::read(r, flags_);
          skip = false;
        }
        break;

  default:
    break;
}
    if (skip) {
      r.skip(field_type);
    }

    r.read_field_end();
  }

  r.read_struct_end();
}

inline void ricepp_block_header::write(::dwarfs::thrift_lite::protocol_writer_type auto& w) const {
  auto const& opts = w.options();

  w.write_struct_begin("ricepp_block_header");

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, block_size_)) {
    w.write_field_begin("block_size", ::dwarfs::thrift_lite::ttype::i32_t, 1);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(block_size_)>>::write(w, block_size_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, component_count_)) {
    w.write_field_begin("component_count", ::dwarfs::thrift_lite::ttype::i16_t, 2);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(component_count_)>>::write(w, component_count_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, bytes_per_sample_)) {
    w.write_field_begin("bytes_per_sample", ::dwarfs::thrift_lite::ttype::byte_t, 3);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(bytes_per_sample_)>>::write(w, bytes_per_sample_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, unused_lsb_count_)) {
    w.write_field_begin("unused_lsb_count", ::dwarfs::thrift_lite::ttype::byte_t, 4);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(unused_lsb_count_)>>::write(w, unused_lsb_count_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, big_endian_)) {
    w.write_field_begin("big_endian", ::dwarfs::thrift_lite::ttype::bool_t, 5);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(big_endian_)>>::write(w, big_endian_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, ricepp_version_)) {
    w.write_field_begin("ricepp_version", ::dwarfs::thrift_lite::ttype::i16_t, 6);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(ricepp_version_)>>::write(w, ricepp_version_);
    w.write_field_end();
  }

  w.write_field_stop();
  w.write_struct_end();
}

inline void ricepp_block_header::read(::dwarfs::thrift_lite::protocol_reader_type auto& r) {
  block_size_ = {};
  component_count_ = {};
  bytes_per_sample_ = {};
  unused_lsb_count_ = {};
  big_endian_ = {};
  ricepp_version_ = {};

  r.read_struct_begin();

  for (;;) {
    auto field_type = ::dwarfs::thrift_lite::ttype{};
    auto field_id = std::int16_t{};

    r.read_field_begin(field_type, field_id);

    if (field_type == ::dwarfs::thrift_lite::ttype::stop_t) {
      break;
    }

    bool skip = true;

    switch (field_id) {
      case 1:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(block_size_)>>::read(r, block_size_);
          skip = false;
        }
        break;

      case 2:
        if (field_type == ::dwarfs::thrift_lite::ttype::i16_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(component_count_)>>::read(r, component_count_);
          skip = false;
        }
        break;

      case 3:
        if (field_type == ::dwarfs::thrift_lite::ttype::byte_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(bytes_per_sample_)>>::read(r, bytes_per_sample_);
          skip = false;
        }
        break;

      case 4:
        if (field_type == ::dwarfs::thrift_lite::ttype::byte_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(unused_lsb_count_)>>::read(r, unused_lsb_count_);
          skip = false;
        }
        break;

      case 5:
        if (field_type == ::dwarfs::thrift_lite::ttype::bool_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(big_endian_)>>::read(r, big_endian_);
          skip = false;
        }
        break;

      case 6:
        if (field_type == ::dwarfs::thrift_lite::ttype::i16_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(ricepp_version_)>>::read(r, ricepp_version_);
          skip = false;
        }
        break;

  default:
    break;
}
    if (skip) {
      r.skip(field_type);
    }

    r.read_field_end();
  }

  r.read_struct_end();
}

} // namespace dwarfs::thrift::compression

