Parsing : int32 uint32 float32 double64 string (all single values and arrays)
This commit is contained in:
@ -97,27 +97,80 @@ def bmms_bin_entry_genericparser(pcDataBuf):
|
||||
|
||||
mEntry = {'Type':0,'Val':0}
|
||||
mEntry['Type'] = uint32_to_id(uiID)
|
||||
mList = []
|
||||
|
||||
match uiType:
|
||||
|
||||
case 0x01000000 | 0x02000000 | 0x03000000 | 0xa1000000 | 0xa2000000 | 0xa3000000 :
|
||||
|
||||
case 0x01000000 | 0xa1000000 :
|
||||
|
||||
if (uiSize - st_ReadedBytes) % 4 != 0:
|
||||
mEntry['Val'] = []
|
||||
return mEntry
|
||||
|
||||
nIntValues = int((uiSize - st_ReadedBytes) / 4)
|
||||
|
||||
mList = []
|
||||
for i in range(nIntValues):
|
||||
mList.append(struct.unpack('!i', pcDataBuf[st_ReadedBytes:st_ReadedBytes + 4][:4])[0])
|
||||
st_ReadedBytes += 4
|
||||
|
||||
mEntry['Val'] = mList
|
||||
|
||||
case 0x02000000 | 0xa2000000 :
|
||||
|
||||
if (uiSize - st_ReadedBytes) % 4 != 0:
|
||||
mEntry['Val'] = []
|
||||
return mEntry
|
||||
|
||||
nIntValues = int((uiSize - st_ReadedBytes) / 4)
|
||||
|
||||
mList = []
|
||||
for i in range(nIntValues):
|
||||
mList.append(read_nbo(pcDataBuf[st_ReadedBytes:st_ReadedBytes + 4]))
|
||||
st_ReadedBytes += 4
|
||||
|
||||
mEntry['Val'] = mList
|
||||
|
||||
case 0x03000000 |0xa3000000 :
|
||||
|
||||
if (uiSize - st_ReadedBytes) % 4 != 0:
|
||||
mEntry['Val'] = []
|
||||
return mEntry
|
||||
|
||||
nIntValues = int((uiSize - st_ReadedBytes) / 4)
|
||||
|
||||
mList = []
|
||||
for i in range(nIntValues):
|
||||
mList.append(struct.unpack('!f', pcDataBuf[st_ReadedBytes:st_ReadedBytes + 4][:4])[0])
|
||||
st_ReadedBytes += 4
|
||||
|
||||
mEntry['Val'] = mList
|
||||
|
||||
case 0x04000000 | 0xa4000000:
|
||||
|
||||
case 0x05000000:
|
||||
mEntry['Val'] = pcDataBuf[st_ReadedBytes:st_ReadedBytes + uiSize-8].rstrip(b'\0').decode('utf-8')
|
||||
|
||||
if (uiSize - st_ReadedBytes) % 8 != 0:
|
||||
mEntry['Val'] = []
|
||||
return mEntry
|
||||
|
||||
nIntValues = int((uiSize - st_ReadedBytes) / 8)
|
||||
|
||||
mList = []
|
||||
for i in range(nIntValues):
|
||||
mList.append(struct.unpack('!d', pcDataBuf[st_ReadedBytes:st_ReadedBytes + 8][:8])[0])
|
||||
st_ReadedBytes += 8
|
||||
|
||||
mEntry['Val'] = []
|
||||
|
||||
case 0x05000000 | 0xa5000000 :
|
||||
sList = pcDataBuf[st_ReadedBytes:st_ReadedBytes + uiSize-8].split(b'\b')
|
||||
mList = []
|
||||
for mStr in sList[1:]:
|
||||
mList.append(mStr.rstrip(b'\0').decode('utf-8'))
|
||||
mList
|
||||
mEntry['Val'] = mList
|
||||
|
||||
case 0xc5000000 :
|
||||
mEntry['Val'] = pcDataBuf[st_ReadedBytes:st_ReadedBytes + uiSize-8]
|
||||
|
||||
case other:
|
||||
return mEntry
|
||||
|
||||
|
Reference in New Issue
Block a user