#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::history {

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

  w.write_struct_begin("dwarfs_version");

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, major_)) {
    w.write_field_begin("major", ::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(major_)>>::write(w, major_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, minor_)) {
    w.write_field_begin("minor", ::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(minor_)>>::write(w, minor_);
    w.write_field_end();
  }

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

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

  if (isset_.test(git_rev_isset_index)) {
    w.write_field_begin("git_rev", ::dwarfs::thrift_lite::ttype::string_t, 5);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(git_rev_)>>::write(w, git_rev_);
    w.write_field_end();
  }

  if (isset_.test(git_branch_isset_index)) {
    w.write_field_begin("git_branch", ::dwarfs::thrift_lite::ttype::string_t, 6);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(git_branch_)>>::write(w, git_branch_);
    w.write_field_end();
  }

  if (isset_.test(git_desc_isset_index)) {
    w.write_field_begin("git_desc", ::dwarfs::thrift_lite::ttype::string_t, 7);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(git_desc_)>>::write(w, git_desc_);
    w.write_field_end();
  }

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

inline void dwarfs_version::read(::dwarfs::thrift_lite::protocol_reader_type auto& r) {
  isset_.reset();
  major_ = {};
  minor_ = {};
  patch_ = {};
  is_release_ = {};
  git_rev_ = {};
  git_branch_ = {};
  git_desc_ = {};

  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(major_)>>::read(r, major_);
          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(minor_)>>::read(r, minor_);
          skip = false;
        }
        break;

      case 3:
        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(patch_)>>::read(r, patch_);
          skip = false;
        }
        break;

      case 4:
        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(is_release_)>>::read(r, is_release_);
          skip = false;
        }
        break;

      case 5:
        if (field_type == ::dwarfs::thrift_lite::ttype::binary_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(git_rev_)>>::read(r, git_rev_);
          isset_.set(git_rev_isset_index);
          skip = false;
        }
        break;

      case 6:
        if (field_type == ::dwarfs::thrift_lite::ttype::binary_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(git_branch_)>>::read(r, git_branch_);
          isset_.set(git_branch_isset_index);
          skip = false;
        }
        break;

      case 7:
        if (field_type == ::dwarfs::thrift_lite::ttype::binary_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(git_desc_)>>::read(r, git_desc_);
          isset_.set(git_desc_isset_index);
          skip = false;
        }
        break;

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

    r.read_field_end();
  }

  r.read_struct_end();
}

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

  w.write_struct_begin("history_entry");

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, version_)) {
    w.write_field_begin("version", ::dwarfs::thrift_lite::ttype::struct_t, 1);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::structure, std::remove_cvref_t<decltype(version_)>>::write(w, version_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, system_id_)) {
    w.write_field_begin("system_id", ::dwarfs::thrift_lite::ttype::string_t, 2);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(system_id_)>>::write(w, system_id_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, compiler_id_)) {
    w.write_field_begin("compiler_id", ::dwarfs::thrift_lite::ttype::string_t, 3);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(compiler_id_)>>::write(w, compiler_id_);
    w.write_field_end();
  }

  if (isset_.test(arguments_isset_index)) {
    w.write_field_begin("arguments", ::dwarfs::thrift_lite::ttype::list_t, 4);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::string>, std::remove_cvref_t<decltype(arguments_)>>::write(w, arguments_);
    w.write_field_end();
  }

  if (isset_.test(timestamp_isset_index)) {
    w.write_field_begin("timestamp", ::dwarfs::thrift_lite::ttype::i64_t, 5);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(timestamp_)>>::write(w, timestamp_);
    w.write_field_end();
  }

  if (isset_.test(library_versions_isset_index)) {
    w.write_field_begin("library_versions", ::dwarfs::thrift_lite::ttype::set_t, 6);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::set<::dwarfs::thrift_lite::detail::type_class::string>, std::remove_cvref_t<decltype(library_versions_)>>::write(w, library_versions_);
    w.write_field_end();
  }

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

inline void history_entry::read(::dwarfs::thrift_lite::protocol_reader_type auto& r) {
  isset_.reset();
  version_ = {};
  system_id_ = {};
  compiler_id_ = {};
  arguments_ = {};
  timestamp_ = {};
  library_versions_ = {};

  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::struct_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::structure, std::remove_cvref_t<decltype(version_)>>::read(r, version_);
          skip = false;
        }
        break;

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

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

      case 4:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::string>, std::remove_cvref_t<decltype(arguments_)>>::read(r, arguments_);
          isset_.set(arguments_isset_index);
          skip = false;
        }
        break;

      case 5:
        if (field_type == ::dwarfs::thrift_lite::ttype::i64_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(timestamp_)>>::read(r, timestamp_);
          isset_.set(timestamp_isset_index);
          skip = false;
        }
        break;

      case 6:
        if (field_type == ::dwarfs::thrift_lite::ttype::set_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::set<::dwarfs::thrift_lite::detail::type_class::string>, std::remove_cvref_t<decltype(library_versions_)>>::read(r, library_versions_);
          isset_.set(library_versions_isset_index);
          skip = false;
        }
        break;

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

    r.read_field_end();
  }

  r.read_struct_end();
}

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

  w.write_struct_begin("history");

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, entries_)) {
    w.write_field_begin("entries", ::dwarfs::thrift_lite::ttype::list_t, 1);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::structure>, std::remove_cvref_t<decltype(entries_)>>::write(w, entries_);
    w.write_field_end();
  }

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

inline void history::read(::dwarfs::thrift_lite::protocol_reader_type auto& r) {
  entries_ = {};

  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::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::structure>, std::remove_cvref_t<decltype(entries_)>>::read(r, entries_);
          skip = false;
        }
        break;

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

    r.read_field_end();
  }

  r.read_struct_end();
}

} // namespace dwarfs::thrift::history

