new pack / unpack function design
Opened this issue · 0 comments
LaughingSun commented
spackf
outQueue = SAN.datapacker( format, inQueue[, outQueue] )
- format codes begin with the percent sign('%') followed by an optional alignment/byte order/padding modifiers, optional consumption, single character code, optional modifiers, optional splice code or grouped embedded data. and an optional repeat count.
- a comma(',') or semicolon(';') signifies skipping to the next (non-embedded) data item.
- anything not a format code or other process character is implied as literal, escaped characters are literal, literal characters and parts/substrings can also use the literal code (optionally with grouping), fe "an example of literal code usage "%q(this is a literal)" and this is not."
- alignment (optional)
- minus('-') left justified
- plus('+') right justified
- chunk size and byte order (optional)
- c 8 bit chunks, little endian
- C 8 bit chunks, big endian
- w 16 bit chunks, little endian
- W 16 bit chunks, big endian
- t 24 bit chunks, little endian
- T 24 bit chunks, big endian
- l 32 bit chunks, little endian
- L 32 bit chunks, big endian
- q 64 bit chunks, little endian
- Q 64 bit chunks, big endian
- 'c{' n-bit '}' n bit chunks, little endian
- 'C{' n-bit '}' n bit chunks, little endian
- padding (optional)
- '0' zero padded
- 'x' space padded
- '!' null padded (default)
- '[' other ']' other padded
- consumption (optional)
- an integer, consumes that many chunks
- asterix('*') consumes until finished
- '$' null terminated
- '^' first chunk is length terminated
- splice codes (optional)
- '@' inserts the current absolute offset of the packed data item
- '&' inserts the current packed data item offset of the packed data item
- '#' inserts the length of the current data item
- '#@' inserts the length of packed data
- '#&' insert the length of the current packed data item from the offset to the end
- codes (required)
- 'b' as blob
- 'd' as integer
- 'f' as float
- 's' ascii
- 'u' utf8
- 'U' utf16
Basically this should follow the concept of:
- in-queue consumption or insertion
- how much to consume, with conditionals: until end, until character or value
- how to parse
- out-queue push or dump
- how much to push or dump with conditionals: until end, until character or value
- how to format
- repetitions, how many times to do this with conditionals: until end, until character or value
method would look like
outQueue = datapacker(format, inQueue[, outQueue]);