Skip to content

Commit d44db6d

Browse files
committed
added parsing of reMarkable lines test, format version 5
1 parent a68696d commit d44db6d

2 files changed

Lines changed: 101 additions & 0 deletions

File tree

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
package com.igormaznitsa.jbbp.it;
2+
3+
import static com.igormaznitsa.jbbp.io.JBBPByteOrder.LITTLE_ENDIAN;
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
6+
7+
import com.igormaznitsa.jbbp.JBBPParser;
8+
import com.igormaznitsa.jbbp.io.JBBPBitInputStream;
9+
import com.igormaznitsa.jbbp.io.JBBPOut;
10+
import com.igormaznitsa.jbbp.mapper.Bin;
11+
import com.igormaznitsa.jbbp.mapper.BinType;
12+
import org.junit.jupiter.api.Test;
13+
14+
public class RemarkableLinesParsingTest extends AbstractParserIntegrationTest {
15+
16+
private static final String REMARKABLE_V5_LINES = "byte [43] header;" +
17+
"<int nlayers;" +
18+
"layers [nlayers] {" +
19+
" <int nstrokes;" +
20+
" strokes [nstrokes] {" +
21+
" <int pen;" +
22+
" <int color;" +
23+
" <int unknown1;" +
24+
" <floatj width;" +
25+
" <int unknown2;" +
26+
" <int nsegments;" +
27+
" segments [nsegments] {" +
28+
" <floatj x;" +
29+
" <floatj y;" +
30+
" <floatj pressure;" +
31+
" <floatj tilt;" +
32+
" <floatj unknown1;" +
33+
" <floatj unknown2;" +
34+
" }" +
35+
" } " +
36+
"}";
37+
private static final JBBPParser PARSER = JBBPParser.prepare(REMARKABLE_V5_LINES);
38+
39+
@Test
40+
public void testV5_Remarkable1() throws Exception {
41+
final RemarkableV5Body parsed;
42+
try (JBBPBitInputStream inputStream = new JBBPBitInputStream(
43+
getResourceAsInputStream("remarkable1.rm"))) {
44+
parsed =
45+
PARSER.parse(getResourceAsInputStream("remarkable1.rm")).mapTo(new RemarkableV5Body());
46+
}
47+
48+
assertEquals("reMarkable .lines file, version=5", parsed.header.trim());
49+
final byte[] written = JBBPOut.BeginBin().Bin(parsed).End().toByteArray();
50+
assertResource("remarkable1.rm", written);
51+
}
52+
53+
public static class RemarkableV5Body {
54+
@Bin(order = 1, arraySizeExpr = "43", type = BinType.BYTE_ARRAY)
55+
public String header;
56+
@Bin(order = 2, byteOrder = LITTLE_ENDIAN)
57+
public int nlayers;
58+
@Bin(order = 3, arraySizeExpr = "nlayers")
59+
public Layer[] layers;
60+
61+
public static class Layer {
62+
@Bin(order = 1, byteOrder = LITTLE_ENDIAN)
63+
public int nstrokes;
64+
@Bin(order = 2, arraySizeExpr = "nstrokes")
65+
public Stroke[] strokes;
66+
67+
public static class Stroke {
68+
@Bin(order = 1, byteOrder = LITTLE_ENDIAN)
69+
public int pen;
70+
@Bin(order = 2, byteOrder = LITTLE_ENDIAN)
71+
public int color;
72+
@Bin(order = 3, byteOrder = LITTLE_ENDIAN)
73+
public int unknown1;
74+
@Bin(order = 4, byteOrder = LITTLE_ENDIAN)
75+
public float width;
76+
@Bin(order = 5, byteOrder = LITTLE_ENDIAN)
77+
public int unknown2;
78+
@Bin(order = 6, byteOrder = LITTLE_ENDIAN)
79+
public int nsegments;
80+
@Bin(order = 7, arraySizeExpr = "nsegments")
81+
public Segment[] segments;
82+
83+
public static class Segment {
84+
@Bin(order = 1, byteOrder = LITTLE_ENDIAN)
85+
public float x;
86+
@Bin(order = 2, byteOrder = LITTLE_ENDIAN)
87+
public float y;
88+
@Bin(order = 3, byteOrder = LITTLE_ENDIAN)
89+
public float pressure;
90+
@Bin(order = 4, byteOrder = LITTLE_ENDIAN)
91+
public float tilt;
92+
@Bin(order = 5, byteOrder = LITTLE_ENDIAN)
93+
public float unknown1;
94+
@Bin(order = 6, byteOrder = LITTLE_ENDIAN)
95+
public float unknown2;
96+
}
97+
}
98+
}
99+
}
100+
101+
}
19.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)