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::string_t Struct Reference

Classes

struct  StringComparisonOperators
 

Public Member Functions

 string_t (uint32_t len)
 
 string_t (const char *data, uint32_t len)
 
 string_t (const char *data)
 
 string_t (const string &value)
 
bool IsInlined () const
 
const charGetData () const
 
const charGetDataUnsafe () const
 
charGetDataWriteable () const
 
const charGetPrefix () const
 
charGetPrefixWriteable ()
 
idx_t GetSize () const
 
void SetSizeAndFinalize (uint32_t size, idx_t allocated_size)
 
bool Empty () const
 
string GetString () const
 
 operator string () const
 
charGetPointer () const
 
void SetPointer (char *new_ptr)
 
void Finalize ()
 
void Verify () const
 
void VerifyUTF8 () const
 
void VerifyCharacters () const
 
void VerifyNull () const
 
bool operator== (const string_t &r) const
 
bool operator!= (const string_t &r) const
 
bool operator> (const string_t &r) const
 
bool operator< (const string_t &r) const
 

Static Public Attributes

static constexpr idx_t PREFIX_BYTES = 4 * sizeof(char)
 
static constexpr idx_t INLINE_BYTES = 12 * sizeof(char)
 
static constexpr idx_t HEADER_SIZE = sizeof(uint32_t) + PREFIX_BYTES
 
static constexpr idx_t MAX_STRING_SIZE = NumericLimits<uint32_t>::Maximum()
 
static constexpr idx_t PREFIX_LENGTH = PREFIX_BYTES
 
static constexpr idx_t INLINE_LENGTH = INLINE_BYTES
 

Private Attributes

union { 
 
   struct { 
 
      uint32_t   length 
 
      char   prefix [4] 
 
      char *   ptr 
 
   }   pointer 
 
   struct { 
 
      uint32_t   length 
 
