///
/// SpeechSynthesisUtterance.swift
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

import NitroModules

/**
 * Represents an instance of `SpeechSynthesisUtterance`, backed by a C++ struct.
 */
public typealias SpeechSynthesisUtterance = margelo.nitro.one.SpeechSynthesisUtterance

public extension SpeechSynthesisUtterance {
  private typealias bridge = margelo.nitro.one.bridge.swift

  /**
   * Create a new instance of `SpeechSynthesisUtterance`.
   */
  init(text: String, language: String?, pitch: Double?, rate: Double?, voice: String?, volume: Double?) {
    self.init(std.string(text), { () -> bridge.std__optional_std__string_ in
      if let __unwrappedValue = language {
        return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
      } else {
        return .init()
      }
    }(), { () -> bridge.std__optional_double_ in
      if let __unwrappedValue = pitch {
        return bridge.create_std__optional_double_(__unwrappedValue)
      } else {
        return .init()
      }
    }(), { () -> bridge.std__optional_double_ in
      if let __unwrappedValue = rate {
        return bridge.create_std__optional_double_(__unwrappedValue)
      } else {
        return .init()
      }
    }(), { () -> bridge.std__optional_std__string_ in
      if let __unwrappedValue = voice {
        return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
      } else {
        return .init()
      }
    }(), { () -> bridge.std__optional_double_ in
      if let __unwrappedValue = volume {
        return bridge.create_std__optional_double_(__unwrappedValue)
      } else {
        return .init()
      }
    }())
  }

  @inline(__always)
  var text: String {
    return String(self.__text)
  }
  
  @inline(__always)
  var language: String? {
    return { () -> String? in
      if bridge.has_value_std__optional_std__string_(self.__language) {
        let __unwrapped = bridge.get_std__optional_std__string_(self.__language)
        return String(__unwrapped)
      } else {
        return nil
      }
    }()
  }
  
  @inline(__always)
  var pitch: Double? {
    return { () -> Double? in
      if bridge.has_value_std__optional_double_(self.__pitch) {
        let __unwrapped = bridge.get_std__optional_double_(self.__pitch)
        return __unwrapped
      } else {
        return nil
      }
    }()
  }
  
  @inline(__always)
  var rate: Double? {
    return { () -> Double? in
      if bridge.has_value_std__optional_double_(self.__rate) {
        let __unwrapped = bridge.get_std__optional_double_(self.__rate)
        return __unwrapped
      } else {
        return nil
      }
    }()
  }
  
  @inline(__always)
  var voice: String? {
    return { () -> String? in
      if bridge.has_value_std__optional_std__string_(self.__voice) {
        let __unwrapped = bridge.get_std__optional_std__string_(self.__voice)
        return String(__unwrapped)
      } else {
        return nil
      }
    }()
  }
  
  @inline(__always)
  var volume: Double? {
    return { () -> Double? in
      if bridge.has_value_std__optional_double_(self.__volume) {
        let __unwrapped = bridge.get_std__optional_double_(self.__volume)
        return __unwrapped
      } else {
        return nil
      }
    }()
  }
}
