// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: transportinstruction.proto

#include "transportinstruction.pb.h"

#include <algorithm>

#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>

PROTOBUF_PRAGMA_INIT_SEG

namespace _pb = ::PROTOBUF_NAMESPACE_ID;
namespace _pbi = _pb::internal;

namespace TransportBuffers {
PROTOBUF_CONSTEXPR Instruction::Instruction(
    ::_pbi::ConstantInitialized): _impl_{
    /*decltype(_impl_._has_bits_)*/{}
  , /*decltype(_impl_._cached_size_)*/{}
  , /*decltype(_impl_.diff_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
  , /*decltype(_impl_.chaff_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
  , /*decltype(_impl_.old_num_)*/uint64_t{0u}
  , /*decltype(_impl_.new_num_)*/uint64_t{0u}
  , /*decltype(_impl_.ack_num_)*/uint64_t{0u}
  , /*decltype(_impl_.throwaway_num_)*/uint64_t{0u}
  , /*decltype(_impl_.protocol_version_)*/0u} {}
struct InstructionDefaultTypeInternal {
  PROTOBUF_CONSTEXPR InstructionDefaultTypeInternal()
      : _instance(::_pbi::ConstantInitialized{}) {}
  ~InstructionDefaultTypeInternal() {}
  union {
    Instruction _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InstructionDefaultTypeInternal _Instruction_default_instance_;
}  // namespace TransportBuffers
namespace TransportBuffers {

// ===================================================================

class Instruction::_Internal {
 public:
  using HasBits = decltype(std::declval<Instruction>()._impl_._has_bits_);
  static void set_has_protocol_version(HasBits* has_bits) {
    (*has_bits)[0] |= 64u;
  }
  static void set_has_old_num(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
  static void set_has_new_num(HasBits* has_bits) {
    (*has_bits)[0] |= 8u;
  }
  static void set_has_ack_num(HasBits* has_bits) {
    (*has_bits)[0] |= 16u;
  }
  static void set_has_throwaway_num(HasBits* has_bits) {
    (*has_bits)[0] |= 32u;
  }
  static void set_has_diff(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_chaff(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
};

Instruction::Instruction(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
  SharedCtor(arena, is_message_owned);
  // @@protoc_insertion_point(arena_constructor:TransportBuffers.Instruction)
}
Instruction::Instruction(const Instruction& from)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite() {
  Instruction* const _this = this; (void)_this;
  new (&_impl_) Impl_{
      decltype(_impl_._has_bits_){from._impl_._has_bits_}
    , /*decltype(_impl_._cached_size_)*/{}
    , decltype(_impl_.diff_){}
    , decltype(_impl_.chaff_){}
    , decltype(_impl_.old_num_){}
    , decltype(_impl_.new_num_){}
    , decltype(_impl_.ack_num_){}
    , decltype(_impl_.throwaway_num_){}
    , decltype(_impl_.protocol_version_){}};

  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
  _impl_.diff_.InitDefault();
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    _impl_.diff_.Set("", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_diff()) {
    _this->_impl_.diff_.Set(from._internal_diff(), 
      _this->GetArenaForAllocation());
  }
  _impl_.chaff_.InitDefault();
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    _impl_.chaff_.Set("", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_chaff()) {
    _this->_impl_.chaff_.Set(from._internal_chaff(), 
      _this->GetArenaForAllocation());
  }
  ::memcpy(&_impl_.old_num_, &from._impl_.old_num_,
    static_cast<size_t>(reinterpret_cast<char*>(&_impl_.protocol_version_) -
    reinterpret_cast<char*>(&_impl_.old_num_)) + sizeof(_impl_.protocol_version_));
  // @@protoc_insertion_point(copy_constructor:TransportBuffers.Instruction)
}

inline void Instruction::SharedCtor(
    ::_pb::Arena* arena, bool is_message_owned) {
  (void)arena;
  (void)is_message_owned;
  new (&_impl_) Impl_{
      decltype(_impl_._has_bits_){}
    , /*decltype(_impl_._cached_size_)*/{}
    , decltype(_impl_.diff_){}
    , decltype(_impl_.chaff_){}
    , decltype(_impl_.old_num_){uint64_t{0u}}
    , decltype(_impl_.new_num_){uint64_t{0u}}
    , decltype(_impl_.ack_num_){uint64_t{0u}}
    , decltype(_impl_.throwaway_num_){uint64_t{0u}}
    , decltype(_impl_.protocol_version_){0u}
  };
  _impl_.diff_.InitDefault();
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    _impl_.diff_.Set("", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  _impl_.chaff_.InitDefault();
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    _impl_.chaff_.Set("", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}

Instruction::~Instruction() {
  // @@protoc_insertion_point(destructor:TransportBuffers.Instruction)
  if (auto *arena = _internal_metadata_.DeleteReturnArena<std::string>()) {
  (void)arena;
    return;
  }
  SharedDtor();
}

inline void Instruction::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
  _impl_.diff_.Destroy();
  _impl_.chaff_.Destroy();
}

void Instruction::SetCachedSize(int size) const {
  _impl_._cached_size_.Set(size);
}

void Instruction::Clear() {
// @@protoc_insertion_point(message_clear_start:TransportBuffers.Instruction)
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _impl_._has_bits_[0];
  if (cached_has_bits & 0x00000003u) {
    if (cached_has_bits & 0x00000001u) {
      _impl_.diff_.ClearNonDefaultToEmpty();
    }
    if (cached_has_bits & 0x00000002u) {
      _impl_.chaff_.ClearNonDefaultToEmpty();
    }
  }
  if (cached_has_bits & 0x0000007cu) {
    ::memset(&_impl_.old_num_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&_impl_.protocol_version_) -
        reinterpret_cast<char*>(&_impl_.old_num_)) + sizeof(_impl_.protocol_version_));
  }
  _impl_._has_bits_.Clear();
  _internal_metadata_.Clear<std::string>();
}

const char* Instruction::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  while (!ctx->Done(&ptr)) {
    uint32_t tag;
    ptr = ::_pbi::ReadTag(ptr, &tag);
    switch (tag >> 3) {
      // optional uint32 protocol_version = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
          _Internal::set_has_protocol_version(&has_bits);
          _impl_.protocol_version_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional uint64 old_num = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
          _Internal::set_has_old_num(&has_bits);
          _impl_.old_num_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional uint64 new_num = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) {
          _Internal::set_has_new_num(&has_bits);
          _impl_.new_num_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional uint64 ack_num = 4;
      case 4:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 32)) {
          _Internal::set_has_ack_num(&has_bits);
          _impl_.ack_num_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional uint64 throwaway_num = 5;
      case 5:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 40)) {
          _Internal::set_has_throwaway_num(&has_bits);
          _impl_.throwaway_num_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional bytes diff = 6;
      case 6:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) {
          auto str = _internal_mutable_diff();
          ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional bytes chaff = 7;
      case 7:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
          auto str = _internal_mutable_chaff();
          ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      default:
        goto handle_unusual;
    }  // switch
  handle_unusual:
    if ((tag == 0) || ((tag & 7) == 4)) {
      CHK_(ptr);
      ctx->SetLastTag(tag);
      goto message_done;
    }
    ptr = UnknownFieldParse(
        tag,
        _internal_metadata_.mutable_unknown_fields<std::string>(),
        ptr, ctx);
    CHK_(ptr != nullptr);
  }  // while
message_done:
  _impl_._has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto message_done;
#undef CHK_
}

uint8_t* Instruction::_InternalSerialize(
    uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:TransportBuffers.Instruction)
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _impl_._has_bits_[0];
  // optional uint32 protocol_version = 1;
  if (cached_has_bits & 0x00000040u) {
    target = stream->EnsureSpace(target);
    target = ::_pbi::WireFormatLite::WriteUInt32ToArray(1, this->_internal_protocol_version(), target);
  }

  // optional uint64 old_num = 2;
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::_pbi::WireFormatLite::WriteUInt64ToArray(2, this->_internal_old_num(), target);
  }

  // optional uint64 new_num = 3;
  if (cached_has_bits & 0x00000008u) {
    target = stream->EnsureSpace(target);
    target = ::_pbi::WireFormatLite::WriteUInt64ToArray(3, this->_internal_new_num(), target);
  }

  // optional uint64 ack_num = 4;
  if (cached_has_bits & 0x00000010u) {
    target = stream->EnsureSpace(target);
    target = ::_pbi::WireFormatLite::WriteUInt64ToArray(4, this->_internal_ack_num(), target);
  }

  // optional uint64 throwaway_num = 5;
  if (cached_has_bits & 0x00000020u) {
    target = stream->EnsureSpace(target);
    target = ::_pbi::WireFormatLite::WriteUInt64ToArray(5, this->_internal_throwaway_num(), target);
  }

  // optional bytes diff = 6;
  if (cached_has_bits & 0x00000001u) {
    target = stream->WriteBytesMaybeAliased(
        6, this->_internal_diff(), target);
  }

  // optional bytes chaff = 7;
  if (cached_has_bits & 0x00000002u) {
    target = stream->WriteBytesMaybeAliased(
        7, this->_internal_chaff(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
        static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:TransportBuffers.Instruction)
  return target;
}

size_t Instruction::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TransportBuffers.Instruction)
  size_t total_size = 0;

  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _impl_._has_bits_[0];
  if (cached_has_bits & 0x0000007fu) {
    // optional bytes diff = 6;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
          this->_internal_diff());
    }

    // optional bytes chaff = 7;
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
          this->_internal_chaff());
    }

    // optional uint64 old_num = 2;
    if (cached_has_bits & 0x00000004u) {
      total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_old_num());
    }

    // optional uint64 new_num = 3;
    if (cached_has_bits & 0x00000008u) {
      total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_new_num());
    }

    // optional uint64 ack_num = 4;
    if (cached_has_bits & 0x00000010u) {
      total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_ack_num());
    }

    // optional uint64 throwaway_num = 5;
    if (cached_has_bits & 0x00000020u) {
      total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_throwaway_num());
    }

    // optional uint32 protocol_version = 1;
    if (cached_has_bits & 0x00000040u) {
      total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_protocol_version());
    }

  }
  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
  }
  int cached_size = ::_pbi::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void Instruction::CheckTypeAndMergeFrom(
    const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
  MergeFrom(*::_pbi::DownCast<const Instruction*>(
      &from));
}

