Jacob Campbell
Parsing/Deserializing Structured File’s Bytes
Gotcha, I’ve got a function already that handles the endianness, so if that’s the only thing, I’m probably gonna keep it as is. There’s no like performance benefit is there? I would assume it just goes through and flips the bit order if it needs to?
16 replies
Parsing/Deserializing Structured File’s Bytes
So my thought was to read the file as a byte array
Separate the header from the compressed portion in an object
Write a method for decompressing the compressed portion
Write a method for searching for the name of each data type in the file and storing it within the object
Then writing methods for the decoding of each header/data type and storing that within the object
So calling the class with the byte array would save attributes within the object would look something like (Note: the data names are messages in the file)
File.hdr
File.decompData
File.msgTypes
File.msgArray
Then there would be methods that check to make sure the messages exist in File.msgTypes and then if they exist, convert them over. The structure of each message is a little different, so I’d have to have different methods for each.
File.getHdr: converts the header into readable data (data source, version number, collection date, etc)
File.getMsg15: checks to make sure Msg15 exists, converts the header into readable data, then converts the data as specified
File.getMsg31: checks to make sure Msg31 exists, converts the header into readable data, then converts the data as specified, etc, etc
Does that sound like a sensible way to handle it?
16 replies
Parsing/Deserializing Structured File’s Bytes
I would assume it’s linear, but not entirely sure what you mean by that 😅
The structure of the file is:
File Header
Compression (everything below is within the compression)
Data Header (contains data name and size of data)
Data
Data Header (contains data name and size of data)
Data
Etc
Etc
16 replies