Skip to content

Use most-significant bit to create integer values of varying sizes.

Notifications You must be signed in to change notification settings

hypercore-cxx/varint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SYNOPSIS

Use msb to create integer values of varying sizes.

USAGE

This module is designed to work with the datcxx build tool. To add this module to your project us the following command...

build add datcxx/varint

TEST

build test

API

struct Encoded {
  std::vector<uint8_t> value;
  unsigned bytes;
};

struct Decoded {
  unsigned value;
  unsigned bytes;
};
Encoded encode (unsigned num);
Encoded encode (unsigned num, std::vector<uint8_t> out, unsigned offset = 0);
Decoded decode (std::vector<uint8_t> buf, unsigned offset = 0);

SEE ALSO

  • This is a nice visual illustration of how varints work.
  • This is a port of Chris Dickinson's varint implementation.
  • This also references Dat Rust varint implementation.
  • A quick summary of how varint encoding works.
  • See this guide to efficiently encoding variable-length integers in C/C++.

About

Use most-significant bit to create integer values of varying sizes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages