// Code generated by winrt-go-gen. DO NOT EDIT.

//go:build windows

//nolint:all
package genericattributeprofile

import (
	"syscall"
	"unsafe"

	"git.savin.nyc/alex/go-winrt/windows/foundation"
	"git.savin.nyc/alex/go-winrt/windows/storage/streams"
	"github.com/go-ole/go-ole"
)

const SignatureGattValueChangedEventArgs string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattValueChangedEventArgs;{d21bdb54-06e3-4ed8-a263-acfac8ba7313})"

type GattValueChangedEventArgs struct {
	ole.IUnknown
}

func (impl *GattValueChangedEventArgs) GetCharacteristicValue() (*streams.IBuffer, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattValueChangedEventArgs))
	defer itf.Release()
	v := (*iGattValueChangedEventArgs)(unsafe.Pointer(itf))
	return v.GetCharacteristicValue()
}

func (impl *GattValueChangedEventArgs) GetTimestamp() (foundation.DateTime, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattValueChangedEventArgs))
	defer itf.Release()
	v := (*iGattValueChangedEventArgs)(unsafe.Pointer(itf))
	return v.GetTimestamp()
}

const GUIDiGattValueChangedEventArgs string = "d21bdb54-06e3-4ed8-a263-acfac8ba7313"
const SignatureiGattValueChangedEventArgs string = "{d21bdb54-06e3-4ed8-a263-acfac8ba7313}"

type iGattValueChangedEventArgs struct {
	ole.IInspectable
}

type iGattValueChangedEventArgsVtbl struct {
	ole.IInspectableVtbl

	GetCharacteristicValue uintptr
	GetTimestamp           uintptr
}

func (v *iGattValueChangedEventArgs) VTable() *iGattValueChangedEventArgsVtbl {
	return (*iGattValueChangedEventArgsVtbl)(unsafe.Pointer(v.RawVTable))
}

func (v *iGattValueChangedEventArgs) GetCharacteristicValue() (*streams.IBuffer, error) {
	var out *streams.IBuffer
	hr, _, _ := syscall.SyscallN(
		v.VTable().GetCharacteristicValue,
		uintptr(unsafe.Pointer(v)),    // this
		uintptr(unsafe.Pointer(&out)), // out streams.IBuffer
	)

	if hr != 0 {
		return nil, ole.NewError(hr)
	}

	return out, nil
}

func (v *iGattValueChangedEventArgs) GetTimestamp() (foundation.DateTime, error) {
	var out foundation.DateTime
	hr, _, _ := syscall.SyscallN(
		v.VTable().GetTimestamp,
		uintptr(unsafe.Pointer(v)),    // this
		uintptr(unsafe.Pointer(&out)), // out foundation.DateTime
	)

	if hr != 0 {
		return foundation.DateTime{}, ole.NewError(hr)
	}

	return out, nil
}
