fix read/write generic helpers
This commit is contained in:
parent
521d19d172
commit
03c024c1a8
6
meta.go
6
meta.go
|
@ -1,12 +1,14 @@
|
||||||
package meta
|
package meta
|
||||||
|
|
||||||
|
const classField = "$id"
|
||||||
|
|
||||||
func ReadGeneric(r Reader, createFunc StructFactory, field string) (Readable, error) {
|
func ReadGeneric(r Reader, createFunc StructFactory, field string) (Readable, error) {
|
||||||
if err := r.BeginContainer(field); err != nil {
|
if err := r.BeginContainer(field); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var classId uint32
|
var classId uint32
|
||||||
if err := r.ReadUint32(&classId, ""); err != nil {
|
if err := r.ReadUint32(&classId, classField); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +32,7 @@ func WriteGeneric(w Writer, s WritableClass, field string) error {
|
||||||
if err := w.BeginCollection(s.FieldsCount()+1, field); err != nil {
|
if err := w.BeginCollection(s.FieldsCount()+1, field); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := w.WriteUint32(s.ClassId(), ""); err != nil {
|
if err := w.WriteUint32(s.ClassId(), classField); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := s.WriteFields(w); err != nil {
|
if err := s.WriteFields(w); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue