diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2022-11-11 08:59:19 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2022-11-11 08:59:19 +0300 |
| commit | f628b40dc66467db2e299f115ea9bac75a297900 (patch) | |
| tree | 030e558ad9949abff876021f6110fc6262aad427 /README.md | |
| parent | added wrapper funcs for read bits/bytes (diff) | |
| download | bitreader-f628b40dc66467db2e299f115ea9bac75a297900.tar.gz bitreader-f628b40dc66467db2e299f115ea9bac75a297900.tar.bz2 bitreader-f628b40dc66467db2e299f115ea9bac75a297900.zip | |
add ReadBitsToSlice() functionv1.2.4
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 16 |
1 files changed, 11 insertions, 5 deletions
| @@ -28,16 +28,22 @@ err := reader.SkipBits(8) | |||
| 28 | err := reader.SkipBytes(4) | 28 | err := reader.SkipBytes(4) |
| 29 | 29 | ||
| 30 | // Read Bits/Bytes | 30 | // Read Bits/Bytes |
| 31 | value, err := reader.ReadBytes(4) | 31 | value, err := reader.ReadBytes(4) // up to 8 bytes |
| 32 | value, err := reader.ReadBits(64) // up to 64 bits | 32 | value, err := reader.ReadBits(64) // up to 64 bits |
| 33 | 33 | ||
| 34 | // Read String | 34 | // Read String |
| 35 | text, err := reader.ReadString() // null-terminated | 35 | text, err := reader.ReadString() // null-terminated |
| 36 | text, err := reader.ReadStringLen(256) // length-specified | 36 | text, err := reader.ReadStringLen(256) // length-specified |
| 37 | |||
| 38 | // Read Bits/Bytes into Slice | ||
| 39 | arr, err := reader.ReadBitsToSlice(128) | ||
| 40 | arr, err := reader.ReadBytesToSlice(64) | ||
| 37 | 41 | ||
| 38 | // Wrapper functions | 42 | // Wrapper functions |
| 39 | text := reader.TryReadString() // string | 43 | text := reader.TryReadString() // string |
| 40 | text := reader.TryReadStringLen(64) // string | 44 | text := reader.TryReadStringLen(64) // string |
| 45 | arr := reader.ReadBitsToSlice(128) // []byte | ||
| 46 | arr := reader.ReadBytesToSlice(64) // []byte | ||
| 41 | state := reader.TryReadBool() // bool | 47 | state := reader.TryReadBool() // bool |
| 42 | value := reader.TryReadInt1() // uint8 | 48 | value := reader.TryReadInt1() // uint8 |
| 43 | value := reader.TryReadInt8() // uint8 | 49 | value := reader.TryReadInt8() // uint8 |
| @@ -51,7 +57,7 @@ value := reader.TryReadBytes(8) // uint64 | |||
| 51 | ``` | 57 | ``` |
| 52 | 58 | ||
| 53 | ## Error Handling | 59 | ## Error Handling |
| 54 | ReadBits(x), ReadBytes(x), ReadBool(), ReadString(), ReadStringLen(x) SkipBits(x) and SkipBytes(x) functions returns an error message when they don't work as expected. It is advised to always handle errors. \ | 60 | ReadBits(x), ReadBytes(x), ReadBool(), ReadString(), ReadStringLen(x), ReadBitsToSlice(x), ReadBytesToSlice(x), SkipBits(x) and SkipBytes(x) functions returns an error message when they don't work as expected. It is advised to always handle errors. \ |
| 55 | Wrapper functions, however, only returns the value and panics if an error is encountered. | 61 | Wrapper functions, however, only returns the value and panics if an error is encountered. |
| 56 | 62 | ||
| 57 | ## Bug Report / Feature Request | 63 | ## Bug Report / Feature Request |