Bitcloud.c: Pack and parse UBJSON
Opened this issue · 3 comments
complete and test the functions to pack UBJSON messages and parse them back into data.
command line interface test may look like:
bitcloud -ubjson FileName_to_pack new_file
this would open and read FileName as pure data, pack it into a UBJSON message, and output two files.
First file to output (e.g., "FileName.ubjson") would be a raw UBJSON output to prove that the function packs properly (hex editor required for analysis and validation). Second file would take the output from the UBJSON message packing function and output a New_File as the result to validate that unpacking works. (diff to compare)
I'm actually doing these in the serialization routines bc_serialize_row and bc_deserialize_row, taking in count that data is going to be stored in an array of cells (bc_cell and bc_row, this last one is just a pointer). Once I have the routines working, it should be trivial to serialize rows, but I'm not sure why would you like to deserialize an entire file.
This issue should be very much related to the event loop, as the event loop may analize the ubjson data coming from the sockets. We should debate the way to do this. Again, it is not the same to deserialize rows than to deserialize "instructions", althought the principles are the same.
The magic of ubjson is that it is very easy to parse and do not require external frunctions (everything is done in a switch). Remember that C do have a problem with types, you must use unions if you want to respond in the same routine with different data types, so creating a generic deserialization function is not really trivial and easy tu use. We can debate this.
I have done some updates to the ubjson specification in the bitcloud.h, after the conversation on IRC.
okay cool
will take a look on it :)