You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -254,10 +254,10 @@ uint32_t value = 27; // We can choose any value below 2^5. Otherwise we need mor
254
254
writer.serialize_bits(value, 5);
255
255
256
256
// Flush the writer's remaining state into the buffer
257
-
uint32_t num_bytes = writer.flush();
257
+
uint32_t num_bits = writer.flush();
258
258
259
259
// Create a reader, referencing the buffer and bytes written
260
-
bit_reader reader(buffer, num_bytes);
260
+
bit_reader reader(buffer, num_bits);
261
261
262
262
// Read the value back
263
263
uint32_t out_value; // We don't have to initialize it yet
@@ -275,10 +275,10 @@ int32_t value = -45; // We can choose any value within the range below
275
275
writer.serialize<int32_t>(value, -90, 40); // A lower and upper bound which the value will be quantized between
276
276
277
277
// Flush the writer's remaining state into the buffer
278
-
uint32_t num_bytes = writer.flush();
278
+
uint32_t num_bits = writer.flush();
279
279
280
280
// Create a reader by moving and invalidating the writer
281
-
bit_reader reader(buffer, num_bytes);
281
+
bit_reader reader(buffer, num_bits);
282
282
283
283
// Read the value back
284
284
int32_t out_value; // We don't have to initialize it yet
@@ -296,10 +296,10 @@ const char* value = "Hello world!";
296
296
writer.serialize<const char*>(value, 32U); // The second argument is the maximum size we expect the string to be
297
297
298
298
// Flush the writer's remaining state into the buffer
299
-
uint32_t num_bytes = writer.flush();
299
+
uint32_t num_bits = writer.flush();
300
300
301
301
// Create a reader by moving and invalidating the writer
302
-
bit_reader reader(buffer, num_bytes);
302
+
bit_reader reader(buffer, num_bits);
303
303
304
304
// Read the value back
305
305
char out_value[32]; // Set the size to the max size
@@ -317,10 +317,10 @@ std::string value = "Hello world!";
317
317
writer.serialize<std::string>(value, 32U); // The second argument is the maximum size we expect the string to be
318
318
319
319
// Flush the writer's remaining state into the buffer
320
-
uint32_t num_bytes = writer.flush();
320
+
uint32_t num_bits = writer.flush();
321
321
322
322
// Create a reader by moving and invalidating the writer
323
-
bit_reader reader(buffer, num_bytes);
323
+
bit_reader reader(buffer, num_bits);
324
324
325
325
// Read the value back
326
326
std::string out_value; // The string will be resized if the output doesn't fit
@@ -339,10 +339,10 @@ float value = 1.2345678f;
339
339
writer.serialize<bounded_range>(range, value);
340
340
341
341
// Flush the writer's remaining state into the buffer
342
-
uint32_t num_bytes = writer.flush();
342
+
uint32_t num_bits = writer.flush();
343
343
344
344
// Create a reader by moving and invalidating the writer
345
-
bit_reader reader(buffer, num_bytes);
345
+
bit_reader reader(buffer, num_bits);
346
346
347
347
// Read the value back
348
348
float out_value;
@@ -354,7 +354,7 @@ These examples can also be seen in [`src/test/examples_test.cpp`](https://github
354
354
# Extensibility
355
355
The library is made with extensibility in mind.
356
356
The `bit_writer` and `bit_reader` use a template trait specialization of the given type to deduce how to serialize and deserialize the object.
357
-
The only requirements of the trait is that it has (or can deduce) 2 static functions which take a bit_writer& and a bit_reader& respectively as their first argument.
357
+
The only requirements of the trait is that it has (or can deduce) 2 static functions which take a `bit_writer&` and a `bit_reader&` respectively as their first argument.
358
358
The 2 functions must also return a bool indicating whether the serialization was a success or not, but can otherwise take any number of additional arguments.
0 commit comments