Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::EncodingUtil Struct Reference

Static Public Member Functions

template<class T >
static idx_t EncodeUnsignedLEB128 (data_ptr_t target, T value)
 
template<class T >
static idx_t DecodeUnsignedLEB128 (const_data_ptr_t source, T &result)
 
template<class T >
static idx_t EncodeSignedLEB128 (data_ptr_t target, T value)
 
template<class T >
static idx_t DecodeSignedLEB128 (const_data_ptr_t source, T &result)
 
template<class T >
static std::enable_if< std::is_signed< T >::value, idx_t >::type DecodeLEB128 (const_data_ptr_t source, T &result)
 
template<class T >
static std::enable_if< std::is_unsigned< T >::value, idx_t >::type DecodeLEB128 (const_data_ptr_t source, T &result)
 
template<class T >
static std::enable_if< std::is_signed< T >::value, idx_t >::type EncodeLEB128 (data_ptr_t target, T value)
 
template<class T >
static std::enable_if< std::is_unsigned< T >::value, idx_t >::type EncodeLEB128 (data_ptr_t target, T value)
 

Member Function Documentation

◆ EncodeUnsignedLEB128()

template<class T >
static idx_t duckdb::EncodingUtil::EncodeUnsignedLEB128 ( data_ptr_t  target,
value 
)
inlinestatic
21635 {
21636 static_assert(std::is_integral<T>::value, "Must be integral");
21637 static_assert(std::is_unsigned<T>::value, "Must be unsigned");
21638 static_assert(sizeof(T) <= sizeof(uint64_t), "Must be uint64_t or smaller");
21639
21640 idx_t offset = 0;
21641 do {
21642 uint8_t byte = value & 0x7F;
21643 value >>= 7;
21644 if (value != 0) {
21645 byte |= 0x80;
21646 }
21647 target[offset++] = byte;
21648 } while (value != 0);
21649 return offset;
21650 }
::uint8_t uint8_t
::uint64_t uint64_t

◆ DecodeUnsignedLEB128()

template<class T >
static idx_t duckdb::EncodingUtil::DecodeUnsignedLEB128 ( const_data_ptr_t  source,
T &  result 
)
inlinestatic
21654 {
21655 constexpr idx_t max_shift = sizeof(T) * 8;
21656 static_assert(std::is_integral<T>::value, "Must be integral");
21657 static_assert(std::is_unsigned<T>::value, "Must be unsigned");
21658 static_assert(sizeof(T) <= sizeof(uint64_t), "Must be uint64_t or smaller");
21659
21660 result = 0;
21661 idx_t shift = 0;
21662 idx_t offset = 0;
21663 uint8_t byte;
21664 do {
21665 byte = source[offset++];
21666 if (shift >= max_shift) {
21667 throw IOException("Failed to decode LEB128 integer: data may be corrupt");
21668 }
21669 result |= static_cast<T>(byte & 0x7F) << shift;
21670 shift += 7;
21671 } while (byte & 0x80);
21672
21673 return offset;
21674 }

◆ EncodeSignedLEB128()

template<class T >
static idx_t duckdb::EncodingUtil::EncodeSignedLEB128 ( data_ptr_t  target,
value 
)
inlinestatic
21678 {
21679 static_assert(std::is_integral<T>::value, "Must be integral");
21680 static_assert(std::is_signed<T>::value, "Must be signed");
21681 static_assert(sizeof(T) <= sizeof(int64_t), "Must be int64_t or smaller");
21682
21683 idx_t offset = 0;
21684 do {
21685 uint8_t byte = value & 0x7F;
21686 value >>= 7;
21687
21688 // Determine whether more bytes are needed
21689 if ((value == 0 && (byte & 0x40) == 0) || (value == -1 && (byte & 0x40))) {
21690 target[offset++] = byte;
21691 break;
21692 } else {
21693 byte |= 0x80;
21694 target[offset++] = byte;
21695 }
21696 } while (true);
21697 return offset;
21698 }
::int64_t int64_t

◆ DecodeSignedLEB128()

template<class T >
static idx_t duckdb::EncodingUtil::DecodeSignedLEB128 ( const_data_ptr_t  source,
T &  result 
)
inlinestatic
21702 {
21703 constexpr idx_t max_shift = sizeof(T) * 8;
21704 static_assert(std::is_integral<T>::value, "Must be integral");
21705 static_assert(std::is_signed<T>::value, "Must be signed");
21706 static_assert(sizeof(T) <= sizeof(int64_t), "Must be int64_t or smaller");
21707
21708 // This is used to avoid undefined behavior when shifting into the sign bit
21709 using unsigned_type = typename std::make_unsigned<T>::type;
21710
21711 result = 0;
21712 idx_t shift = 0;
21713 idx_t offset = 0;
21714
21715 uint8_t byte;
21716 do {
21717 byte = source[offset++];
21718 if (shift >= max_shift) {
21719 throw IOException("Failed to decode LEB128 integer: data may be corrupt");
21720 }
21721 result |= static_cast<unsigned_type>(byte & 0x7F) << shift;
21722 shift += 7;
21723 } while (byte & 0x80);
21724
21725 // Sign-extend if the most significant bit of the last byte is set
21726 if (shift < sizeof(T) * 8 && (byte & 0x40)) {
21727 result |= -(static_cast<unsigned_type>(1) << shift);
21728 }
21729 return offset;
21730 }

◆ DecodeLEB128() [1/2]

template<class T >
static std::enable_if< std::is_signed< T >::value, idx_t >::type duckdb::EncodingUtil::DecodeLEB128 ( const_data_ptr_t  source,
T &  result 
)
inlinestatic
21734 {
21735 return DecodeSignedLEB128(source, result);
21736 }

◆ DecodeLEB128() [2/2]

template<class T >
static std::enable_if< std::is_unsigned< T >::value, idx_t >::type duckdb::EncodingUtil::DecodeLEB128 ( const_data_ptr_t  source,
T &  result 
)
inlinestatic
21740 {
21741 return DecodeUnsignedLEB128(source, result);
21742 }

◆ EncodeLEB128() [1/2]

template<class T >
static std::enable_if< std::is_signed< T >::value, idx_t >::type duckdb::EncodingUtil::EncodeLEB128 ( data_ptr_t  target,
value 
)
inlinestatic
21745 {
21746 return EncodeSignedLEB128(target, value);
21747 }

◆ EncodeLEB128() [2/2]

template<class T >
static std::enable_if< std::is_unsigned< T >::value, idx_t >::type duckdb::EncodingUtil::EncodeLEB128 ( data_ptr_t  target,
value 
)
inlinestatic
21750 {
21751 return EncodeUnsignedLEB128(target, value);
21752 }

The documentation for this struct was generated from the following file: