// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com). // All rights reserved. // iterator.go package expr import ( "errors" "fmt" ) // Operator names const ( initName = "init" cleanName = "clean" resetName = "reset" nextName = "next" currentName = "current" indexName = "index" countName = "count" ) type Iterator interface { Next() (item any, err error) // must return io.EOF after the last item Current() (item any, err error) Index() int } type ExtIterator interface { Iterator HasOperation(name string) bool CallOperation(name string, args []any) (value any, err error) } func errNoOperation(name string) error { return fmt.Errorf("no %s() function defined in the data-source", name) } func errInvalidDataSource() error { return errors.New("invalid data-source") }