go-toast

Send toast notifications in Windows
Log | Files | Refs | README | LICENSE

xmldocument.go (1541B)


      1 // Code generated by winrt-go-gen. DO NOT EDIT.
      2 
      3 //go:build windows
      4 
      5 //nolint:all
      6 package dom
      7 
      8 import (
      9 	"syscall"
     10 	"unsafe"
     11 
     12 	"github.com/go-ole/go-ole"
     13 )
     14 
     15 const SignatureXmlDocument string = "rc(Windows.Data.Xml.Dom.XmlDocument;{f7f3a506-1e87-42d6-bcfb-b8c809fa5494})"
     16 
     17 type XmlDocument struct {
     18 	ole.IUnknown
     19 }
     20 
     21 func NewXmlDocument() (*XmlDocument, error) {
     22 	inspectable, err := ole.RoActivateInstance("Windows.Data.Xml.Dom.XmlDocument")
     23 	if err != nil {
     24 		return nil, err
     25 	}
     26 	return (*XmlDocument)(unsafe.Pointer(inspectable)), nil
     27 }
     28 
     29 func (impl *XmlDocument) LoadXml(xml string) error {
     30 	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiXmlDocumentIO))
     31 	defer itf.Release()
     32 	v := (*iXmlDocumentIO)(unsafe.Pointer(itf))
     33 	return v.LoadXml(xml)
     34 }
     35 
     36 const (
     37 	GUIDiXmlDocumentIO      string = "6cd0e74e-ee65-4489-9ebf-ca43e87ba637"
     38 	SignatureiXmlDocumentIO string = "{6cd0e74e-ee65-4489-9ebf-ca43e87ba637}"
     39 )
     40 
     41 type iXmlDocumentIO struct {
     42 	ole.IInspectable
     43 }
     44 
     45 type iXmlDocumentIOVtbl struct {
     46 	ole.IInspectableVtbl
     47 
     48 	LoadXml             uintptr
     49 	LoadXmlWithSettings uintptr
     50 	SaveToFileAsync     uintptr
     51 }
     52 
     53 func (v *iXmlDocumentIO) VTable() *iXmlDocumentIOVtbl {
     54 	return (*iXmlDocumentIOVtbl)(unsafe.Pointer(v.RawVTable))
     55 }
     56 
     57 func (v *iXmlDocumentIO) LoadXml(xml string) error {
     58 	xmlHStr, err := ole.NewHString(xml)
     59 	if err != nil {
     60 		return err
     61 	}
     62 	hr, _, _ := syscall.SyscallN(
     63 		v.VTable().LoadXml,
     64 		uintptr(unsafe.Pointer(v)), // this
     65 		uintptr(xmlHStr),           // in string
     66 	)
     67 
     68 	if hr != 0 {
     69 		return ole.NewError(hr)
     70 	}
     71 
     72 	return nil
     73 }