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

#include "keys.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 mixxx {
namespace track {
namespace io {
namespace key {
PROTOBUF_CONSTEXPR KeyMap_KeyChange::KeyMap_KeyChange(
    ::_pbi::ConstantInitialized)
  : frame_position_(0)
  , key_(0)
{}
struct KeyMap_KeyChangeDefaultTypeInternal {
  PROTOBUF_CONSTEXPR KeyMap_KeyChangeDefaultTypeInternal()
      : _instance(::_pbi::ConstantInitialized{}) {}
  ~KeyMap_KeyChangeDefaultTypeInternal() {}
  union {
    KeyMap_KeyChange _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 KeyMap_KeyChangeDefaultTypeInternal _KeyMap_KeyChange_default_instance_;
PROTOBUF_CONSTEXPR KeyMap::KeyMap(
    ::_pbi::ConstantInitialized)
  : key_change_()
  , global_key_text_(&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{})
  , global_key_(0)

  , source_(0)
{}
struct KeyMapDefaultTypeInternal {
  PROTOBUF_CONSTEXPR KeyMapDefaultTypeInternal()
      : _instance(::_pbi::ConstantInitialized{}) {}
  ~KeyMapDefaultTypeInternal() {}
  union {
    KeyMap _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 KeyMapDefaultTypeInternal _KeyMap_default_instance_;
}  // namespace key
}  // namespace io
}  // namespace track
}  // namespace mixxx
namespace mixxx {
namespace track {
namespace io {
namespace key {
bool Source_IsValid(int value) {
  switch (value) {
    case 0:
    case 1:
    case 2:
      return true;
    default:
      return false;
  }
}

static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> Source_strings[3] = {};

static const char Source_names[] =
  "ANALYZER"
  "FILE_METADATA"
  "USER";

static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry Source_entries[] = {
  { {Source_names + 0, 8}, 0 },
  { {Source_names + 8, 13}, 1 },
  { {Source_names + 21, 4}, 2 },
};

static const int Source_entries_by_number[] = {
  0, // 0 -> ANALYZER
  1, // 1 -> FILE_METADATA
  2, // 2 -> USER
};

const std::string& Source_Name(
    Source value) {
  static const bool dummy =
      ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings(
          Source_entries,
          Source_entries_by_number,
          3, Source_strings);
  (void) dummy;
  int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName(
      Source_entries,
      Source_entries_by_number,
      3, value);
  return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() :
                     Source_strings[idx].get();
}
bool Source_Parse(
    ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Source* value) {
  int int_value;
  bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue(
      Source_entries, 3, name, &int_value);
  if (success) {
    *value = static_cast<Source>(int_value);
  }
  return success;
}
bool ChromaticKey_IsValid(int value) {
  switch (value) {
    case 0:
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
    case 8:
    case 9:
    case 10:
    case 11:
    case 12:
    case 13:
    case 14:
    case 15:
    case 16:
    case 17:
    case 18:
    case 19:
    case 20:
    case 21:
    case 22:
    case 23:
    case 24:
      return true;
    default:
      return false;
  }
}

static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> ChromaticKey_strings[25] = {};

static const char ChromaticKey_names[] =
  "A_FLAT_MAJOR"
  "A_MAJOR"
  "A_MINOR"
  "B_FLAT_MAJOR"
  "B_FLAT_MINOR"
  "B_MAJOR"
  "B_MINOR"
  "C_MAJOR"
  "C_MINOR"
  "C_SHARP_MINOR"
  "D_FLAT_MAJOR"
  "D_MAJOR"
  "D_MINOR"
  "E_FLAT_MAJOR"
  "E_FLAT_MINOR"
  "E_MAJOR"
  "E_MINOR"
  "F_MAJOR"
  "F_MINOR"
  "F_SHARP_MAJOR"
  "F_SHARP_MINOR"
  "G_MAJOR"
  "G_MINOR"
  "G_SHARP_MINOR"
  "INVALID";

static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry ChromaticKey_entries[] = {
  { {ChromaticKey_names + 0, 12}, 9 },
  { {ChromaticKey_names + 12, 7}, 10 },
  { {ChromaticKey_names + 19, 7}, 22 },
  { {ChromaticKey_names + 26, 12}, 11 },
  { {ChromaticKey_names + 38, 12}, 23 },
  { {ChromaticKey_names + 50, 7}, 12 },
  { {ChromaticKey_names + 57, 7}, 24 },
  { {ChromaticKey_names + 64, 7}, 1 },
  { {ChromaticKey_names + 71, 7}, 13 },
  { {ChromaticKey_names + 78, 13}, 14 },
  { {ChromaticKey_names + 91, 12}, 2 },
  { {ChromaticKey_names + 103, 7}, 3 },
  { {ChromaticKey_names + 110, 7}, 15 },
  { {ChromaticKey_names + 117, 12}, 4 },
  { {ChromaticKey_names + 129, 12}, 16 },
  { {ChromaticKey_names + 141, 7}, 5 },
  { {ChromaticKey_names + 148, 7}, 17 },
  { {ChromaticKey_names + 155, 7}, 6 },
  { {ChromaticKey_names + 162, 7}, 18 },
  { {ChromaticKey_names + 169, 13}, 7 },
  { {ChromaticKey_names + 182, 13}, 19 },
  { {ChromaticKey_names + 195, 7}, 8 },
  { {ChromaticKey_names + 202, 7}, 20 },
  { {ChromaticKey_names + 209, 13}, 21 },
  { {ChromaticKey_names + 222, 7}, 0 },
};

static const int ChromaticKey_entries_by_number[] = {
  24, // 0 -> INVALID
  7, // 1 -> C_MAJOR
  10, // 2 -> D_FLAT_MAJOR
  11, // 3 -> D_MAJOR
  13, // 4 -> E_FLAT_MAJOR
  15, // 5 -> E_MAJOR
  17, // 6 -> F_MAJOR
  19, // 7 -> F_SHARP_MAJOR
  21, // 8 -> G_MAJOR
  0, // 9 -> A_FLAT_MAJOR
  1, // 10 -> A_MAJOR
  3, // 11 -> B_FLAT_MAJOR
  5, // 12 -> B_MAJOR
  8, // 13 -> C_MINOR
  9, // 14 -> C_SHARP_MINOR
  12, // 15 -> D_MINOR
  14, // 16 -> E_FLAT_MINOR
  16, // 17 -> E_MINOR
  18, // 18 -> F_MINOR
  20, // 19 -> F_SHARP_MINOR
  22, // 20 -> G_MINOR
  23, // 21 -> G_SHARP_MINOR
  2, // 22 -> A_MINOR
  4, // 23 -> B_FLAT_MINOR
  6, // 24 -> B_MINOR
};

const std::string& ChromaticKey_Name(
    ChromaticKey value) {
  static const bool dummy =
      ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings(
          ChromaticKey_entries,
          ChromaticKey_entries_by_number,
          25, ChromaticKey_strings);
  (void) dummy;
  int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName(
      ChromaticKey_entries,
      ChromaticKey_entries_by_number,
      25, value);
  return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() :
                     ChromaticKey_strings[idx].get();
}
bool ChromaticKey_Parse(
    ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, ChromaticKey* value) {
  int int_value;
  bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue(
      ChromaticKey_entries, 25, name, &int_value);
  if (success) {
    *value = static_cast<ChromaticKey>(int_value);
  }
  return success;
}

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

class KeyMap_KeyChange::_Internal {
 public:
  using HasBits = decltype(std::declval<KeyMap_KeyChange>()._has_bits_);
  static void set_has_frame_position(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_key(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
};

KeyMap_KeyChange::KeyMap_KeyChange(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
  SharedCtor();
  // @@protoc_insertion_point(arena_constructor:mixxx.track.io.key.KeyMap.KeyChange)
}
KeyMap_KeyChange::KeyMap_KeyChange(const KeyMap_KeyChange& from)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
  ::memcpy(&frame_position_, &from.frame_position_,
    static_cast<size_t>(reinterpret_cast<char*>(&key_) -
    reinterpret_cast<char*>(&frame_position_)) + sizeof(key_));
  // @@protoc_insertion_point(copy_constructor:mixxx.track.io.key.KeyMap.KeyChange)
}

inline void KeyMap_KeyChange::SharedCtor() {
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
    reinterpret_cast<char*>(&frame_position_) - reinterpret_cast<char*>(this)),
    0, static_cast<size_t>(reinterpret_cast<char*>(&key_) -
    reinterpret_cast<char*>(&frame_position_)) + sizeof(key_));
}

KeyMap_KeyChange::~KeyMap_KeyChange() {
  // @@protoc_insertion_point(destructor:mixxx.track.io.key.KeyMap.KeyChange)
  if (auto *arena = _internal_metadata_.DeleteReturnArena<std::string>()) {
  (void)arena;
    return;
  }
  SharedDtor();
}

inline void KeyMap_KeyChange::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}

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

void KeyMap_KeyChange::Clear() {
// @@protoc_insertion_point(message_clear_start:mixxx.track.io.key.KeyMap.KeyChange)
  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) {
    ::memset(&frame_position_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&key_) -
        reinterpret_cast<char*>(&frame_position_)) + sizeof(key_));
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<std::string>();
}

const char* KeyMap_KeyChange::_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 int32 frame_position = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
          _Internal::set_has_frame_position(&has_bits);
          frame_position_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional .mixxx.track.io.key.ChromaticKey key = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
          uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
          if (PROTOBUF_PREDICT_TRUE(::mixxx::track::io::key::ChromaticKey_IsValid(val))) {
            _internal_set_key(static_cast<::mixxx::track::io::key::ChromaticKey>(val));
          } else {
            ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(2, val, mutable_unknown_fields());
          }
        } 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* KeyMap_KeyChange::_InternalSerialize(
    uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:mixxx.track.io.key.KeyMap.KeyChange)
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // optional int32 frame_position = 1;
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_frame_position(), target);
  }

  // optional .mixxx.track.io.key.ChromaticKey key = 2;
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::_pbi::WireFormatLite::WriteEnumToArray(
      2, this->_internal_key(), 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:mixxx.track.io.key.KeyMap.KeyChange)
  return target;
}

