2024-07-12 11:13:15 +08:00
|
|
|
package inih
|
|
|
|
|
|
|
|
|
|
import (
|
2024-07-12 12:03:15 +08:00
|
|
|
"unsafe"
|
2024-07-12 11:13:15 +08:00
|
|
|
|
|
|
|
|
"github.com/goplus/llgo/c"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// llgo:type C
|
|
|
|
|
type Reader struct {
|
|
|
|
|
Unused [24]byte
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 12:03:15 +08:00
|
|
|
type StdString struct {
|
|
|
|
|
buf [24]byte
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type stringHead struct {
|
|
|
|
|
data unsafe.Pointer
|
|
|
|
|
size int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type __long struct {
|
|
|
|
|
__cap_ int
|
|
|
|
|
__size_ int
|
|
|
|
|
__data_ unsafe.Pointer
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Str(s string) *StdString {
|
|
|
|
|
var r StdString
|
2024-07-12 11:13:15 +08:00
|
|
|
r.init(c.GoStringData(s), c.Int(len(s)))
|
|
|
|
|
return &r
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 12:03:15 +08:00
|
|
|
func (r *StdString) String() string {
|
|
|
|
|
if r.buf[0]&1 == 0 {
|
|
|
|
|
return c.GoString((*c.Char)(unsafe.Pointer(&r.buf[1])))
|
|
|
|
|
} else {
|
|
|
|
|
v := *(*__long)(unsafe.Pointer(&r.buf[0]))
|
|
|
|
|
return *(*string)(unsafe.Pointer(&stringHead{data: v.__data_, size: v.__size_}))
|
|
|
|
|
}
|
2024-07-12 11:13:15 +08:00
|
|
|
}
|
|
|
|
|
|
2024-07-12 12:03:15 +08:00
|
|
|
// llgo:link (*StdString).init C._ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm
|
|
|
|
|
func (*StdString) init(s *c.Char, size c.Int) {}
|
2024-07-12 11:13:15 +08:00
|
|
|
|
|
|
|
|
//go:linkname NewReader C._ZN9INIReaderC1EPKcm
|
|
|
|
|
func NewReader(fileName *c.Char, size c.Ulong) Reader
|
|
|
|
|
|
|
|
|
|
//go:linkname NewReaderFile C._ZN9INIReaderC1ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
|
2024-07-12 12:03:15 +08:00
|
|
|
func NewReaderFile(fileName *StdString) Reader
|
2024-07-12 11:13:15 +08:00
|
|
|
|
|
|
|
|
// llgo:link (*Reader).ParseError C._ZNK9INIReader10ParseErrorEv
|
|
|
|
|
func (*Reader) ParseError() c.Int { return 0 }
|
|
|
|
|
|
|
|
|
|
// llgo:link (*Reader).GetInteger C._ZNK9INIReader10GetIntegerERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_l
|
2024-07-12 12:03:15 +08:00
|
|
|
func (*Reader) GetInteger(section *StdString, name *StdString, defaultValue c.Long) c.Long {
|
2024-07-12 11:13:15 +08:00
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// llgo:link (*Reader).GetBoolean C._ZNK9INIReader10GetBooleanERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_b
|
2024-07-12 12:03:15 +08:00
|
|
|
func (*Reader) GetBoolean(section *StdString, name *StdString, defaultValue bool) bool {
|
2024-07-12 11:13:15 +08:00
|
|
|
return false
|
|
|
|
|
}
|
2024-07-12 12:03:15 +08:00
|
|
|
|
|
|
|
|
// llgo:link (*Reader).GetString C._ZNK9INIReader9GetStringERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_S8_
|
2024-07-12 13:53:01 +08:00
|
|
|
func (*Reader) GetString(section *StdString, name *StdString, defaultValue *StdString) StdString {
|
|
|
|
|
return StdString{}
|
2024-07-12 12:03:15 +08:00
|
|
|
}
|