summaryrefslogtreecommitdiff
path: root/src/hub/src/spreadspace.org/sfive/s5typesStore.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/hub/src/spreadspace.org/sfive/s5typesStore.go')
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5typesStore.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5typesStore.go b/src/hub/src/spreadspace.org/sfive/s5typesStore.go
index 67d38d1..b046ce9 100644
--- a/src/hub/src/spreadspace.org/sfive/s5typesStore.go
+++ b/src/hub/src/spreadspace.org/sfive/s5typesStore.go
@@ -207,3 +207,33 @@ func itob(v int64) []byte {
func btoi(b []byte) int64 {
return int64(binary.BigEndian.Uint64(b))
}
+
+type idList []int64
+
+func idListFromBytes(data []byte) (ids idList, err error) {
+ l := len(data)
+ if l%8 != 0 {
+ err = errors.New("length of data must be multiples of 8")
+ return
+ }
+ for i := 0; i < l; i += 8 {
+ ids = append(ids, int64(binary.BigEndian.Uint64(data[i:i+8])))
+ }
+ return
+}
+
+func (ids idList) toBytes() (data []byte) {
+ l := len(ids)
+ data = make([]byte, 8*l)
+ for i, d := 0, 0; i < l; i, d = i+1, d+8 {
+ binary.BigEndian.PutUint64(data[d:d+8], uint64(ids[i]))
+ }
+ return
+}
+
+func appendToBinaryIDList(b []byte, id int64) []byte {
+ l := len(b)
+ b = append(b, make([]byte, 8)...)
+ binary.BigEndian.PutUint64(b[l:l+8], uint64(id))
+ return b
+}