package byteutil

import (
	
	
)

// Buffer wrap and extends the bytes.Buffer, add some useful methods
// and implements the io.Writer, io.Closer and stdio.Flusher interfaces
type Buffer struct {
	bytes.Buffer
	// custom error for testing
	CloseErr error
	FlushErr error
	SyncErr  error
}

// NewBuffer instance
func () *Buffer { return &Buffer{} }

// PrintByte to buffer, ignore error. alias of WriteByte()
func ( *Buffer) ( byte) {
	_ = .WriteByte()
}

// WriteStr1 quiet write one string to buffer
func ( *Buffer) ( string) { .writeStringNl(, false) }

// WriteStr1Nl quiet write one string and end with newline
func ( *Buffer) ( string) { .writeStringNl(, true) }

// writeStringNl quiet write one string and end with newline
func ( *Buffer) ( string,  bool) {
	_, _ = .Buffer.WriteString()
	if  {
		_ = .WriteByte('\n')
	}
}

// WriteStr quiet write strings to buffer
func ( *Buffer) ( ...string) {
	.writeStringsNl(, false)
}

// WriteStrings to buffer, ignore error.
func ( *Buffer) ( []string) {
	.writeStringsNl(, false)
}

// WriteStringNl write message to buffer and end with newline
func ( *Buffer) ( ...string) {
	.writeStringsNl(, true)
}

// writeStringsNl to buffer, ignore error.
func ( *Buffer) ( []string,  bool) {
	for ,  := range  {
		_, _ = .Buffer.WriteString()
	}
	if  {
		_ = .WriteByte('\n')
	}
}

// WriteAny type value to buffer
func ( *Buffer) ( ...any) {
	.writeAnysWithNl(, false)
}

// Writeln write values to buffer and end with newline
func ( *Buffer) ( ...any) {
	.writeAnysWithNl(, true)
}

// WriteAnyNl type value to buffer and end with newline
func ( *Buffer) ( ...any) {
	.writeAnysWithNl(, true)
}

// WriteAnyLn type value to buffer and end with newline
func ( *Buffer) ( []any,  bool) {
	for ,  := range  {
		_, _ = .Buffer.WriteString(fmt.Sprint())
	}
	if  {
		_ = .WriteByte('\n')
	}
}

// Writef write message to buffer, ignore error. alias of Printf()
func ( *Buffer) ( string,  ...any) { _, _ = fmt.Fprintf(, , ...) }

// Printf quick write message to buffer, ignore error.
func ( *Buffer) ( string,  ...any) { _, _ = fmt.Fprintf(, , ...) }

// Println quick write message with newline to buffer, will ignore error.
func ( *Buffer) ( ...any) { _, _ = fmt.Fprintln(, ...) }

// ResetGet buffer string. alias of ResetAndGet()
func ( *Buffer) () string {
	return .ResetAndGet()
}

// ResetAndGet buffer string.
func ( *Buffer) () string {
	 := .String()
	.Reset()
	return 
}

// Close buffer
func ( *Buffer) () error { return .CloseErr }

// Flush buffer
func ( *Buffer) () error { return .FlushErr }

// Sync anf flush buffer
func ( *Buffer) () error { return .SyncErr }