-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get content size from serial type
- Loading branch information
Showing
1 changed file
with
23 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
package dataformat | ||
|
||
func GetContentSize(serialCode uint64) (contentSize uint64) { | ||
// TODO | ||
return contentSize | ||
func GetContentSize(serialType uint64) uint64 { | ||
switch { | ||
case serialType == 1: | ||
return 1 // 8-bit integer | ||
case serialType == 2: | ||
return 2 // 16-bit integer | ||
case serialType == 3: | ||
return 3 // 24-bit integer | ||
case serialType == 4: | ||
return 4 // 32-bit integer | ||
case serialType == 5: | ||
return 6 // 48-bit integer | ||
case serialType == 6: | ||
return 8 // 64-bit integer | ||
case serialType == 7: | ||
return 8 // 64-bit floating point | ||
case serialType >= 12 && serialType%2 == 0: | ||
return (serialType - 12) / 2 // BLOB | ||
case serialType >= 13 && serialType%2 == 1: | ||
return (serialType - 13) / 2 // Text string | ||
default: | ||
return 0 // NULL | ||
} | ||
} |