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::Bit Class Reference

The Bit class is a static class that holds helper functions for the BIT type. More...

Static Public Member Functions

static DUCKDB_API idx_t BitLength (bitstring_t bits)
 Returns the number of bits in the bit string.
 
static DUCKDB_API idx_t BitCount (bitstring_t bits)
 Returns the number of set bits in the bit string.
 
static DUCKDB_API idx_t OctetLength (bitstring_t bits)
 Returns the number of bytes in the bit string.
 
static DUCKDB_API idx_t GetBit (bitstring_t bit_string, idx_t n)
 Extracts the nth bit from bit string; the first (leftmost) bit is indexed 0.
 
static DUCKDB_API void SetBit (bitstring_t &bit_string, idx_t n, idx_t new_value)
 Sets the nth bit in bit string to newvalue; the first (leftmost) bit is indexed 0.
 
static DUCKDB_API idx_t BitPosition (bitstring_t substring, bitstring_t bits)
 Returns first starting index of the specified substring within bits, or zero if it's not present.
 
static DUCKDB_API void ToString (bitstring_t bits, char *output)
 
static DUCKDB_API string ToString (bitstring_t bits)
 
static DUCKDB_API bool TryGetBitStringSize (string_t str, idx_t &result_size, string *error_message)
 Returns the bit size of a string -> bit conversion.
 
static DUCKDB_API void ToBit (string_t str, bitstring_t &output)
 
static DUCKDB_API string ToBit (string_t str)
 
static DUCKDB_API void BlobToBit (string_t blob, bitstring_t &output)
 output needs to have enough space allocated before calling this function (blob size + 1)
 
static DUCKDB_API string BlobToBit (string_t blob)
 
template<class T >
static void NumericToBit (T numeric, bitstring_t &output_str)
 output_str needs to have enough space allocated before calling this function (sizeof(T) + 1)
 
template<class T >
static string NumericToBit (T numeric)
 
template<class T >
static void BitToNumeric (bitstring_t bit, T &output_num)
 bit is expected to fit inside of output num (bit size <= sizeof(T) + 1)
 
template<class T >
staticBitToNumeric (bitstring_t bit)
 
static void BitToBlob (bitstring_t bit, string_t &output_blob)
 bit is expected to fit inside of output_blob (bit size = output_blob + 1)
 
static string BitToBlob (bitstring_t bit)
 
static DUCKDB_API void BitString (const string_t &input, idx_t len, bitstring_t &result)
 Creates a new bitstring of determined length.
 
static DUCKDB_API void ExtendBitString (const bitstring_t &input, idx_t bit_length, bitstring_t &result)
 
static DUCKDB_API void SetEmptyBitString (bitstring_t &target, string_t &input)
 
static DUCKDB_API void SetEmptyBitString (bitstring_t &target, idx_t len)
 
static DUCKDB_API idx_t ComputeBitstringLen (idx_t len)
 
static DUCKDB_API void RightShift (const bitstring_t &bit_string, idx_t shift, bitstring_t &result)
 
static DUCKDB_API void LeftShift (const bitstring_t &bit_string, idx_t shift, bitstring_t &result)
 
static DUCKDB_API void BitwiseAnd (const bitstring_t &rhs, const bitstring_t &lhs, bitstring_t &result)
 
static DUCKDB_API void BitwiseOr (const bitstring_t &rhs, const bitstring_t &lhs, bitstring_t &result)
 
static DUCKDB_API void BitwiseXor (const bitstring_t &rhs, const bitstring_t &lhs, bitstring_t &result)
 
static DUCKDB_API void BitwiseNot (const bitstring_t &rhs, bitstring_t &result)
 
static DUCKDB_API void Verify (const bitstring_t &input)
 

Static Private Member Functions

static void Finalize (bitstring_t &str)
 
static idx_t GetBitInternal (bitstring_t bit_string, idx_t n)
 
static void SetBitInternal (bitstring_t &bit_string, idx_t n, idx_t new_value)
 
static idx_t GetBitIndex (idx_t n)
 
static uint8_t GetFirstByte (const bitstring_t &str)
 

Detailed Description

The Bit class is a static class that holds helper functions for the BIT type.

Member Function Documentation

◆ ToString()

static DUCKDB_API void duckdb::Bit::ToString ( bitstring_t  bits,
char output 
)
static

Converts bits to a string, writing the output to the designated output string. The string needs to have space for at least GetStringSize(bits) bytes.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToBit()

static DUCKDB_API void duckdb::Bit::ToBit ( string_t  str,
bitstring_t output 
)
static

Convert a string to a bit. This function should ONLY be called after calling GetBitSize, since it does NOT perform data validation.

◆ NumericToBit() [1/2]

template<class T >
void duckdb::Bit::NumericToBit ( numeric,
bitstring_t output_str 
)
static

output_str needs to have enough space allocated before calling this function (sizeof(T) + 1)

31110 {
31111 D_ASSERT(output_str.GetSize() >= sizeof(T) + 1);
31112
31113 auto le_numeric = BSwapIfBE(numeric);
31114 auto output = output_str.GetDataWriteable();
31115 auto data = const_data_ptr_cast(&le_numeric);
31116
31117 *output = 0; // set padding to 0
31118 ++output;
31119 for (idx_t idx = 0; idx < sizeof(T); ++idx) {
31120 output[idx] = static_cast<char>(data[sizeof(T) - idx - 1]);
31121 }
31122 Bit::Finalize(output_str);
31123}

◆ NumericToBit() [2/2]

template<class T >
string duckdb::Bit::NumericToBit ( numeric)
static
31126 {
31127 auto bit_len = sizeof(T) + 1;
31128 auto buffer = make_unsafe_uniq_array_uninitialized<char>(bit_len);
31129 bitstring_t output_str(buffer.get(), UnsafeNumericCast<uint32_t>(bit_len));
31130 Bit::NumericToBit(numeric, output_str);
31131 return output_str.GetString();
31132}
static void NumericToBit(T numeric, bitstring_t &output_str)
output_str needs to have enough space allocated before calling this function (sizeof(T) + 1)
Definition duckdb.cpp:31110

◆ BitToNumeric() [1/2]

template<class T >
void duckdb::Bit::BitToNumeric ( bitstring_t  bit,
T &  output_num 
)
static

bit is expected to fit inside of output num (bit size <= sizeof(T) + 1)

31142 {
31143 D_ASSERT(bit.GetSize() <= sizeof(T) + 1);
31144
31145 output_num = 0;
31146 auto data = const_data_ptr_cast(bit.GetData());
31147 auto output = data_ptr_cast(&output_num);
31148
31149 idx_t padded_byte_idx = sizeof(T) - bit.GetSize() + 1;
31150 output[sizeof(T) - 1 - padded_byte_idx] = GetFirstByte(bit);
31151 for (idx_t idx = padded_byte_idx + 1; idx < sizeof(T); ++idx) {
31152 output[sizeof(T) - 1 - idx] = data[1 + idx - padded_byte_idx];
31153 }
31154 output_num = BSwapIfBE(output_num);
31155}

◆ BitToNumeric() [2/2]

template<class T >
T duckdb::Bit::BitToNumeric ( bitstring_t  bit)
static
31135 {
31136 T output;
31137 Bit::BitToNumeric(bit, output);
31138 return (output);
31139}
static void BitToNumeric(bitstring_t bit, T &output_num)
bit is expected to fit inside of output num (bit size <= sizeof(T) + 1)
Definition duckdb.cpp:31142

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