Skip to content

Commit

Permalink
root/rbytes: add WriteObject
Browse files Browse the repository at this point in the history
  • Loading branch information
sbinet committed Feb 1, 2022
1 parent fa6827e commit e488e92
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions groot/rbytes/wbuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,20 @@ func (w *WBuffer) WriteVersion(vers int16) int64 {
return pos
}

func (w *WBuffer) WriteObject(obj root.Object) error {
if w.err != nil {
return w.err
}

if v := reflect.ValueOf(obj); (v == reflect.Value{}) || v.IsNil() {
w.WriteU32(0) // NULL pointer
return w.err
}

_, w.err = obj.(Marshaler).MarshalROOT(w)
return w.err
}

func (w *WBuffer) WriteObjectAny(obj root.Object) error {
if w.err != nil {
return w.err
Expand Down

0 comments on commit e488e92

Please sign in to comment.