Skip to content

Commit 49bfd77

Browse files
committed
2 parents 75d973d + 2f14223 commit 49bfd77

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,19 @@ also the precompiled jar, javadoc and sources can be downloaded manually from [t
5252

5353
Hello world
5454
============
55-
The Framework is very easy in use because it has only two main classes for its functionality com.igormaznitsa.jbbp.JBBPParser (for data parsing) and com.igormaznitsa.jbbp.io.JBBPOut (for binary block writing), both of them work over low-level IO classes com.igormaznitsa.jbbp.io.JBBPBitInputStream and com.igormaznitsa.jbbp.io.JBBPBitOutputStream which are the core for the framework.
55+
The Framework is very easy in use because it has only two main classes for its functionality com.igormaznitsa.jbbp.JBBPParser (for data parsing) and com.igormaznitsa.jbbp.io.JBBPOut (for binary block writing), both of them work over low-level IO classes com.igormaznitsa.jbbp.io.JBBPBitInputStream and com.igormaznitsa.jbbp.io.JBBPBitOutputStream which are the core for the framework.
56+
57+
The Easiest case below shows how to parse byte array to bits.
58+
```Java
59+
byte [] parsedBits = JBBPParser.prepare("bit:1 [_];").parse(new byte[]{1,2,3,4,5}).
60+
findFieldForType(JBBPFieldArrayBit.class).getArray();
61+
```
62+
Of course sometime it is not a comfortable way to look for parsed fields in the result, so you can use mapping of parsed data to class fields.
5663
```Java
57-
class Mapped { @Bin(type = BinType.BYTE_ARRAY) String text;}
58-
Mapped mapped = JBBPParser.prepare("byte [_] text;").parse(JBBPOut.BeginBin().Byte("Hello World").End().toByteArray()).mapTo(Mapped.class);
59-
assertEquals("Hello World",mapped.text);
64+
class Parsed {@Bin(type = BinType.BIT_ARRAY)byte[] parsed;}
65+
Parsed parsedBits = JBBPParser.prepare("bit:1 [_] parsed;").parse(new byte[]{1,2,3,4,5}).mapTo(Parsed.class);
6066
```
67+
6168
More compex example with features added as of 1.1.0
6269
====================================================
6370
The Example shows how to parse a byte written in non-standard MSB0 order (Java has LSB0 bit order) to bit fields, print its values and pack fields back
@@ -285,3 +292,7 @@ final byte [] array =
285292
Long(0x123456789ABCDEF1L, 0x212356239091AB32L).
286293
End().toByteArray();
287294
```
295+
Donation
296+
=========
297+
If you like the software you can make some donation to the author
298+
[![https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AHWJHJFBAWGL2)

0 commit comments

Comments
 (0)