awtk/docs/fscript_rbuffer.md
2021-01-12 14:29:47 +08:00

1.2 KiB

读缓冲区扩展函数

1.rbuffer_create

2.rbuffer_skip

3.rbuffer_rewind

4.rbuffer_read_uint8

5.rbuffer_read_uint16

6.rbuffer_read_uint32

7.rbuffer_read_uint64

8.rbuffer_read_int8

9.rbuffer_read_int16

10.rbuffer_read_int32

11.rbuffer_read_int64

12.rbuffer_read_float

13.rbuffer_read_double

14.rbuffer_read_string

15.rbuffer_read_binary

16.rbuffer_get_data

17.rbuffer_get_cursor

18.rbuffer_get_capacity

更多示例

...

b=rbuffer_create(wbuffer_get_data(a), wbuffer_get_cursor(a))

assert(rbuffer_get_cursor(b)==0)
assert(rbuffer_read_int8(b)== -10)

assert(rbuffer_get_cursor(b)==1)
assert(rbuffer_read_int16(b)==-1122)

assert(rbuffer_get_cursor(b)==3)
assert(rbuffer_read_int32(b)==-11223344)

assert(rbuffer_get_cursor(b)==7)
assert(rbuffer_read_int64(b)==-1122334455667788)

assert(rbuffer_get_cursor(b)==15)
assert(rbuffer_read_string(b)=="hello")
assert(rbuffer_get_cursor(b)==21)
c = rbuffer_read_binary(b, 6)
assert(rbuffer_get_cursor(b)==27)

wbuffer_rewind(a)
assert(wbuffer_get_cursor(a)==0)
wbuffer_write_binary(a, c)
assert(wbuffer_get_cursor(a)==6)

unset(a)
unset(b)