diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 13 |
1 files changed, 9 insertions, 4 deletions
| @@ -1,9 +1,10 @@ | |||
| 1 | # BitReader [](https://goreportcard.com/report/github.com/pektezol/bitreader) [](https://github.com/pektezol/bitreader/blob/main/LICENSE) [](https://pkg.go.dev/github.com/pektezol/bitreader) | 1 | # BitReader [](https://goreportcard.com/report/github.com/pektezol/bitreader) [](https://github.com/pektezol/bitreader/blob/main/LICENSE) [](https://pkg.go.dev/github.com/pektezol/bitreader) |
| 2 | A simple bit reader with big/little-endian support for golang.\ | 2 | A simple bit reader with big/little-endian support for golang.\ |
| 3 | Reads data from an existing byte array.\ | 3 | Reads stream data from an io.Reader; can read from os.File and a byte array with bytes.NewReader(array).\ |
| 4 | Uses string manipulation (for now).\ | 4 | Uses bitwise operations.\ |
| 5 | Support reading up to 64 bits at one time.\ | 5 | Support reading up to 64 bits at one time.\ |
| 6 | Checking for overflowing the data. | 6 | Includes wrapper functions for most used data types.\ |
| 7 | Error checking on all but wrapper functions.\ | ||
| 7 | 8 | ||
| 8 | ## Installation | 9 | ## Installation |
| 9 | ```bash | 10 | ```bash |
| @@ -30,7 +31,11 @@ err := reader.SkipBytes(4) | |||
| 30 | value, err := reader.ReadBytes(4) | 31 | value, err := reader.ReadBytes(4) |
| 31 | value, err := reader.ReadBits(64) // up to 64 bits | 32 | value, err := reader.ReadBits(64) // up to 64 bits |
| 32 | 33 | ||
| 34 | // Read String | ||
| 35 | value, err := reader.ReadString() // null-terminated | ||
| 36 | |||
| 33 | // Wrapper functions | 37 | // Wrapper functions |
| 38 | text := reader.ReadString() // string | ||
| 34 | state := reader.TryReadBool() // bool | 39 | state := reader.TryReadBool() // bool |
| 35 | value := reader.TryReadInt1() // uint8 | 40 | value := reader.TryReadInt1() // uint8 |
| 36 | value := reader.TryReadInt8() // uint8 | 41 | value := reader.TryReadInt8() // uint8 |
| @@ -42,7 +47,7 @@ value := reader.TryReadFloat64() // float64 | |||
| 42 | ``` | 47 | ``` |
| 43 | 48 | ||
| 44 | ## Error Handling | 49 | ## Error Handling |
| 45 | ReadBits(x), ReadBytes(x), ReadBool(), SkipBits(x) and SkipBytes(x) functions returns an error message when they don't work as expected. It is advised to always handle errors. \ | 50 | ReadBits(x), ReadBytes(x), ReadBool(), ReadString(), SkipBits(x) and SkipBytes(x) functions returns an error message when they don't work as expected. It is advised to always handle errors. \ |
| 46 | Wrapper functions, however, only returns the value and panics if an error is encountered. | 51 | Wrapper functions, however, only returns the value and panics if an error is encountered. |
| 47 | 52 | ||
| 48 | ## Bug Report / Feature Request | 53 | ## Bug Report / Feature Request |