void Instruction::MergeFrom(const Instruction& from) {
  Instruction* const _this = this;
  // @@protoc_insertion_point(class_specific_merge_from_start:TransportBuffers.Instruction)
  GOOGLE_DCHECK_NE(&from, _this);
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = from._impl_._has_bits_[0];
  if (cached_has_bits & 0x0000007fu) {
    if (cached_has_bits & 0x00000001u) {
      _this->_internal_set_diff(from._internal_diff());
    }
    if (cached_has_bits & 0x00000002u) {
      _this->_internal_set_chaff(from._internal_chaff());
    }
    if (cached_has_bits & 0x00000004u) {
      _this->_impl_.old_num_ = from._impl_.old_num_;
    }
    if (cached_has_bits & 0x00000008u) {
      _this->_impl_.new_num_ = from._impl_.new_num_;
    }
    if (cached_has_bits & 0x00000010u) {
      _this->_impl_.ack_num_ = from._impl_.ack_num_;
    }
    if (cached_has_bits & 0x00000020u) {
      _this->_impl_.throwaway_num_ = from._impl_.throwaway_num_;
    }
    if (cached_has_bits & 0x00000040u) {
      _this->_impl_.protocol_version_ = from._impl_.protocol_version_;
    }
    _this->_impl_._has_bits_[0] |= cached_has_bits;
  }
  _this->_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}

void Instruction::CopyFrom(const Instruction& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TransportBuffers.Instruction)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool Instruction::IsInitialized() const {
  return true;
}

void Instruction::InternalSwap(Instruction* other) {
  using std::swap;
  auto* lhs_arena = GetArenaForAllocation();
  auto* rhs_arena = other->GetArenaForAllocation();
  _internal_metadata_.InternalSwap(&other->_internal_metadata_);
  swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &_impl_.diff_, lhs_arena,
      &other->_impl_.diff_, rhs_arena
  );
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &_impl_.chaff_, lhs_arena,
      &other->_impl_.chaff_, rhs_arena
  );
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(Instruction, _impl_.protocol_version_)
      + sizeof(Instruction::_impl_.protocol_version_)
      - PROTOBUF_FIELD_OFFSET(Instruction, _impl_.old_num_)>(
          reinterpret_cast<char*>(&_impl_.old_num_),
          reinterpret_cast<char*>(&other->_impl_.old_num_));
}

std::string Instruction::GetTypeName() const {
  return "TransportBuffers.Instruction";
}


// @@protoc_insertion_point(namespace_scope)
}  // namespace TransportBuffers
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::TransportBuffers::Instruction*
Arena::CreateMaybeMessage< ::TransportBuffers::Instruction >(Arena* arena) {
  return Arena::CreateMessageInternal< ::TransportBuffers::Instruction >(arena);
}
PROTOBUF_NAMESPACE_CLOSE

// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