size_t KeyMap_KeyChange::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:mixxx.track.io.key.KeyMap.KeyChange)
  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 & 0x00000003u) {
    // optional int32 frame_position = 1;
    if (cached_has_bits & 0x00000001u) {
      total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_frame_position());
    }

    // optional .mixxx.track.io.key.ChromaticKey key = 2;
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::_pbi::WireFormatLite::EnumSize(this->_internal_key());
    }

  }
  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 KeyMap_KeyChange::CheckTypeAndMergeFrom(
    const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
  MergeFrom(*::_pbi::DownCast<const KeyMap_KeyChange*>(
      &from));
}

void KeyMap_KeyChange::MergeFrom(const KeyMap_KeyChange& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:mixxx.track.io.key.KeyMap.KeyChange)
  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 & 0x00000003u) {
    if (cached_has_bits & 0x00000001u) {
      frame_position_ = from.frame_position_;
    }
    if (cached_has_bits & 0x00000002u) {
      key_ = from.key_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}

void KeyMap_KeyChange::CopyFrom(const KeyMap_KeyChange& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:mixxx.track.io.key.KeyMap.KeyChange)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

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

void KeyMap_KeyChange::InternalSwap(KeyMap_KeyChange* other) {
  using std::swap;
  _internal_metadata_.InternalSwap(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(KeyMap_KeyChange, key_)
      + sizeof(KeyMap_KeyChange::key_)
      - PROTOBUF_FIELD_OFFSET(KeyMap_KeyChange, frame_position_)>(
          reinterpret_cast<char*>(&frame_position_),
          reinterpret_cast<char*>(&other->frame_position_));
}

std::string KeyMap_KeyChange::GetTypeName() const {
  return "mixxx.track.io.key.KeyMap.KeyChange";
}


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

class KeyMap::_Internal {
 public:
  using HasBits = decltype(std::declval<KeyMap>()._has_bits_);
  static void set_has_global_key(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static void set_has_global_key_text(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_source(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
};

KeyMap::KeyMap(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned),
  key_change_(arena) {
  SharedCtor();
  // @@protoc_insertion_point(arena_constructor:mixxx.track.io.key.KeyMap)
}
KeyMap::KeyMap(const KeyMap& from)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(),
      _has_bits_(from._has_bits_),
      key_change_(from.key_change_) {
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
  global_key_text_.InitDefault();
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    global_key_text_.Set("", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_global_key_text()) {
    global_key_text_.Set(from._internal_global_key_text(), 
      GetArenaForAllocation());
  }
  ::memcpy(&global_key_, &from.global_key_,
    static_cast<size_t>(reinterpret_cast<char*>(&source_) -
    reinterpret_cast<char*>(&global_key_)) + sizeof(source_));
  // @@protoc_insertion_point(copy_constructor:mixxx.track.io.key.KeyMap)
}

inline void KeyMap::SharedCtor() {
global_key_text_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  global_key_text_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
    reinterpret_cast<char*>(&global_key_) - reinterpret_cast<char*>(this)),
    0, static_cast<size_t>(reinterpret_cast<char*>(&source_) -
    reinterpret_cast<char*>(&global_key_)) + sizeof(source_));
}

KeyMap::~KeyMap() {
  // @@protoc_insertion_point(destructor:mixxx.track.io.key.KeyMap)
  if (auto *arena = _internal_metadata_.DeleteReturnArena<std::string>()) {
  (void)arena;
    return;
  }
  SharedDtor();
}

inline void KeyMap::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
  global_key_text_.Destroy();
}

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

void KeyMap::Clear() {
// @@protoc_insertion_point(message_clear_start:mixxx.track.io.key.KeyMap)
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  key_change_.Clear();
  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000001u) {
    global_key_text_.ClearNonDefaultToEmpty();
  }
  if (cached_has_bits & 0x00000006u) {
    ::memset(&global_key_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&source_) -
        reinterpret_cast<char*>(&global_key_)) + sizeof(source_));
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<std::string>();
}

