Documentation ¶
Index ¶
- Constants
- func ConvertSignedTemplate[T SignedNumber](r *ByteReader, processNonDigit func(uint, uint, T) (uint, error), ...) (T, uint, error)
- func ConvertTemplate[T Number](r *ByteReader, processNonDigit func(uint, uint, T) (uint, error), ...) (T, uint, error)
- func GetType[T any]() r.Type
- func GetTypeKind[T any]() r.Kind
- func ProcessDigit[T constraints.Integer](digit uint, flags uint, res T) (T, uint)
- func ProcessFloatNonDigit[T constraints.Float](digit uint, flags uint, res T) (uint, error)
- func ProcessIntNonDigit[T constraints.Signed](digit uint, flags uint, res T) (uint, error)
- func ProcessNonDigit[T Number](digit uint, flags uint, res T) (uint, error)
- func ProcessSignedNonDigit[T SignedNumber](digit uint, flags uint, res T) (uint, error)
- func ProcessUintNonDigit[T constraints.Unsigned](digit uint, flags uint, res T) (uint, error)
- type ByteReader
- type DescendInfo
- type Number
- type SignedNumber
- type SliceReader
Constants ¶
const ( // Floating point symbol found when reading the next digit DecimalDot uint = 10 // Minus sign symbol found when reading the next digit MinusSign uint = 11 // Newline found when reading the next digit Newline uint = 12 // Whitespace found when reading the next digit WhiteSpace uint = 13 // Error found when reading the next digit ErrDigit uint = 14 // Letter found when reading the next digit Letter uint = 15 // The slice reader should break the loop for current element Break uint = 0x01 // Current element has decimal places HasDecimals uint = 0x02 // Newline found when reading current element HasNewline uint = 0x04 // Current element has at least one digit HasValue uint = 0x08 // Current element has minus sign IsNegative uint = 0x10 )
Variables ¶
This section is empty.
Functions ¶
func ConvertSignedTemplate ¶ added in v1.0.1
func ConvertSignedTemplate[T SignedNumber](r *ByteReader, processNonDigit func(uint, uint, T) (uint, error), processDigit func(uint, uint, T) (T, uint), ) (T, uint, error)
Template function for converting floats and integers
func ConvertTemplate ¶ added in v1.0.1
func ConvertTemplate[T Number]( r *ByteReader, processNonDigit func(uint, uint, T) (uint, error), processDigit func(uint, uint, T) (T, uint), ) (T, uint, error)
Template function for converting all number types
func GetTypeKind ¶ added in v1.0.1
Returns reflection Kind corresponding to the specified generic type
func ProcessDigit ¶
func ProcessDigit[T constraints.Integer](digit uint, flags uint, res T) (T, uint)
Combines digit with the current result
func ProcessFloatNonDigit ¶
Processes non-digit symbols for floats
func ProcessIntNonDigit ¶
Processes non-digit symbols for integers
func ProcessNonDigit ¶
Processes non-digit symbols for all number types
func ProcessSignedNonDigit ¶
func ProcessSignedNonDigit[T SignedNumber](digit uint, flags uint, res T) (uint, error)
Processes non-digit symbols for floats and integers
func ProcessUintNonDigit ¶
Processes non-digit symbols for unsigned integers
Types ¶
type ByteReader ¶
type ByteReader struct {
// contains filtered or unexported fields
}
Buffered reader of bytes
func NewByteReader ¶
func NewByteReader(r io.Reader, chunkSize int) *ByteReader
Constructs new ByteReader
func (*ByteReader) LookAheadFor ¶ added in v1.0.4
func (r *ByteReader) LookAheadFor(b byte) (bool, error)
Searches for byte b, if found moves back one character behind b
func (*ByteReader) MoveBack ¶ added in v1.0.4
func (r *ByteReader) MoveBack()
Moves the head one place backwards
func (*ByteReader) NextByte ¶
func (r *ByteReader) NextByte() (byte, error)
Returns the next byte without any conversions. If current buffer is exhausted, a new buffer is read.
func (*ByteReader) NextByteConvertNewline ¶ added in v1.0.4
func (r *ByteReader) NextByteConvertNewline() (byte, error)
Returns next byte and convert "\r\n" to "\n"
func (*ByteReader) NextDigit ¶
func (r *ByteReader) NextDigit() (uint, error)
Returns next number symbol as uint
func (*ByteReader) SkipByte ¶ added in v1.0.4
func (r *ByteReader) SkipByte(b byte) error
Skip the next byte b, if found
type DescendInfo ¶ added in v1.0.3
Result of counting number of dimensions of a generic type
func Descend ¶ added in v1.0.3
func Descend[T any]() DescendInfo
Counts number of dimensions of a generic type
func DynamicDescend ¶ added in v1.0.3
func DynamicDescend(aType r.Type) DescendInfo
Counts number of dimensions of a reflection Type
type Number ¶
type Number interface { constraints.Float | constraints.Integer }
Generic type constraint for all numbers
type SignedNumber ¶
type SignedNumber interface { constraints.Float | constraints.Signed }
Generic type constraint for floats and integers
type SliceReader ¶
type SliceReader[T any] struct { Buf1 []T Buf2 [][]T Buf3 [][][]T // contains filtered or unexported fields }
Reads 1D, 2D or 3D slice of T from the specified ByteReader. For each element of type T, a conversion function conv is used to construct it from the current position of ByteReader.
func NewSliceReader ¶
func NewSliceReader[T any]( byteReader *ByteReader, conv func(*ByteReader) (T, uint, error), dim uint, ) *SliceReader[T]
Constructs new SliceReader
func RunSliceReader ¶
func RunSliceReader[T any]( r io.Reader, chunkSize int, conv func(*ByteReader) (T, uint, error), dim uint) (*SliceReader[T], error)
Constructs and runs a SliceReader
func (*SliceReader[T]) Run ¶
func (s *SliceReader[T]) Run() error
Converts all bytes from ByteReader to the specified slice of dimension s.dim