energy/cef/types-string-multi-map.go

99 lines
2.6 KiB
Go
Raw Normal View History

2022-10-04 13:21:05 +08:00
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
2022-10-04 13:21:05 +08:00
//
//----------------------------------------
2023-02-27 09:15:37 +08:00
// CEF 多值MAP类型 StringMultiMapRef.New
2023-05-31 17:41:14 +08:00
2022-10-04 13:21:05 +08:00
package cef
import (
"github.com/energye/energy/v2/cef/internal/def"
2023-05-31 18:00:34 +08:00
"github.com/energye/energy/v2/common/imports"
2022-10-04 13:21:05 +08:00
"github.com/energye/golcl/lcl/api"
"unsafe"
)
2023-02-27 09:15:37 +08:00
// StringMultiMapRef -> ICefStringMultiMap
var StringMultiMapRef stringMultiMap
// stringMultiMap
type stringMultiMap uintptr
// New 创建一个新的 StringMultiMap
func (m *stringMultiMap) New() *ICefStringMultiMap {
var result uintptr
imports.Proc(def.StringMultimapRef_Create).Call(uintptr(unsafe.Pointer(&result)))
2023-02-27 09:15:37 +08:00
return &ICefStringMultiMap{instance: unsafe.Pointer(result)}
2023-02-26 23:21:44 +08:00
}
// Instance 实例
func (m *ICefStringMultiMap) Instance() uintptr {
if m == nil {
return 0
}
return uintptr(m.instance)
2022-10-04 13:21:05 +08:00
}
2023-02-27 11:33:00 +08:00
func (m *ICefStringMultiMap) IsValid() bool {
if m == nil || m.instance == nil {
return false
}
return true
}
2023-02-20 14:42:17 +08:00
// GetSize 大小
2023-02-27 19:42:50 +08:00
func (m *ICefStringMultiMap) GetSize() uint32 {
r1, _, _ := imports.Proc(def.StringMultimap_GetSize).Call(m.Instance())
2023-02-27 19:42:50 +08:00
return uint32(r1)
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// FindCount key值数量
2023-02-27 19:42:50 +08:00
func (m *ICefStringMultiMap) FindCount(key string) uint32 {
r1, _, _ := imports.Proc(def.StringMultimap_FindCount).Call(m.Instance(), api.PascalStr(key))
2023-02-27 19:42:50 +08:00
return uint32(r1)
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
2023-02-26 23:21:44 +08:00
// GetEnumerate 根据 key and index 获取
func (m *ICefStringMultiMap) GetEnumerate(key string, index uint32) (r string) {
value := NewTString()
imports.Proc(def.StringMultimap_GetEnumerate).Call(m.Instance(), api.PascalStr(key), uintptr(index), value.Instance())
r = value.Value()
value.Free()
return
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// GetKey 根据 index 获取key
func (m *ICefStringMultiMap) GetKey(index uint32) (r string) {
value := NewTString()
imports.Proc(def.StringMultimap_GetKey).Call(m.Instance(), uintptr(index), value.Instance())
r = value.Value()
value.Free()
return r
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// GetValue 根据 index 获取value
func (m *ICefStringMultiMap) GetValue(index uint32) (r string) {
value := NewTString()
imports.Proc(def.StringMultimap_GetValue).Call(m.Instance(), uintptr(index), value.Instance())
r = value.Value()
value.Free()
return
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// Append 给key追加值
2022-10-04 13:21:05 +08:00
func (m *ICefStringMultiMap) Append(key, value string) bool {
r1, _, _ := imports.Proc(def.StringMultimap_Append).Call(m.Instance(), api.PascalStr(key), api.PascalStr(value))
2023-02-26 23:21:44 +08:00
return api.GoBool(r1)
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// Clear 清空
2022-10-04 13:21:05 +08:00
func (m *ICefStringMultiMap) Clear() {
imports.Proc(def.StringMultimap_Clear).Call(m.Instance())
2022-10-04 13:21:05 +08:00
}