const char* KeyMap::_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 .mixxx.track.io.key.ChromaticKey global_key = 1 [default = INVALID];
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
          uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
          if (PROTOBUF_PREDICT_TRUE(::mixxx::track::io::key::ChromaticKey_IsValid(val))) {
            _internal_set_global_key(static_cast<::mixxx::track::io::key::ChromaticKey>(val));
          } else {
            ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields());
          }
        } else
          goto handle_unusual;
        continue;
      // optional string global_key_text = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
          auto str = _internal_mutable_global_key_text();
          ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // repeated .mixxx.track.io.key.KeyMap.KeyChange key_change = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_key_change(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr));
        } else
          goto handle_unusual;
        continue;
      // optional .mixxx.track.io.key.Source source = 4 [default = ANALYZER];
      case 4:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 32)) {
          uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
          if (PROTOBUF_PREDICT_TRUE(::mixxx::track::io::key::Source_IsValid(val))) {
            _internal_set_source(static_cast<::mixxx::track::io::key::Source>(val));
          } else {
            ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(4, val, mutable_unknown_fields());
          }
        } 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* KeyMap::_InternalSerialize(
    uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:mixxx.track.io.key.KeyMap)
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // optional .mixxx.track.io.key.ChromaticKey global_key = 1 [default = INVALID];
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::_pbi::WireFormatLite::WriteEnumToArray(
      1, this->_internal_global_key(), target);
  }

  // optional string global_key_text = 2;
  if (cached_has_bits & 0x00000001u) {
    target = stream->WriteStringMaybeAliased(
        2, this->_internal_global_key_text(), target);
  }

  // repeated .mixxx.track.io.key.KeyMap.KeyChange key_change = 3;
  for (unsigned i = 0,
      n = static_cast<unsigned>(this->_internal_key_change_size()); i < n; i++) {
    const auto& repfield = this->_internal_key_change(i);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
        InternalWriteMessage(3, repfield, repfield.GetCachedSize(), target, stream);
  }

  // optional .mixxx.track.io.key.Source source = 4 [default = ANALYZER];
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::_pbi::WireFormatLite::WriteEnumToArray(
      4, this->_internal_source(), 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:mixxx.track.io.key.KeyMap)
  return target;
}

