// components/skills/public/skill.mojom-shared.cc is auto generated by mojom_bindings_generator.py, do not edit

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/skills/public/skill.mojom-shared.h"
#include <ostream>
#include <utility>
#include "base/strings/stringprintf.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/lib/validation_util.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"

#include "components/skills/public/skill.mojom-params-data.h"
namespace skills {
namespace mojom {

NOINLINE static const char* SkillSourceToStringHelper(SkillSource value) {
  // Defined in a helper function to ensure that Clang generates a lookup table.
  switch(value) {
    case SkillSource::kUnknown:
      return "kUnknown";
    case SkillSource::kFirstParty:
      return "kFirstParty";
    case SkillSource::kUserCreated:
      return "kUserCreated";
    case SkillSource::kDerivedFromFirstParty:
      return "kDerivedFromFirstParty";
    case SkillSource::kEnterprise:
      return "kEnterprise";
    case SkillSource::kDerivedFromEnterprise:
      return "kDerivedFromEnterprise";
    default:
      return nullptr;
  }
}

std::string SkillSourceToString(SkillSource value) {
  const char *str = SkillSourceToStringHelper(value);
  if (!str) {
    return base::StringPrintf("Unknown SkillSource value: %i", static_cast<int32_t>(value));
  }
  return str;
}

std::ostream& operator<<(std::ostream& os, SkillSource value) {
  return os << SkillSourceToString(value);
}

NOINLINE static const char* SkillsDialogTypeToStringHelper(SkillsDialogType value) {
  // Defined in a helper function to ensure that Clang generates a lookup table.
  switch(value) {
    case SkillsDialogType::kAdd:
      return "kAdd";
    case SkillsDialogType::kEdit:
      return "kEdit";
    default:
      return nullptr;
  }
}

std::string SkillsDialogTypeToString(SkillsDialogType value) {
  const char *str = SkillsDialogTypeToStringHelper(value);
  if (!str) {
    return base::StringPrintf("Unknown SkillsDialogType value: %i", static_cast<int32_t>(value));
  }
  return str;
}

std::ostream& operator<<(std::ostream& os, SkillsDialogType value) {
  return os << SkillsDialogTypeToString(value);
}

namespace internal {


// static
bool Skill_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 104, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const Skill_Data* object =
      static_cast<const Skill_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->id, 1, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& id_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->id, validation_context,
                                         &id_validate_params)) {
    return false;
  }

  constexpr const mojo::internal::ContainerValidateParams& source_skill_id_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->source_skill_id, validation_context,
                                         &source_skill_id_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->name, 3, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& name_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->name, validation_context,
                                         &name_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->icon, 4, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& icon_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->icon, validation_context,
                                         &icon_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->prompt, 5, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& prompt_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->prompt, validation_context,
                                         &prompt_validate_params)) {
    return false;
  }


  if (!::skills::mojom::internal::SkillSource_Data
        ::Validate(object->source, validation_context))
    return false;

  if (!mojo::internal::ValidatePointerNonNullable(
          object->description, 7, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& description_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->description, validation_context,
                                         &description_validate_params)) {
    return false;
  }

  constexpr const mojo::internal::ContainerValidateParams& curated_by_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->curated_by, validation_context,
                                         &curated_by_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidateStruct(object->image_url, validation_context))
    return false;

  if (!mojo::internal::ValidatePointerNonNullable(
          object->creation_time, 10, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateStruct(object->creation_time, validation_context))
    return false;

  if (!mojo::internal::ValidatePointerNonNullable(
          object->last_update_time, 11, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateStruct(object->last_update_time, validation_context))
    return false;

  constexpr const mojo::internal::ContainerValidateParams& category_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->category, validation_context,
                                         &category_validate_params)) {
    return false;
  }

  return true;
}

Skill_Data::Skill_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool TopicInfo_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 24, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const TopicInfo_Data* object =
      static_cast<const TopicInfo_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->category_name, 1, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& category_name_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->category_name, validation_context,
                                         &category_name_validate_params)) {
    return false;
  }

  if (!mojo::internal::ValidatePointerNonNullable(
          object->display_name, 2, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& display_name_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->display_name, validation_context,
                                         &display_name_validate_params)) {
    return false;
  }

  return true;
}

TopicInfo_Data::TopicInfo_Data()
    : header_({sizeof(*this), 0}) {}

}  // namespace internal
}  // namespace mojom
}  // namespace skills

namespace perfetto {

// static
void TraceFormatTraits<::skills::mojom::SkillSource>::WriteIntoTrace(
   perfetto::TracedValue context, ::skills::mojom::SkillSource value) {
  return std::move(context).WriteString(::skills::mojom::SkillSourceToString(value));
}

} // namespace perfetto

namespace perfetto {

// static
void TraceFormatTraits<::skills::mojom::SkillsDialogType>::WriteIntoTrace(
   perfetto::TracedValue context, ::skills::mojom::SkillsDialogType value) {
  return std::move(context).WriteString(::skills::mojom::SkillsDialogTypeToString(value));
}

} // namespace perfetto