31 lines
632 B
Go
31 lines
632 B
Go
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
|
// All rights reserved.
|
|
|
|
// iterator.go
|
|
package expr
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
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 %q function defined in the data-source", name)
|
|
}
|
|
|
|
func errInvalidDataSource() error {
|
|
return errors.New("invalid data-source")
|
|
}
|