size_t KeyMap::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:mixxx.track.io.key.KeyMap)
  size_t total_size = 0;

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

  // repeated .mixxx.track.io.key.KeyMap.KeyChange key_change = 3;
  total_size += 1UL * this->_internal_key_change_size();
  for (const auto& msg : this->key_change_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    // optional string global_key_text = 2;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
          this->_internal_global_key_text());
    }

    // optional .mixxx.track.io.key.ChromaticKey global_key = 1 [default = INVALID];
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::_pbi::WireFormatLite::EnumSize(this->_internal_global_key());
    }

    // optional .mixxx.track.io.key.Source source = 4 [default = ANALYZER];
    if (cached_has_bits & 0x00000004u) {
      total_size += 1 +
        ::_pbi::WireFormatLite::EnumSize(this->_internal_source());
    }

  }
  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 KeyMap::CheckTypeAndMergeFrom(
    const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
  MergeFrom(*::_pbi::DownCast<const KeyMap*>(
      &from));
}

void KeyMap::MergeFrom(const KeyMap& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:mixxx.track.io.key.KeyMap)
  GOOGLE_DCHECK_NE(&from, this);
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  key_change_.MergeFrom(from.key_change_);
  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    if (cached_has_bits & 0x00000001u) {
      _internal_set_global_key_text(from._internal_global_key_text());
    }
    if (cached_has_bits & 0x00000002u) {
      global_key_ = from.global_key_;
    }
    if (cached_has_bits & 0x00000004u) {
      source_ = from.source_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}

void KeyMap::CopyFrom(const KeyMap& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:mixxx.track.io.key.KeyMap)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

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

void KeyMap::InternalSwap(KeyMap* 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]);
  key_change_.InternalSwap(&other->key_change_);
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &global_key_text_, lhs_arena,
      &other->global_key_text_, rhs_arena
  );
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(KeyMap, source_)
      + sizeof(KeyMap::source_)
      - PROTOBUF_FIELD_OFFSET(KeyMap, global_key_)>(
          reinterpret_cast<char*>(&global_key_),
          reinterpret_cast<char*>(&other->global_key_));
}

std::string KeyMap::GetTypeName() const {
  return "mixxx.track.io.key.KeyMap";
}


// @@protoc_insertion_point(namespace_scope)
}  // namespace key
}  // namespace io
}  // namespace track
}  // namespace mixxx
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::mixxx::track::io::key::KeyMap_KeyChange*
Arena::CreateMaybeMessage< ::mixxx::track::io::key::KeyMap_KeyChange >(Arena* arena) {
  return Arena::CreateMessageInternal< ::mixxx::track::io::key::KeyMap_KeyChange >(arena);
}
template<> PROTOBUF_NOINLINE ::mixxx::track::io::key::KeyMap*
Arena::CreateMaybeMessage< ::mixxx::track::io::key::KeyMap >(Arena* arena) {
  return Arena::CreateMessageInternal< ::mixxx::track::io::key::KeyMap >(arena);
}
PROTOBUF_NAMESPACE_CLOSE

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