func (c *state) SetBufferFromIndex(v interface{}, i int) error {
	if len(c.buffer)-1 >= i {
		c.buffer[i] = &v
		return nil
	}
	return fmt.Errorf(ire)
}
SetDataFromIndex sets to input value the i'th element from the data array
package db
import (
	"fmt"
	"strings"
)
const (
	ire = "index error"
)
type state struct {
	data   []interface{}
	buffer []*interface{}
	lib    map[string]int
	ad     int
}
func newStateFactory() *state {
	s := state{
		data:   make([]interface{}, 0),
		buffer: make([]*interface{}, 0),
		lib:    make(map[string]int),
	}
	return &s
}
func (c *state) Clear() {
	c.data, c.buffer, c.lib = nil, nil, nil
	c.data = make([]interface{}, 0)
	c.buffer = make([]*interface{}, 0)
	c.lib = make(map[string]int)
}
func (c *state) SetAD(i int) error {
	if err := c.IndexInRange(i); err != nil {
		return wrapErr(err)
	}
	c.ad = i
	return nil
}
func (c *state) GetAD() int {
	return c.ad
}
func (c *state) PushData(d interface{}) {
	c.data = append(c.data, d)
}
func (c *state) PushBuffer(d interface{}) {
	c.buffer = append(c.buffer, &d)
}
func (c *state) GetAllData() []interface{} {
	return c.data
}
func (c *state) GetAllBuffer() []*interface{} {
	return c.buffer
}
func (c *state) GetData() interface{} {
	data, _ := c.GetDataFromIndex(c.GetAD())
	return data
}
func (c *state) GetDataFromIndex(i int) (interface{}, error) {
	if err := c.IndexInRange(i); err != nil {
		return nil, wrapErr(err)
	}
	return c.data[i], nil
}
func (c *state) SetData(v interface{}) error {
	return c.SetDataFromIndex(v, c.GetAD())
}
func (c *state) SetDataFromIndex(v interface{}, i int) error {
	if err := c.IndexInRange(i); err != nil {
		return wrapErr(err)
	}
	c.data[i] = v
	return nil
}
func (c *state) GetBufferFromIndex(i int) (*interface{}, error) {
	if len(c.buffer)-1 >= i {
		return c.buffer[i], nil
	}
	return nil, fmt.Errorf(ire)
}