// 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 TransportBuffers {
constexpr Instruction::Instruction(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : diff_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
  , chaff_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
  , old_num_(uint64_t{0u})
  , new_num_(uint64_t{0u})
  , ack_num_(uint64_t{0u})
  , throwaway_num_(uint64_t{0u})
  , protocol_version_(0u){}
struct InstructionDefaultTypeInternal {
  constexpr InstructionDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~InstructionDefaultTypeInternal() {}
  union {
    Instruction _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT InstructionDefaultTypeInternal _Instruction_default_instance_;
}  // namespace TransportBuffers
namespace TransportBuffers {

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

class Instruction::_Internal {
 public:
  using HasBits = decltype(std::declval<Instruction>()._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();
  if (!is_message_owned) {
    RegisterArenaDtor(arena);
  }
  // @@protoc_insertion_point(arena_constructor:TransportBuffers.Instruction)
}
Instruction::Instruction(const Instruction& from)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
  diff_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    diff_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_diff()) {
    diff_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_diff(), 
      GetArenaForAllocation());
  }
  chaff_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    chaff_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_chaff()) {
    chaff_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_chaff(), 
      GetArenaForAllocation());
  }
  ::memcpy(&old_num_, &from.old_num_,
    static_cast<size_t>(reinterpret_cast<char*>(&protocol_version_) -
    reinterpret_cast<char*>(&old_num_)) + sizeof(protocol_version_));
  // @@protoc_insertion_point(copy_constructor:TransportBuffers.Instruction)
}

inline void Instruction::SharedCtor() {
diff_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  diff_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
chaff_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  chaff_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
    reinterpret_cast<char*>(&old_num_) - reinterpret_cast<char*>(this)),
    0, static_cast<size_t>(reinterpret_cast<char*>(&protocol_version_) -
    reinterpret_cast<char*>(&old_num_)) + sizeof(protocol_version_));
}

Instruction::~Instruction() {
  // @@protoc_insertion_point(destructor:TransportBuffers.Instruction)
  if (GetArenaForAllocation() != nullptr) return;
  SharedDtor();
  _internal_metadata_.Delete<std::string>();
}

inline void Instruction::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
  diff_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  chaff_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}

void Instruction::ArenaDtor(void* object) {
  Instruction* _this = reinterpret_cast< Instruction* >(object);
  (void)_this;
}
void Instruction::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void Instruction::SetCachedSize(int size) const {
  _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 = _has_bits_[0];
  if (cached_has_bits & 0x00000003u) {
    if (cached_has_bits & 0x00000001u) {
      diff_.ClearNonDefaultToEmpty();
    }
    if (cached_has_bits & 0x00000002u) {
      chaff_.ClearNonDefaultToEmpty();
    }
  }
  if (cached_has_bits & 0x0000007cu) {
    ::memset(&old_num_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&protocol_version_) -
        reinterpret_cast<char*>(&old_num_)) + sizeof(protocol_version_));
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<std::string>();
}

const char* Instruction::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  while (!ctx->Done(&ptr)) {
    uint32_t tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::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);
          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);
          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);
          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);
          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);
          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 = ::PROTOBUF_NAMESPACE_ID::internal::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 = ::PROTOBUF_NAMESPACE_ID::internal::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:
  _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 = _has_bits_[0];
  // optional uint32 protocol_version = 1;
  if (cached_has_bits & 0x00000040u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt32ToArray(1, this->_internal_protocol_version(), target);
  }

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

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

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

  // optional uint64 throwaway_num = 5;
  if (cached_has_bits & 0x00000020u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::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 = _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 += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64SizePlusOne(this->_internal_old_num());
    }

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

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

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

    // optional uint32 protocol_version = 1;
    if (cached_has_bits & 0x00000040u) {
      total_size += ::PROTOBUF_NAMESPACE_ID::internal::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 = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

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

void Instruction::MergeFrom(const Instruction& from) {
// @@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._has_bits_[0];
  if (cached_has_bits & 0x0000007fu) {
    if (cached_has_bits & 0x00000001u) {
      _internal_set_diff(from._internal_diff());
    }
    if (cached_has_bits & 0x00000002u) {
      _internal_set_chaff(from._internal_chaff());
    }
    if (cached_has_bits & 0x00000004u) {
      old_num_ = from.old_num_;
    }
    if (cached_has_bits & 0x00000008u) {
      new_num_ = from.new_num_;
    }
    if (cached_has_bits & 0x00000010u) {
      ack_num_ = from.ack_num_;
    }
    if (cached_has_bits & 0x00000020u) {
      throwaway_num_ = from.throwaway_num_;
    }
    if (cached_has_bits & 0x00000040u) {
      protocol_version_ = from.protocol_version_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
  _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(_has_bits_[0], other->_has_bits_[0]);
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
      &diff_, lhs_arena,
      &other->diff_, rhs_arena
  );
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
      &chaff_, lhs_arena,
      &other->chaff_, rhs_arena
  );
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(Instruction, protocol_version_)
      + sizeof(Instruction::protocol_version_)
      - PROTOBUF_FIELD_OFFSET(Instruction, old_num_)>(
          reinterpret_cast<char*>(&old_num_),
          reinterpret_cast<char*>(&other->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>
