parse

package
v0.0.0-...-aa75ebd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotEnoughStrings = errors.New("not enough strings provided")
View Source
var PlaceholderDoesNotMatch = errors.New("string does not match placeholder match or regex tag")
View Source
var TooManyStrings = errors.New("too many strings provided")
View Source
var UnknownValueError = errors.New("unknown value")

Functions

func Bool

func Bool(s string) (bool, error)

func ByteGrid

func ByteGrid(s string) *structures.FlatGrid[byte]

ByteGrid converts a 2D grid represented as a string into a structures.FlatGrid. Each row should be represented by a line, and each item within that line should be represented by a single byte. This is useful for e.g. maze tasks where coordinates always stay inside the input grid

func Characters

func Characters(s string) []string

Characters splits a string on each character, optimized for ASCII strings

func Chunks

func Chunks(s string) (chunks []string)

Chunks splits a string into "chunks" split by blank lines. Additionally, CLRF is converted to LF

func ExtractDigits

func ExtractDigits(s string) []int

func ExtractFloat32s

func ExtractFloat32s(s string) []float32

func ExtractFloat64s

func ExtractFloat64s(s string) []float64

func ExtractInt64s

func ExtractInt64s(s string) []int64

func ExtractInts

func ExtractInts(s string) []int

func ExtractUint64s

func ExtractUint64s(s string) []uint64

func ExtractUints

func ExtractUints(s string) []uint

func Float32

func Float32(s string) float32

func Float32s

func Float32s(s []string) []float32

func Float64

func Float64(s string) float64

func Float64s

func Float64s(s []string) []float64

func Grid

func Grid[T any](row Splitter, items func(string) []T, s string) [][]T

func Int

func Int(s string) int

func Int16

func Int16(s string) int16

func Int16s

func Int16s(s []string) []int16

func Int32

func Int32(s string) int32

func Int32s

func Int32s(s []string) []int32

func Int64

func Int64(s string) int64

func Int64s

func Int64s(s []string) []int64

func Int8

func Int8(s string) int8

func Int8s

func Int8s(s []string) []int8

func IntStrings

func IntStrings(s string) []string

func Ints

func Ints(s []string) []int

func Lines

func Lines(s string) []string

Lines splits a string based on newlines, removing the last line if empty

func MustReflect

func MustReflect[T any](s []string) T

func Reflect

func Reflect[T any](s []string) (T, error)

func ReflectGrid

func ReflectGrid[T any](row, col Splitter, s string) [][]T

func Uint

func Uint(s string) uint

func Uint16

func Uint16(s string) uint16

func Uint16s

func Uint16s(s []string) []uint16

func Uint32

func Uint32(s string) uint32

func Uint32s

func Uint32s(s []string) []uint32

func Uint64

func Uint64(s string) uint64

func Uint64s

func Uint64s(s []string) []uint64

func Uint8

func Uint8(s string) uint8

func Uint8s

func Uint8s(s []string) []uint8

func UintStrings

func UintStrings(s string) []string

func Uints

func Uints(s []string) []uint

func Whitespace

func Whitespace(s string) []string

Whitespace splits a string on whitespace

Types

type Placeholder

type Placeholder struct{}

type Splitter

type Splitter func(string) []string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL