Module bin.rbuf
Implements unsafe binary Reader.
Same as bin.basebuf supports decoding numbers into any endianess.
{u,i}{8,16,32,64}{be,le,}
are supported opposite to defined at bin.basebuf.
Class rbuf
rbuf:ber() | Decodes VLQ number Opposite to bin.basebuf.ber (LuaJIT >= 2.1). |
rbuf:str(len) | [unsafe] Extracts len bytes from buffer as string |
rbuf:dump() | [safe] Returns nice hexdump of the remaining buffer |
rbuf:hex() | [safe] Returns hex representation of the remaining buffer |
rbuf:move() | [safe] memmoves remaining buffer to the beginning. |
rbuf:skip(len) | [unsafe] Forwards cursor for len bytes (accepts negatives). |
rbuf:avail() | [safe] Returns remaining part of the buffer |
rbuf.new(p[, l=#p]) | Creates rbuf from pointer |
Class rbuf
Implements unsafe binary Reader. Has following structure.
struct bin_rbuf {
const char * buf;
union {
const char *c;
const int8_t *i8;
const uint8_t *u8;
const int16_t *i16;
const uint16_t *u16;
const int32_t *i32;
const uint32_t *u32;
const int64_t *i64;
const uint64_t *u64;
} p;
size_t len;
};
- rbuf:ber()
-
Decodes VLQ number Opposite to bin.basebuf.ber (LuaJIT >= 2.1).
Returns:
number
decoded value - rbuf:str(len)
-
[unsafe] Extracts
len
bytes from buffer as stringParameters:
- len number size of resulting string
Returns:
-
string str
- rbuf:dump()
-
[safe] Returns nice hexdump of the remaining buffer
Returns:
-
string hexdump
See also:
- rbuf:hex()
-
[safe] Returns hex representation of the remaining buffer
Returns:
-
string hex
See also:
- rbuf:move()
-
[safe] memmoves remaining buffer to the beginning.
shrinks
len
of the buffer. - rbuf:skip(len)
-
[unsafe] Forwards cursor for
len
bytes (accepts negatives).Parameters:
- len number `
- rbuf:avail()
-
[safe] Returns remaining part of the buffer
Returns:
left
bytes - rbuf.new(p[, l=#p])
-
Creates rbuf from pointer
Parameters:
- p char* pointer or string
- l length of the pointer (default #p)
Returns: