Documentation ¶
Index ¶
- Constants
- Variables
- func GetPool() schnittstellen.Pool[String, *String]
- func MakeErrLength(expected, actual int64, err error) error
- func NewScannerExperimental(r *RingBuffer) *scannerExperimental
- func WriteKeySpaceValueNewline(w io.Writer, key, value io.WriterTo) (n int64, err error)
- type RingBuffer
- func (rb *RingBuffer) AdvanceRead(n int)
- func (rb *RingBuffer) Cap() int
- func (rb *RingBuffer) Fill() (n int64, err error)
- func (rb *RingBuffer) Len() int
- func (rb *RingBuffer) PeekReadable() (rs Slice)
- func (rb *RingBuffer) PeekUnreadable() (rs Slice)
- func (rb *RingBuffer) PeekUpto(b byte) (readable Slice, err error)
- func (rb *RingBuffer) PeekUptoAndIncluding(b byte) (readable Slice, err error)
- func (rb *RingBuffer) PeekWriteable() (rs Slice)
- func (rb *RingBuffer) Read(p []byte) (n int, err error)
- func (rb *RingBuffer) ReadLength() int64
- func (rb *RingBuffer) Reset(r io.Reader)
- func (rb *RingBuffer) Seek(offset int64, whence int) (actual int64, err error)
- func (rb *RingBuffer) Unread(toUnread int) (actuallyUnread int)
- func (rb *RingBuffer) Write(p []byte) (n int, err error)
- type RingBufferRuneScanner
- type RingBufferScanner
- type Scanner
- type Slice
- func (rs Slice) Bytes() []byte
- func (rs Slice) BytesBetween(left, right int) []byte
- func (rs Slice) Compare(b []byte) (c int)
- func (rs Slice) Cut(b byte) (before, after Slice, ok bool)
- func (rs Slice) Equal(b []byte) bool
- func (rs Slice) First() []byte
- func (a Slice) FirstByte() byte
- func (rs Slice) IsEmpty() bool
- func (rs Slice) Len() int
- func (rs Slice) LenFirst() int
- func (rs Slice) LenSecond() int
- func (rs Slice) Overlap() (o [6]byte, first, second int)
- func (rs Slice) ReadFrom(r io.Reader) (n int64, err error)
- func (rs Slice) Second() []byte
- func (a Slice) Slice(left, right int) (b Slice)
- func (a Slice) SliceBytes() SliceBytes
- func (rs Slice) SliceUptoAndIncluding(b byte) (s Slice, ok bool)
- func (rs Slice) SliceUptoButExcluding(b byte) (s Slice, ok bool)
- func (rs Slice) Start() int64
- func (rs Slice) String() string
- func (rs Slice) WriteTo(w io.Writer) (n int64, err error)
- type SliceBytes
- type SliceReader
- type SliceRuneScanner
- func (s *SliceRuneScanner) Error() error
- func (s *SliceRuneScanner) Offset() int
- func (s *SliceRuneScanner) ReadRune() (r rune, size int, err error)
- func (s *SliceRuneScanner) Remaining() int
- func (s *SliceRuneScanner) Reset()
- func (s *SliceRuneScanner) ResetSliceOnly(slice Slice)
- func (s *SliceRuneScanner) ResetWith(slice Slice)
- func (s *SliceRuneScanner) Scan() (r rune, width int, ok bool)
- func (s *SliceRuneScanner) UnreadRune() (err error)
- type SplitFunc
- type SplitFuncExperimental
- type String
- func (str *String) Append(vs ...*String) (n int, err error)
- func (str *String) Available() int
- func (str *String) AvailableBuffer() []byte
- func (str *String) Bytes() []byte
- func (src *String) CopyTo(dst *String) (err error)
- func (a *String) Equals(b *String) bool
- func (a *String) EqualsBytes(b []byte) bool
- func (a *String) EqualsString(b string) bool
- func (str *String) Grow(n int)
- func (str *String) Len() int
- func (str *String) Map(mapping func(r rune) rune, s []byte) (n int)
- func (src *String) MarshalBinary() ([]byte, error)
- func (src *String) MarshalText() ([]byte, error)
- func (dst *String) ReadFrom(r io.Reader) (n int64, err error)
- func (dst *String) ReadFromBuffer(src *bytes.Buffer) (err error)
- func (dst *String) ReadNFrom(r io.Reader, toRead int) (read int, err error)
- func (str *String) Reset()
- func (dst *String) Set(src string) (err error)
- func (dst *String) SetBytes(src []byte) (err error)
- func (str *String) String() string
- func (src *String) UnmarshalBinary(b []byte) error
- func (src *String) UnmarshalText(b []byte) error
- func (str *String) Write(p []byte) (int, error)
- func (str *String) WriteLower(s []byte) (n int)
- func (str *String) WriteLowerOrError(s []byte) (err error)
- func (dst *String) WriteRune(r rune) (int, error)
- func (src *String) WriteTo(w io.Writer) (n int64, err error)
- func (src *String) WriteToStringWriter(w schnittstellen.WriterAndStringWriter) (n int64, err error)
- type StringFormatReadWriter
- type StringFormatReader
Constants ¶
const RingBufferDefaultSize = 4096
Variables ¶
var StringFormatWriter stringFormatWriter
Functions ¶
func GetPool ¶
func GetPool() schnittstellen.Pool[String, *String]
func NewScannerExperimental ¶
func NewScannerExperimental(r *RingBuffer) *scannerExperimental
NewScanner returns a new scannerExperimental to read from r. The split function defaults to ScanLines.
Types ¶
type RingBuffer ¶
type RingBuffer struct {
// contains filtered or unexported fields
}
func MakeRingBuffer ¶
func MakeRingBuffer(r io.Reader, n int) *RingBuffer
func (*RingBuffer) AdvanceRead ¶
func (rb *RingBuffer) AdvanceRead(n int)
func (*RingBuffer) Cap ¶
func (rb *RingBuffer) Cap() int
func (*RingBuffer) Fill ¶
func (rb *RingBuffer) Fill() (n int64, err error)
func (*RingBuffer) Len ¶
func (rb *RingBuffer) Len() int
func (*RingBuffer) PeekReadable ¶
func (rb *RingBuffer) PeekReadable() (rs Slice)
func (*RingBuffer) PeekUnreadable ¶
func (rb *RingBuffer) PeekUnreadable() (rs Slice)
func (*RingBuffer) PeekUpto ¶
func (rb *RingBuffer) PeekUpto(b byte) (readable Slice, err error)
func (*RingBuffer) PeekUptoAndIncluding ¶
func (rb *RingBuffer) PeekUptoAndIncluding(b byte) (readable Slice, err error)
func (*RingBuffer) PeekWriteable ¶
func (rb *RingBuffer) PeekWriteable() (rs Slice)
func (*RingBuffer) Read ¶
func (rb *RingBuffer) Read(p []byte) (n int, err error)
func (*RingBuffer) ReadLength ¶
func (rb *RingBuffer) ReadLength() int64
func (*RingBuffer) Reset ¶
func (rb *RingBuffer) Reset(r io.Reader)
func (*RingBuffer) Seek ¶
func (rb *RingBuffer) Seek(offset int64, whence int) (actual int64, err error)
func (*RingBuffer) Unread ¶
func (rb *RingBuffer) Unread(toUnread int) (actuallyUnread int)
func (*RingBuffer) Write ¶
func (rb *RingBuffer) Write(p []byte) (n int, err error)
type RingBufferRuneScanner ¶
type RingBufferRuneScanner struct { SliceRuneScanner // contains filtered or unexported fields }
func MakeRingBufferRuneScanner ¶
func MakeRingBufferRuneScanner(rb *RingBuffer) (s *RingBufferRuneScanner)
func (*RingBufferRuneScanner) ReadRune ¶
func (s *RingBufferRuneScanner) ReadRune() (r rune, size int, err error)
func (*RingBufferRuneScanner) Reset ¶
func (s *RingBufferRuneScanner) Reset()
func (*RingBufferRuneScanner) ResetWith ¶
func (s *RingBufferRuneScanner) ResetWith(rb *RingBuffer)
func (*RingBufferRuneScanner) UnreadRune ¶
func (s *RingBufferRuneScanner) UnreadRune() (err error)
type RingBufferScanner ¶
type RingBufferScanner struct {
// contains filtered or unexported fields
}
func MakeRingBufferScanner ¶
func MakeRingBufferScanner(rb *RingBuffer) *RingBufferScanner
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner provides a convenient interface for reading data such as a file of newline-delimited lines of text. Successive calls to the Scan method will step through the 'tokens' of a file, skipping the bytes between the tokens. The specification of a token is defined by a split function of type SplitFunc; the default split function breaks the input into lines with line termination stripped. Split functions are defined in this package for scanning a file into lines, bytes, UTF-8-encoded runes, and space-delimited words. The client may instead provide a custom split function.
Scanning stops unrecoverably at EOF, the first I/O error, or a token too large to fit in the buffer. When a scan stops, the reader may have advanced arbitrarily far past the last token. Programs that need more control over error handling or large tokens, or must run sequential scans on a reader, should use bufio.Reader instead.
func NewScanner ¶
func NewScanner(r *RingBuffer) *Scanner
NewScanner returns a new Scanner to read from r. The split function defaults to ScanLines.
func (*Scanner) Buffer ¶
Buffer sets the initial buffer to use when scanning and the maximum size of buffer that may be allocated during scanning. The maximum token size is the larger of max and cap(buf). If max <= cap(buf), Scan will use this buffer only and do no allocation.
By default, Scan uses an internal buffer and sets the maximum token size to MaxScanTokenSize.
Buffer panics if it is called after scanning has started.
func (*Scanner) Bytes ¶
Bytes returns the most recent token generated by a call to Scan. The underlying array may point to data that will be overwritten by a subsequent call to Scan. It does no allocation.
func (*Scanner) Err ¶
Err returns the first non-EOF error that was encountered by the Scanner.
func (*Scanner) Scan ¶
Scan advances the Scanner to the next token, which will then be available through the Bytes or Text method. It returns false when the scan stops, either by reaching the end of the input or an error. After Scan returns false, the Err method will return any error that occurred during scanning, except that if it was io.EOF, Err will return nil. Scan panics if the split function returns too many empty tokens without advancing the input. This is a common error mode for scanners.
func (*Scanner) Split ¶
Split sets the split function for the Scanner. The default split function is ScanLines.
Split panics if it is called after scanning has started.
type Slice ¶
type Slice struct {
// contains filtered or unexported fields
}
func (Slice) SliceBytes ¶
func (a Slice) SliceBytes() SliceBytes
func (Slice) SliceUptoAndIncluding ¶
func (Slice) SliceUptoButExcluding ¶
type SliceReader ¶
type SliceReader struct {
// contains filtered or unexported fields
}
func MakeSliceReader ¶
func MakeSliceReader(sl Slice) *SliceReader
func (*SliceReader) Read ¶
func (sr *SliceReader) Read(p []byte) (n int, err error)
func (*SliceReader) ResetWith ¶
func (sr *SliceReader) ResetWith(sl Slice)
type SliceRuneScanner ¶
type SliceRuneScanner struct {
// contains filtered or unexported fields
}
func MakeSliceRuneScanner ¶
func MakeSliceRuneScanner(slice Slice) (s *SliceRuneScanner)
func (*SliceRuneScanner) Error ¶
func (s *SliceRuneScanner) Error() error
func (*SliceRuneScanner) Offset ¶
func (s *SliceRuneScanner) Offset() int
func (*SliceRuneScanner) ReadRune ¶
func (s *SliceRuneScanner) ReadRune() (r rune, size int, err error)
func (*SliceRuneScanner) Remaining ¶
func (s *SliceRuneScanner) Remaining() int
func (*SliceRuneScanner) Reset ¶
func (s *SliceRuneScanner) Reset()
func (*SliceRuneScanner) ResetSliceOnly ¶
func (s *SliceRuneScanner) ResetSliceOnly(slice Slice)
func (*SliceRuneScanner) ResetWith ¶
func (s *SliceRuneScanner) ResetWith(slice Slice)
func (*SliceRuneScanner) Scan ¶
func (s *SliceRuneScanner) Scan() (r rune, width int, ok bool)
func (*SliceRuneScanner) UnreadRune ¶
func (s *SliceRuneScanner) UnreadRune() (err error)
type SplitFunc ¶
SplitFunc is the signature of the split function used to tokenize the input. The arguments are an initial substring of the remaining unprocessed data and a flag, atEOF, that reports whether the Reader has no more data to give. The return values are the number of bytes to advance the input and the next token to return to the user, if any, plus an error, if any.
Scanning stops if the function returns an error, in which case some of the input may be discarded. If that error is ErrFinalToken, scanning stops with no error.
Otherwise, the Scanner advances the input. If the token is not nil, the Scanner returns it to the user. If the token is nil, the Scanner reads more data and continues scanning; if there is no more data--if atEOF was true--the Scanner returns. If the data does not yet hold a complete token, for instance if it has no newline while scanning lines, a SplitFunc can return (0, nil, nil) to signal the Scanner to read more data into the slice and try again with a longer slice starting at the same point in the input.
The function is never called with an empty data slice unless atEOF is true. If atEOF is true, however, data may be non-empty and, as always, holds unprocessed text.
type SplitFuncExperimental ¶
SplitFunc is the signature of the split function used to tokenize the input. The arguments are an initial substring of the remaining unprocessed data and a flag, atEOF, that reports whether the Reader has no more data to give. The return values are the number of bytes to advance the input and the next token to return to the user, if any, plus an error, if any.
Scanning stops if the function returns an error, in which case some of the input may be discarded. If that error is ErrFinalToken, scanning stops with no error.
Otherwise, the scannerExperimental advances the input. If the token is not nil, the scannerExperimental returns it to the user. If the token is nil, the scannerExperimental reads more data and continues scanning; if there is no more data--if atEOF was true--the scannerExperimental returns. If the data does not yet hold a complete token, for instance if it has no newline while scanning lines, a SplitFunc can return (0, nil, nil) to signal the scannerExperimental to read more data into the slice and try again with a longer slice starting at the same point in the input.
The function is never called with an empty data slice unless atEOF is true. If atEOF is true, however, data may be non-empty and, as always, holds unprocessed text.
type String ¶
type String struct {
// contains filtered or unexported fields
}
func (*String) ReadNFrom ¶
func (*String) WriteLower ¶
WriteLower writes all Unicode letters mapped to their lower case.
func (*String) WriteToStringWriter ¶
func (src *String) WriteToStringWriter( w schnittstellen.WriterAndStringWriter, ) (n int64, err error)
type StringFormatReadWriter ¶
type StringFormatReadWriter[T any] interface { StringFormatReader[T] schnittstellen.StringFormatWriter[T] }
type StringFormatReader ¶
type StringFormatReader[T any] interface { ReadStringFormat(*RingBuffer, T) (int64, error) }