Skip to content

Commit fae67d9

Browse files
committed
added Readme + LICENSE
1 parent 22962c2 commit fae67d9

File tree

2 files changed

+115
-1
lines changed

2 files changed

+115
-1
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 https://github.com/pro100andrey
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,94 @@
1-
# pro_binary
1+
# pro_binary - Binary Read/Write Library
2+
3+
This library provides efficient binary reading and writing capabilities in Dart. It supports various data types and endianness, making it ideal for low-level data manipulation and network protocols.
4+
5+
## Features
6+
7+
- Read and write operations for various data types (e.g., int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64).
8+
- Support for both big-endian and little-endian formats.
9+
- Efficient memory management with dynamic buffer resizing.
10+
11+
## Installation
12+
13+
Add this to your package's `pubspec.yaml` file:
14+
``` yaml
15+
dependencies:
16+
pro_binary: ^1.0.0
17+
```
18+
19+
Then, run `pub get` to install the package.
20+
21+
## Usage
22+
23+
### Writing Binary Data
24+
25+
``` dart
26+
import 'package:binary_rw/binary_writer.dart';
27+
28+
void main() {
29+
final writer = BinaryWriter()
30+
..writeUint8(42)
31+
..writeInt8(-42)
32+
..writeUint16(65535, Endian.little)
33+
..writeInt16(-32768, Endian.little)
34+
..writeUint32(4294967295, Endian.little)
35+
..writeInt32(-2147483648, Endian.little)
36+
..writeUint64(9223372036854775807, Endian.little)
37+
..writeInt64(-9223372036854775808, Endian.little)
38+
..writeFloat32(3.14, Endian.little)
39+
..writeFloat64(3.141592653589793, Endian.little)
40+
..writeBytes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 200, 255]);
41+
42+
final bytes = writer.takeBytes();
43+
print(bytes);
44+
}
45+
```
46+
47+
### Reading Binary Data
48+
49+
``` dart
50+
import 'package:binary_rw/binary_reader.dart';
51+
52+
void main() {
53+
final buffer = Uint8List.fromList([
54+
42, 214, 255, 255, 0, 128, 255, 255, 255, 255, 0, 0, 0, 128,
55+
255, 255, 255, 255, 255, 255, 255, 127, 0, 0, 0, 0, 0, 0, 0, 128,
56+
195, 245, 72, 64, 24, 45, 68, 84, 251, 33, 9, 64,
57+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 200, 255
58+
]);
59+
60+
final reader = BinaryReader(buffer);
61+
62+
final uint8 = reader.readUint8();
63+
final int8 = reader.readInt8();
64+
final uint16 = reader.readUint16(Endian.little);
65+
final int16 = reader.readInt16(Endian.little);
66+
final uint32 = reader.readUint32(Endian.little);
67+
final int32 = reader.readInt32(Endian.little);
68+
final uint64 = reader.readUint64(Endian.little);
69+
final int64 = reader.readInt64(Endian.little);
70+
final float32 = reader.readFloat32(Endian.little);
71+
final float64 = reader.readFloat64(Endian.little);
72+
final bytes = reader.readBytes(13);
73+
74+
print([uint8, int8, uint16, int16, uint32, int32, uint64, int64, float32, float64, bytes]);
75+
}
76+
```
77+
78+
## Running Tests
79+
80+
To run the tests, use the following command:
81+
82+
``` bash
83+
dart test
84+
```
85+
86+
This will execute all tests in the `test` directory and provide a summary of the results.
87+
88+
## Contributing
89+
90+
Feel free to open issues or submit pull requests on GitHub. Contributions are always welcome!
91+
92+
## License
93+
94+
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.

0 commit comments

Comments
 (0)