7 return struct.pack(
'<?', value)
10 return struct.pack(
'<c', value)
13 return struct.pack(
'<b', value)
16 return struct.pack(
'<h', value)
19 return struct.pack(
'<i', value)
22 return struct.pack(
'<q', value)
25 return struct.pack(
'<B', value)
28 return struct.pack(
'<H', value)
31 return struct.pack(
'<I', value)
34 return struct.pack(
'<Q', value)
37 return struct.pack(
'<f', value)
40 return struct.pack(
'<d', value)
47 def unpack(fmt, size, bytestream, offset = 0):
48 return struct.unpack_from(fmt, bytestream, offset)[0], offset + size
51 return unpack(
'<?', 4, bytestream, offset)
54 return unpack(
'<c', 1, bytestream, offset)
57 return unpack(
'<b', 1, bytestream, offset)
60 return unpack(
'<h', 2, bytestream, offset)
63 return unpack(
'<i', 4, bytestream, offset)
66 return unpack(
'<q', 8, bytestream, offset)
69 return unpack(
'<B', 1, bytestream, offset)
72 return unpack(
'<H', 2, bytestream, offset)
75 return unpack(
'<I', 4, bytestream, offset)
78 return unpack(
'<Q', 8, bytestream, offset)
81 return unpack(
'<f', 4, bytestream, offset)
84 return unpack(
'<d', 8, bytestream, offset)
88 value =
"".join(struct.unpack_from(
'<' + str(size) +
'c', bytestream, offset))