///
/// GATTService.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 `GATTService`, backed by a C++ struct.
 */
public typealias GATTService = margelo.nitro.munimbluetooth.GATTService

public extension GATTService {
  private typealias bridge = margelo.nitro.munimbluetooth.bridge.swift

  /**
   * Create a new instance of `GATTService`.
   */
  init(uuid: String, characteristics: [GATTCharacteristic], includedServices: [String]?) {
    self.init(std.string(uuid), { () -> bridge.std__vector_GATTCharacteristic_ in
      var __vector = bridge.create_std__vector_GATTCharacteristic_(characteristics.count)
      for __item in characteristics {
        __vector.push_back(__item)
      }
      return __vector
    }(), { () -> bridge.std__optional_std__vector_std__string__ in
      if let __unwrappedValue = includedServices {
        return bridge.create_std__optional_std__vector_std__string__({ () -> bridge.std__vector_std__string_ in
          var __vector = bridge.create_std__vector_std__string_(__unwrappedValue.count)
          for __item in __unwrappedValue {
            __vector.push_back(std.string(__item))
          }
          return __vector
        }())
      } else {
        return .init()
      }
    }())
  }

  @inline(__always)
  var uuid: String {
    return String(self.__uuid)
  }
  
  @inline(__always)
  var characteristics: [GATTCharacteristic] {
    return self.__characteristics.map({ __item in __item })
  }
  
  @inline(__always)
  var includedServices: [String]? {
    return { () -> [String]? in
      if bridge.has_value_std__optional_std__vector_std__string__(self.__includedServices) {
        let __unwrapped = bridge.get_std__optional_std__vector_std__string__(self.__includedServices)
        return __unwrapped.map({ __item in String(__item) })
      } else {
        return nil
      }
    }()
  }
}
