Example #1
0
// decode from bytes. Return bytes decoded and errEOS if we run out of data.
func (pd pnDecoder) decode(bytes []byte) (n int, err error) {
	C.pn_data_clear(pd.data)
	if len(bytes) == 0 {
		return 0, errEOS
	}
	cBuf := (*C.char)(unsafe.Pointer(&bytes[0]))
	result := int(C.pn_data_decode(pd.data, cBuf, C.size_t(len(bytes))))
	if result < 0 {
		return 0, errorCode(result)
	} else {
		return result, nil
	}
}
Example #2
0
func clearMarshal(v interface{}, data *C.pn_data_t) {
	C.pn_data_clear(data)
	marshal(v, data)
}
Example #3
0
func replace(data *C.pn_data_t, v interface{}) {
	C.pn_data_clear(data)
	marshal(v, data)
}
Example #4
0
func (d Data) Clear()                  { C.pn_data_clear(d.pn) }