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

Static Public Member Functions

static int32_t FormatMicros (int32_t microseconds, char micro_buffer[])
 Format microseconds to a buffer of length 6. Returns the number of trailing zeros.
static idx_t MicrosLength (int32_t micros, char micro_buffer[])
static idx_t Length (int32_t time[], char micro_buffer[])
static void FormatTwoDigits (char *ptr, int32_t value)
static void Format (char *data, idx_t length, int32_t hour, int32_t minute, int32_t second, int32_t microsecond, char micro_buffer[])
static void Format (char *data, idx_t length, int32_t time[], char micro_buffer[])

Member Function Documentation

◆ FormatMicros()

int32_t duckdb::TimeToStringCast::FormatMicros ( int32_t microseconds,
char micro_buffer[] )
inlinestatic

Format microseconds to a buffer of length 6. Returns the number of trailing zeros.

19945 {
19946 char *endptr = micro_buffer + 6;
19947 endptr = NumericHelper::FormatUnsigned<int32_t>(microseconds, endptr);
19948 while (endptr > micro_buffer) {
19949 *--endptr = '0';
19950 }
19951 idx_t trailing_zeros = 0;
19952 for (idx_t i = 5; i > 0; i--) {
19953 if (micro_buffer[i] != '0') {
19954 break;
19955 }
19956 trailing_zeros++;
19957 }
19958 return UnsafeNumericCast<int32_t>(trailing_zeros);
19959 }
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
Here is the caller graph for this function:

◆ MicrosLength()

idx_t duckdb::TimeToStringCast::MicrosLength ( int32_t micros,
char micro_buffer[] )
inlinestatic
19961 {
19962 // format is HH:MM:DD.MS
19963 // microseconds come after the time with a period separator
19964 idx_t length;
19965 if (micros == 0) {
19966 // no microseconds
19967 // format is HH:MM:DD
19968 length = 8;
19969 } else {
19970 length = 15;
19971 // for microseconds, we truncate any trailing zeros (i.e. "90000" becomes ".9")
19972 // first write the microseconds to the microsecond buffer
19973 // we write backwards and pad with zeros to the left
19974 // now we figure out how many digits we need to include by looking backwards
19975 // and checking how many zeros we encounter
19976 length -= NumericCast<idx_t>(FormatMicros(micros, micro_buffer));
19977 }
19978 return length;
19979 }
static int32_t FormatMicros(int32_t microseconds, char micro_buffer[])
Format microseconds to a buffer of length 6. Returns the number of trailing zeros.
Definition duckdb.cpp:19945

◆ Length()

idx_t duckdb::TimeToStringCast::Length ( int32_t time[],
char micro_buffer[] )
inlinestatic
19981 {
19982 return MicrosLength(time[3], micro_buffer);
19983 }

◆ FormatTwoDigits()

void duckdb::TimeToStringCast::FormatTwoDigits ( char * ptr,
int32_t value )
inlinestatic
19985 {
19986 D_ASSERT(value >= 0 && value <= 99);
19987 if (value < 10) {
19988 ptr[0] = '0';
19989 ptr[1] = UnsafeNumericCast<char>('0' + value);
19990 } else {
19991 auto index = UnsafeNumericCast<unsigned>(value * 2);
19992 ptr[0] = duckdb_fmt::internal::data::digits[index];
19993 ptr[1] = duckdb_fmt::internal::data::digits[index + 1];
19994 }
19995 }
index

◆ Format() [1/2]

void duckdb::TimeToStringCast::Format ( char * data,
idx_t length,
int32_t hour,
int32_t minute,
int32_t second,
int32_t microsecond,
char micro_buffer[] )
inlinestatic
19998 {
19999 // first write hour, month and day
20000 FormatTwoDigits(data, hour);
20001 data[2] = ':';
20002 FormatTwoDigits(data + 3, minute);
20003 data[5] = ':';
20004 FormatTwoDigits(data + 6, second);
20005 if (length > 8) {
20006 // write the micro seconds at the end
20007 data[8] = '.';
20008 memcpy(data + 9, micro_buffer, length - 9);
20009 }
20010 }

◆ Format() [2/2]

void duckdb::TimeToStringCast::Format ( char * data,
idx_t length,
int32_t time[],
char micro_buffer[] )
inlinestatic
20012 {
20013 Format(data, length, time[0], time[1], time[2], time[3], micro_buffer);
20014 }

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