Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Little endian base 128 implementation, which stores arbitrarily large integers in a variable length format.

License

NotificationsYou must be signed in to change notification settings

bolderflight/leb128

Repository files navigation

License: MIT

Bolder Flight Systems Logo    Arduino Logo

Leb128

Signed little endian base 128 (LEB128) implementation, which stores arbitrarily large signed integers in a variable length format. This library is compatible with Arduino ARM and with CMake build systems. It would also be easy to include with other projects, since it is a header only library consisting of a single file.

Installation

Arduino

Use the Arduino Library Manager to install this library or clone to your Arduino/libraries folder. This library is added as:

#include"leb128.h"

An example Arduino executable is located atexamples/arduino/leb128_example/leb128_example.ino. Teensy 3.x, 4.x, and LC devices are used for testing under Arduino and this library should be compatible with other ARM devices. This library isnot expected to work on AVR devices.

CMake

CMake is used to build this library, which is exported as a library target calledleb128. The header is added as:

#include"leb128.h"

The library can be also be compiled stand-alone using the CMake idiom of creating abuild directory and then, from within that directory issuing:

cmake ..make

This will build the library, an example executable calledleb128_example, and an executable for testing using the Google Test framework, calledleb128_test. The example executable source file is located atexamples/cmake/leb128_example.cc.

Namespace

This library is within the namespacebfs.

Functions

std::size_t EncodeLeb128(int64_t val, uint8_t * const data, const std::size_t len) Encodes an int64_tval into a LEB128 variable length format stored in the arraydata of lengthlen. Returns the number of bytes written if successful, otherwise, returns 0.

std::size_t DecodeLeb128(uint8_t const * const data, const std::size_t len, int64_t * const val) Decodes a LEB128 variable length value from the arraydata of lengthlen into an int64_t variableval. Returns the number of bytes read if successful, otherwise, returns 0.

uint8_t buf[100];int64_t read_val =0;int64_t orig_val = std::numeric_limits<int64_t>::max();std::size_t bytes_written = bfs::EncodeLeb128(orig_val, buf,sizeof(buf));std::size_t bytes_read = bfs::DecodeLeb128(buf,sizeof(buf), &read_val);

About

Little endian base 128 implementation, which stores arbitrarily large integers in a variable length format.

Topics

Resources

License

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp