// third_party/blink/public/mojom/speech/speech_recognition_result.mojom-blink.cc is auto generated by mojom_bindings_generator.py, do not edit

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

#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
#endif

#include "third_party/blink/public/mojom/speech/speech_recognition_result.mojom-blink.h"

#include <math.h>
#include <stdint.h>
#include <utility>

#include "base/hash/md5_constexpr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/common/task_annotator.h"
#include "base/trace_event/trace_conversion_helper.h"
#include "base/trace_event/traced_value.h"
#include "mojo/public/cpp/bindings/lib/generated_code_util.h"
#include "mojo/public/cpp/bindings/lib/message_internal.h"
#include "mojo/public/cpp/bindings/lib/serialization_util.h"
#include "mojo/public/cpp/bindings/lib/unserialized_message_context.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_context.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/interfaces/bindings/interface_control_messages.mojom.h"

#include "third_party/blink/public/mojom/speech/speech_recognition_result.mojom-params-data.h"
#include "third_party/blink/public/mojom/speech/speech_recognition_result.mojom-shared-message-ids.h"

#include "third_party/blink/public/mojom/speech/speech_recognition_result.mojom-blink-import-headers.h"
#include "mojo/public/cpp/bindings/lib/wtf_serialization.h"


#ifndef THIRD_PARTY_BLINK_PUBLIC_MOJOM_SPEECH_SPEECH_RECOGNITION_RESULT_MOJOM_BLINK_JUMBO_H_
#define THIRD_PARTY_BLINK_PUBLIC_MOJOM_SPEECH_SPEECH_RECOGNITION_RESULT_MOJOM_BLINK_JUMBO_H_
#endif
namespace blink {
namespace mojom {
namespace blink {
SpeechRecognitionHypothesis::SpeechRecognitionHypothesis()
    : utterance(),
      confidence() {}

SpeechRecognitionHypothesis::SpeechRecognitionHypothesis(
    const ::WTF::String& utterance_in,
    double confidence_in)
    : utterance(std::move(utterance_in)),
      confidence(std::move(confidence_in)) {}

SpeechRecognitionHypothesis::~SpeechRecognitionHypothesis() = default;

void SpeechRecognitionHypothesis::AsValueInto(base::trace_event::TracedValue* value) const {
  value->SetString("utterance", base::trace_event::ValueToString(this->utterance, "<value of type const ::WTF::String&>"));
  value->SetDouble("confidence", this->confidence);
}

bool SpeechRecognitionHypothesis::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
SpeechRecognitionResult::SpeechRecognitionResult()
    : hypotheses(),
      is_provisional() {}

SpeechRecognitionResult::SpeechRecognitionResult(
    WTF::Vector<SpeechRecognitionHypothesisPtr> hypotheses_in,
    bool is_provisional_in)
    : hypotheses(std::move(hypotheses_in)),
      is_provisional(std::move(is_provisional_in)) {}

SpeechRecognitionResult::~SpeechRecognitionResult() = default;

void SpeechRecognitionResult::AsValueInto(base::trace_event::TracedValue* value) const {
  value->BeginArray("hypotheses");
  for (const auto& item0 : this->hypotheses) {
    if (item0.is_null()) {
      value->AppendString("nullptr");
    } else {
      value->BeginDictionary();
      item0->AsValueInto(value);
      value->EndDictionary();
    }
  }
  value->EndArray();
  value->SetBoolean("is_provisional", this->is_provisional);
}

bool SpeechRecognitionResult::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
}  // namespace blink
}  // namespace mojom
}  // namespace blink

namespace mojo {


// static
bool StructTraits<::blink::mojom::blink::SpeechRecognitionHypothesis::DataView, ::blink::mojom::blink::SpeechRecognitionHypothesisPtr>::Read(
    ::blink::mojom::blink::SpeechRecognitionHypothesis::DataView input,
    ::blink::mojom::blink::SpeechRecognitionHypothesisPtr* output) {
  bool success = true;
  ::blink::mojom::blink::SpeechRecognitionHypothesisPtr result(::blink::mojom::blink::SpeechRecognitionHypothesis::New());
  
      if (success && !input.ReadUtterance(&result->utterance))
        success = false;
      if (success)
        result->confidence = input.confidence();
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::blink::mojom::blink::SpeechRecognitionResult::DataView, ::blink::mojom::blink::SpeechRecognitionResultPtr>::Read(
    ::blink::mojom::blink::SpeechRecognitionResult::DataView input,
    ::blink::mojom::blink::SpeechRecognitionResultPtr* output) {
  bool success = true;
  ::blink::mojom::blink::SpeechRecognitionResultPtr result(::blink::mojom::blink::SpeechRecognitionResult::New());
  
      if (success && !input.ReadHypotheses(&result->hypotheses))
        success = false;
      if (success)
        result->is_provisional = input.is_provisional();
  *output = std::move(result);
  return success;
}

}  // namespace mojo

#if defined(__clang__)
#pragma clang diagnostic pop
#endif