From 9653dab9f4170e82a712570b033eb6fba0a11895 Mon Sep 17 00:00:00 2001 From: Greg Date: Thu, 9 Aug 2018 11:33:22 -0400 Subject: [PATCH] History() now returns the correct type. Added Save(), SaveSync(), Load() and Delete() to template. --- generate/template.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/generate/template.go b/generate/template.go index b5fdf55..d927caf 100644 --- a/generate/template.go +++ b/generate/template.go @@ -24,13 +24,35 @@ func (v *Var_N) Set(x _T) error { return ptr.Set(x) } +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...) +} + func (v *Var_N) Get(ts ...time.Time) _T { ptr := (*persist.Var)(unsafe.Pointer(v)) return ptr.Get(ts...).(_T) } -func (v *Var_N) History() ([]persist.Var, error) { +func (v *Var_N) Delete(t time.Time) { ptr := (*persist.Var)(unsafe.Pointer(v)) - return ptr.History() + ptr.Delete(t) +} + +func (v *Var_N) History() ([]Var_N, error) { + ptr := (*persist.Var)(unsafe.Pointer(v)) + h, err := ptr.History() + ret := (*[]Var_N)(unsafe.Pointer(&h)) + return *ret, err } `