2018-08-06 12:14:16 -04:00
|
|
|
package generate
|
2018-08-06 11:06:33 -04:00
|
|
|
const template string = `//Generated by gitlab.wow.st/persist/cmd/pgen.
|
|
|
|
//Do not edit
|
|
|
|
package main
|
2018-08-03 15:08:30 -04:00
|
|
|
|
|
|
|
import (
|
2018-08-03 15:14:10 -04:00
|
|
|
"encoding/gob"
|
2018-08-03 15:08:30 -04:00
|
|
|
"time"
|
|
|
|
"unsafe"
|
|
|
|
"gitlab.wow.st/gmp/persist"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Var_N persist.Var
|
|
|
|
|
2018-08-04 16:03:00 -04:00
|
|
|
func New(name string, x _T, opt ...persist.Option) *Var_N {
|
2018-08-03 15:14:10 -04:00
|
|
|
gob.Register(x)
|
2018-08-04 16:03:00 -04:00
|
|
|
ptr := persist.New(name, x, opt...)
|
2018-08-03 15:08:30 -04:00
|
|
|
ret := (*Var_N)(unsafe.Pointer(ptr))
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *Var_N) Set(x _T) error {
|
|
|
|
ptr := (*persist.Var)(unsafe.Pointer(v))
|
|
|
|
return ptr.Set(x)
|
|
|
|
}
|
|
|
|
|
2018-08-09 11:33:22 -04:00
|
|
|
func (v *Var_N) SaveSync() {
|
|
|
|
ptr := (*persist.Var)(unsafe.Pointer(v))
|
|
|
|
ptr.SaveSync()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *Var_N) Save(sync ...bool) {
|
|
|
|
ptr := (*persist.Var)(unsafe.Pointer(v))
|
|
|
|
ptr.Save(sync...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *Var_N) Load(ts ...time.Time) error {
|
|
|
|
ptr := (*persist.Var)(unsafe.Pointer(v))
|
|
|
|
return ptr.Load(ts...)
|
|
|
|
}
|
|
|
|
|
2018-08-03 15:08:30 -04:00
|
|
|
func (v *Var_N) Get(ts ...time.Time) _T {
|
|
|
|
ptr := (*persist.Var)(unsafe.Pointer(v))
|
|
|
|
return ptr.Get(ts...).(_T)
|
|
|
|
}
|
|
|
|
|
2018-08-09 11:33:22 -04:00
|
|
|
func (v *Var_N) Delete(t time.Time) {
|
|
|
|
ptr := (*persist.Var)(unsafe.Pointer(v))
|
|
|
|
ptr.Delete(t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *Var_N) History() ([]Var_N, error) {
|
2018-08-03 15:08:30 -04:00
|
|
|
ptr := (*persist.Var)(unsafe.Pointer(v))
|
2018-08-09 11:33:22 -04:00
|
|
|
h, err := ptr.History()
|
|
|
|
ret := (*[]Var_N)(unsafe.Pointer(&h))
|
|
|
|
return *ret, err
|
2018-08-03 15:08:30 -04:00
|
|
|
}
|
|
|
|
`
|