-
Notifications
You must be signed in to change notification settings - Fork 5
Reader and Writer
Marc edited this page Jun 29, 2016
·
5 revisions
This two classes are helper classes, meaning that they where created to be used internally. Does that mean that you can't use them in your program? No, of course you can!
The Reader class allows you to deserialize C++ data types, so if you want to deserialize an int
from a pointer, you can just do:
int result = Cereal::Reader::readBytes<int>(pointer, offset);
The Writer class allow you to serialize C++ data types, so if you want to write a float
to an address, you can call Cereal::Writer::writeBytes<dataType>(pointer, offset, data):
offset = Cereal::Writer::writeBytes<float>(pointer, offset, 7.2f);
As you can see, the writeBytes
function returns the new offset (in this case, 4 bytes ahead), so you can use that in a for or while loop to serialize a lot of data.
Home | About Cereal | Setup Guide | Technical Docs | API Reference | Copyright © 2016 - 2019 The Cereal Team