      char   inlined [12] 
 
   }   inlined 
 
value 
 

Friends

struct StringComparisonOperators
 

Constructor & Destructor Documentation

◆ string_t() [1/4]

duckdb::string_t::string_t ( uint32_t  len)
inlineexplicit
4723 {
4724 value.inlined.length = len;
4725 }

◆ string_t() [2/4]

duckdb::string_t::string_t ( const char data,
uint32_t  len 
)
inline
4726 {
4727 value.inlined.length = len;
4728 D_ASSERT(data || GetSize() == 0);
4729 if (IsInlined()) {
4730 // zero initialize the prefix first
4731 // this makes sure that strings with length smaller than 4 still have an equal prefix
4732 memset(value.inlined.inlined, 0, INLINE_BYTES);
4733 if (GetSize() == 0) {
4734 return;
4735 }
4736 // small string: inlined
4737 memcpy(value.inlined.inlined, data, GetSize());
4738 } else {
4739 // large string: store pointer
4740#ifndef DUCKDB_DEBUG_NO_INLINE
4741 memcpy(value.pointer.prefix, data, PREFIX_LENGTH);
4742#else
4743 memset(value.pointer.prefix, 0, PREFIX_BYTES);
4744#endif
4745 value.pointer.ptr = (char *)data; // NOLINT
4746 }
4747 }

◆ string_t() [3/4]

duckdb::string_t::string_t ( const char data)
inline
4750 : string_t(data, UnsafeNumericCast<uint32_t>(strlen(data))) {
4751 }

◆ string_t() [4/4]

duckdb::string_t::string_t ( const string &  value)
inline
4753 : string_t(value.c_str(), UnsafeNumericCast<uint32_t>(value.size())) {
4754 }

Member Function Documentation

◆ IsInlined()

bool duckdb::string_t::IsInlined ( ) const
inline
4756 {
4757 return GetSize() <= INLINE_LENGTH;
4758 }

◆ GetData()

const char * duckdb::string_t::GetData ( ) const
inline
4760 {
4761 return IsInlined() ? const_char_ptr_cast(value.inlined.inlined) : value.pointer.ptr;
4762 }

◆ GetDataUnsafe()

const char * duckdb::string_t::GetDataUnsafe ( ) const
inline
4763 {
4764 return GetData();
4765 }

◆ GetDataWriteable()

char * duckdb::string_t::GetDataWriteable ( ) const
inline
4767 {
4768 return IsInlined() ? (char *)value.inlined.inlined : value.pointer.ptr; // NOLINT
4769 }

◆ GetPrefix()

const char * duckdb::string_t::GetPrefix ( ) const
inline
4771 {
4772 return value.inlined.inlined;
4773 }

◆ GetPrefixWriteable()

char * duckdb::string_t::GetPrefixWriteable ( )
inline
4775 {
4776 return value.inlined.inlined;
4777 }

◆ GetSize()

idx_t duckdb::string_t::GetSize ( ) const
inline
4779 {
4780 return value.inlined.length;
4781 }

◆ SetSizeAndFinalize()

void duckdb::string_t::SetSizeAndFinalize ( uint32_t  size,
idx_t  allocated_size 
)
inline

Data was written to the 'value.pointer.ptr', has to be copied to the inlined bytes

4783 {
4784 value.inlined.length = size;
4785 if (allocated_size > INLINE_LENGTH && IsInlined()) {
4787 D_ASSERT(value.pointer.ptr);
4788 auto ptr = value.pointer.ptr;
4789 memcpy(GetDataWriteable(), ptr, size);
4790 }
4791 Finalize();
4792 VerifyCharacters();
4793 }
GOpaque< Size > size(const GMat &src)
Here is the call graph for this function:

◆ Empty()

bool duckdb::string_t::Empty ( ) const
inline
4795 {
4796 return value.inlined.length == 0;
4797 }

◆ GetString()

string duckdb::string_t::GetString ( ) const
inline
4799 {
4800 return string(GetData(), GetSize());
4801 }

◆ operator string()

duckdb::string_t::operator string ( ) const
inlineexplicit
4803 {
4804 return GetString();
4805 }

◆ GetPointer()

char * duckdb::string_t::GetPointer ( ) const
inline
4807 {
4808 D_ASSERT(!IsInlined());
4809 return value.pointer.ptr;
4810 }

◆ SetPointer()

void duckdb::string_t::SetPointer ( char new_ptr)
inline
4812 {
4813 D_ASSERT(!IsInlined());
4814 value.pointer.ptr = new_ptr;
4815 }

◆ Finalize()

void duckdb::string_t::Finalize ( )
inline
4817 {
4818 // set trailing NULL byte
4819 if (GetSize() <= INLINE_LENGTH) {
4820 // fill prefix with zeros if the length is smaller than the prefix length
4821 memset(value.inlined.inlined + GetSize(), 0, INLINE_BYTES - GetSize());
4822 } else {
4823 // copy the data into the prefix
4824#ifndef DUCKDB_DEBUG_NO_INLINE
4825 auto dataptr = GetData();
4826 memcpy(value.pointer.prefix, dataptr, PREFIX_LENGTH);
4827#else
4828 memset(value.pointer.prefix, 0, PREFIX_BYTES);
4829#endif
4830 }
4831 }

◆ operator==()

bool duckdb::string_t::operator== ( const string_t r) const
inline
4895 {
4896 return StringComparisonOperators::Equals(*this, r);
4897 }

◆ operator!=()

bool duckdb::string_t::operator!= ( const string_t r) const
inline
4899 {
4900 return !(*this == r);
4901 }

◆ operator>()

bool duckdb::string_t::operator> ( const string_t r) const
inline
4903 {
4904 return StringComparisonOperators::GreaterThan(*this, r);
4905 }

◆ operator<()

bool duckdb::string_t::operator< ( const string_t r) const
inline
4906 {
4907 return r > *this;
4908 }

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