[6a3a178] | 1 | import ByteBuffer from "./ByteBuffer";
|
---|
| 2 | /**
|
---|
| 3 | * This class provides encoding and decoding methods for writing and reading
|
---|
| 4 | * ZigZag-encoded LEB128-64b9B-variant (Little Endian Base 128) values to/from a
|
---|
| 5 | * {@link ByteBuffer}. LEB128's variable length encoding provides for using a
|
---|
| 6 | * smaller nuber of bytes for smaller values, and the use of ZigZag encoding
|
---|
| 7 | * allows small (closer to zero) negative values to use fewer bytes. Details
|
---|
| 8 | * on both LEB128 and ZigZag can be readily found elsewhere.
|
---|
| 9 | *
|
---|
| 10 | * The LEB128-64b9B-variant encoding used here diverges from the "original"
|
---|
| 11 | * LEB128 as it extends to 64 bit values: In the original LEB128, a 64 bit
|
---|
| 12 | * value can take up to 10 bytes in the stream, where this variant's encoding
|
---|
| 13 | * of a 64 bit values will max out at 9 bytes.
|
---|
| 14 | *
|
---|
| 15 | * As such, this encoder/decoder should NOT be used for encoding or decoding
|
---|
| 16 | * "standard" LEB128 formats (e.g. Google Protocol Buffers).
|
---|
| 17 | */
|
---|
| 18 | declare class ZigZagEncoding {
|
---|
| 19 | /**
|
---|
| 20 | * Writes a long value to the given buffer in LEB128 ZigZag encoded format
|
---|
| 21 | * (negative numbers not supported)
|
---|
| 22 | * @param buffer the buffer to write to
|
---|
| 23 | * @param value the value to write to the buffer
|
---|
| 24 | */
|
---|
| 25 | static encode(buffer: ByteBuffer, value: number): void;
|
---|
| 26 | /**
|
---|
| 27 | * Read an LEB128-64b9B ZigZag encoded long value from the given buffer
|
---|
| 28 | * (negative numbers not supported)
|
---|
| 29 | * @param buffer the buffer to read from
|
---|
| 30 | * @return the value read from the buffer
|
---|
| 31 | */
|
---|
| 32 | static decode(buffer: ByteBuffer): number;
|
---|
| 33 | }
|
---|
| 34 | export default ZigZagEncoding;
|
---|