Documentation ¶
Index ¶
- Variables
- func AppendFloat(dst EncodingBuffer, val float64, fmt byte, prec, bitSize int)
- func AsciiEqualFold(s, t []byte) bool
- func EqualFoldRight(s, t []byte) bool
- func FormatBits(scratch *FormatBitsScratch, dst FormatBitsWriter, u uint64, base int, neg bool)
- func FormatBits2(dst FormatBitsWriter, u uint64, base int, neg bool)
- func ParseFloat(s []byte, bitSize int) (f float64, err error)
- func ParseInt(s []byte, base int, bitSize int) (i int64, err error)
- func ParseUint(s []byte, base int, bitSize int) (n uint64, err error)
- func Pool(b []byte)
- func SimpleLetterEqualFold(s, t []byte) bool
- func UnquoteBytes(s []byte) (t []byte, ok bool)
- func WriteJson(buf JsonStringWriter, s []byte)
- func WriteJsonString(buf JsonStringWriter, s string)
- type Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Encode(v interface{}) error
- func (b *Buffer) Grow(n int)
- func (b *Buffer) Len() int
- func (b *Buffer) Next(n int) []byte
- func (b *Buffer) Read(p []byte) (n int, err error)
- func (b *Buffer) ReadByte() (c byte, err error)
- func (b *Buffer) ReadBytes(delim byte) (line []byte, err error)
- func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error)
- func (b *Buffer) ReadRune() (r rune, size int, err error)
- func (b *Buffer) ReadString(delim byte) (line string, err error)
- func (b *Buffer) Reset()
- func (b *Buffer) Rewind(n int) error
- func (b *Buffer) String() string
- func (b *Buffer) Truncate(n int)
- func (b *Buffer) Write(p []byte) (n int, err error)
- func (b *Buffer) WriteByte(c byte) error
- func (b *Buffer) WriteRune(r rune) (n int, err error)
- func (b *Buffer) WriteString(s string) (n int, err error)
- func (b *Buffer) WriteTo(w io.Writer) (n int64, err error)
- type DecodingBuffer
- type EncodingBuffer
- type FFErr
- type FFLexer
- type FFParseState
- type FFTok
- type FormatBitsScratch
- type FormatBitsWriter
- type JsonStringWriter
- type LexerError
Constants ¶
This section is empty.
Variables ¶
var ErrTooLarge = errors.New("fflib.v1.Buffer: too large")
ErrTooLarge is passed to panic if memory cannot be allocated to store data in a buffer.
Functions ¶
func AppendFloat ¶
func AppendFloat(dst EncodingBuffer, val float64, fmt byte, prec, bitSize int)
AppendFloat appends the string form of the floating-point number f, as generated by FormatFloat
func AsciiEqualFold ¶
asciiEqualFold is a specialization of bytes.EqualFold for use when s is all ASCII (but may contain non-letters) and contains no special-folding letters. See comments on foldFunc.
func EqualFoldRight ¶
equalFoldRight is a specialization of bytes.EqualFold when s is known to be all ASCII (including punctuation), but contains an 's', 'S', 'k', or 'K', requiring a Unicode fold on the bytes in t. See comments on foldFunc.
func FormatBits ¶
func FormatBits(scratch *FormatBitsScratch, dst FormatBitsWriter, u uint64, base int, neg bool)
DEPRECIATED: `scratch` is no longer used, FormatBits2 is available.
FormatBits computes the string representation of u in the given base. If neg is set, u is treated as negative int64 value. If append_ is set, the string is appended to dst and the resulting byte slice is returned as the first result value; otherwise the string is returned as the second result value.
func FormatBits2 ¶
func FormatBits2(dst FormatBitsWriter, u uint64, base int, neg bool)
FormatBits2 computes the string representation of u in the given base. If neg is set, u is treated as negative int64 value. If append_ is set, the string is appended to dst and the resulting byte slice is returned as the first result value; otherwise the string is returned as the second result value.
func Pool ¶
func Pool(b []byte)
Send a buffer to the Pool to reuse for other instances. You may no longer utilize the content of the buffer, since it may be used by other goroutines.
func SimpleLetterEqualFold ¶
simpleLetterEqualFold is a specialization of bytes.EqualFold for use when s is all ASCII letters (no underscores, etc) and also doesn't contain 'k', 'K', 's', or 'S'. See comments on foldFunc.
func UnquoteBytes ¶
UnquoteBytes will decode []byte containing json string to go string ported from encoding/json/decode.go
func WriteJson ¶
func WriteJson(buf JsonStringWriter, s []byte)
*
- Function ported from encoding/json: func (e *encodeState) string(s string) (int, error)
func WriteJsonString ¶
func WriteJsonString(buf JsonStringWriter, s string)
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
A Buffer is a variable-sized buffer of bytes with Read and Write methods. The zero value for Buffer is an empty buffer ready to use.
func NewBuffer ¶
NewBuffer creates and initializes a new Buffer using buf as its initial contents. It is intended to prepare a Buffer to read existing data. It can also be used to size the internal buffer for writing. To do that, buf should have the desired capacity but a length of zero.
In most cases, new(Buffer) (or just declaring a Buffer variable) is sufficient to initialize a Buffer.
func NewBufferString ¶
NewBufferString creates and initializes a new Buffer using string s as its initial contents. It is intended to prepare a buffer to read an existing string.
In most cases, new(Buffer) (or just declaring a Buffer variable) is sufficient to initialize a Buffer.
func (*Buffer) Bytes ¶
Bytes returns a slice of the contents of the unread portion of the buffer; len(b.Bytes()) == b.Len(). If the caller changes the contents of the returned slice, the contents of the buffer will change provided there are no intervening method calls on the Buffer.
func (*Buffer) Grow ¶
Grow grows the buffer's capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to the buffer without another allocation. If n is negative, Grow will panic. If the buffer can't grow it will panic with ErrTooLarge.
func (*Buffer) Len ¶
Len returns the number of bytes of the unread portion of the buffer; b.Len() == len(b.Bytes()).
func (*Buffer) Next ¶
Next returns a slice containing the next n bytes from the buffer, advancing the buffer as if the bytes had been returned by Read. If there are fewer than n bytes in the buffer, Next returns the entire buffer. The slice is only valid until the next call to a read or write method.
func (*Buffer) Read ¶
Read reads the next len(p) bytes from the buffer or until the buffer is drained. The return value n is the number of bytes read. If the buffer has no data to return, err is io.EOF (unless len(p) is zero); otherwise it is nil.
func (*Buffer) ReadByte ¶
ReadByte reads and returns the next byte from the buffer. If no byte is available, it returns error io.EOF.
func (*Buffer) ReadBytes ¶
ReadBytes reads until the first occurrence of delim in the input, returning a slice containing the data up to and including the delimiter. If ReadBytes encounters an error before finding a delimiter, it returns the data read before the error and the error itself (often io.EOF). ReadBytes returns err != nil if and only if the returned data does not end in delim.
func (*Buffer) ReadFrom ¶
ReadFrom reads data from r until EOF and appends it to the buffer, growing the buffer as needed. The return value n is the number of bytes read. Any error except io.EOF encountered during the read is also returned. If the buffer becomes too large, ReadFrom will panic with ErrTooLarge.
func (*Buffer) ReadRune ¶
ReadRune reads and returns the next UTF-8-encoded Unicode code point from the buffer. If no bytes are available, the error returned is io.EOF. If the bytes are an erroneous UTF-8 encoding, it consumes one byte and returns U+FFFD, 1.
func (*Buffer) ReadString ¶
ReadString reads until the first occurrence of delim in the input, returning a string containing the data up to and including the delimiter. If ReadString encounters an error before finding a delimiter, it returns the data read before the error and the error itself (often io.EOF). ReadString returns err != nil if and only if the returned data does not end in delim.
func (*Buffer) Reset ¶
func (b *Buffer) Reset()
Reset resets the buffer so it has no content. b.Reset() is the same as b.Truncate(0).
func (*Buffer) String ¶
String returns the contents of the unread portion of the buffer as a string. If the Buffer is a nil pointer, it returns "<nil>".
func (*Buffer) Truncate ¶
Truncate discards all but the first n unread bytes from the buffer. It panics if n is negative or greater than the length of the buffer.
func (*Buffer) Write ¶
Write appends the contents of p to the buffer, growing the buffer as needed. The return value n is the length of p; err is always nil. If the buffer becomes too large, Write will panic with ErrTooLarge.
func (*Buffer) WriteByte ¶
WriteByte appends the byte c to the buffer, growing the buffer as needed. The returned error is always nil, but is included to match bufio.Writer's WriteByte. If the buffer becomes too large, WriteByte will panic with ErrTooLarge.
func (*Buffer) WriteRune ¶
WriteRune appends the UTF-8 encoding of Unicode code point r to the buffer, returning its length and an error, which is always nil but is included to match bufio.Writer's WriteRune. The buffer is grown as needed; if it becomes too large, WriteRune will panic with ErrTooLarge.
func (*Buffer) WriteString ¶
WriteString appends the contents of s to the buffer, growing the buffer as needed. The return value n is the length of s; err is always nil. If the buffer becomes too large, WriteString will panic with ErrTooLarge.
type DecodingBuffer ¶
type DecodingBuffer interface { io.ReadWriter io.ByteWriter // contains filtered or unexported methods }
type EncodingBuffer ¶
type FFErr ¶
type FFErr int
const ( FFErr_e_ok FFErr = iota FFErr_io FFErr = iota FFErr_string_invalid_utf8 FFErr = iota FFErr_string_invalid_escaped_char FFErr = iota FFErr_string_invalid_json_char FFErr = iota FFErr_string_invalid_hex_char FFErr = iota FFErr_invalid_char FFErr = iota FFErr_invalid_string FFErr = iota FFErr_missing_integer_after_decimal FFErr = iota FFErr_missing_integer_after_exponent FFErr = iota FFErr_missing_integer_after_minus FFErr = iota FFErr_unallowed_comment FFErr = iota FFErr_incomplete_comment FFErr = iota FFErr_unexpected_token_type FFErr = iota // TODO: improve this error )
type FFLexer ¶
type FFLexer struct { Output DecodingBuffer Token FFTok Error FFErr BigError error // contains filtered or unexported fields }
func NewFFLexer ¶
func (*FFLexer) CaptureField ¶
Captures an entire field value, including recursive objects, and converts them to a []byte suitable to pass to a sub-object's UnmarshalJSON
type FFParseState ¶
type FFParseState int
const ( FFParse_map_start FFParseState = iota FFParse_want_key FFParse_want_colon FFParse_want_value FFParse_after_value )
func (FFParseState) String ¶
func (state FFParseState) String() string
type FFTok ¶
type FFTok int
const ( FFTok_init FFTok = iota FFTok_bool FFTok = iota FFTok_colon FFTok = iota FFTok_comma FFTok = iota FFTok_eof FFTok = iota FFTok_error FFTok = iota FFTok_left_brace FFTok = iota FFTok_left_bracket FFTok = iota FFTok_null FFTok = iota FFTok_right_brace FFTok = iota FFTok_right_bracket FFTok = iota /* we differentiate between integers and doubles to allow the * parser to interpret the number without re-scanning */ FFTok_integer FFTok = iota FFTok_double FFTok = iota FFTok_string FFTok = iota /* comment tokens are not currently returned to the parser, ever */ FFTok_comment FFTok = iota )
type FormatBitsScratch ¶
type FormatBitsScratch struct{}
type FormatBitsWriter ¶
type FormatBitsWriter interface { io.Writer io.ByteWriter }
type JsonStringWriter ¶
type JsonStringWriter interface { io.Writer io.ByteWriter // contains filtered or unexported methods }
type LexerError ¶
type LexerError struct {
// contains filtered or unexported fields
}
func (*LexerError) Error ¶
func (le *LexerError) Error() string