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

Static Public Member Functions

static void FormatSignedNumber (int64_t value, char buffer[], idx_t &length)
 
static void FormatTwoDigits (int64_t value, char buffer[], idx_t &length)
 
static void FormatIntervalValue (int32_t value, char buffer[], idx_t &length, const char *name, idx_t name_len)
 
static idx_t Format (interval_t interval, char buffer[])
 

Member Function Documentation

◆ FormatSignedNumber()

static void duckdb::IntervalToStringCast::FormatSignedNumber ( int64_t  value,
char  buffer[],
idx_t length 
)
inlinestatic
20018 {
20019 int sign = -(value < 0);
20020 auto unsigned_value = NumericCast<uint64_t>((value ^ sign) - sign);
20021 length += NumericCast<idx_t>(NumericHelper::UnsignedLength<uint64_t>(unsigned_value) - sign);
20022 auto endptr = buffer + length;
20023 endptr = NumericHelper::FormatUnsigned<uint64_t>(unsigned_value, endptr);
20024 if (sign) {
20025 *--endptr = '-';
20026 }
20027 }

◆ FormatTwoDigits()

static void duckdb::IntervalToStringCast::FormatTwoDigits ( int64_t  value,
char  buffer[],
idx_t length 
)
inlinestatic
20029 {
20030 TimeToStringCast::FormatTwoDigits(buffer + length, UnsafeNumericCast<int32_t>(value));
20031 length += 2;
20032 }

◆ FormatIntervalValue()

static void duckdb::IntervalToStringCast::FormatIntervalValue ( int32_t  value,
char  buffer[],
idx_t length,
const char name,
idx_t  name_len 
)
inlinestatic
20034 {
20035 if (value == 0) {
20036 return;
20037 }
20038 if (length != 0) {
20039 // space if there is already something in the buffer
20040 buffer[length++] = ' ';
20041 }
20042 FormatSignedNumber(value, buffer, length);
20043 // append the name together with a potential "s" (for plurals)
20044 memcpy(buffer + length, name, name_len);
20045 length += name_len;
20046 if (value != 1 && value != -1) {
20047 buffer[length++] = 's';
20048 }
20049 }

◆ Format()

static idx_t duckdb::IntervalToStringCast::Format ( interval_t  interval,
char  buffer[] 
)
inlinestatic

Formats an interval to a buffer, the buffer should be >=70 characters years: 17 characters (max value: "-2147483647 years") months: 9 (max value: "12 months") days: 16 characters (max value: "-2147483647 days") time: 24 characters (max value: -2562047788:00:00.123456) spaces between all characters (+3 characters) Total: 70 characters Returns the length of the interval

20059 {
20060 idx_t length = 0;
20061 if (interval.months != 0) {
20062 int32_t years = interval.months / 12;
20063 int32_t months = interval.months - years * 12;
20064 // format the years and months
20065 FormatIntervalValue(years, buffer, length, " year", 5);
20066 FormatIntervalValue(months, buffer, length, " month", 6);
20067 }
20068 if (interval.days != 0) {
20069 // format the days
20070 FormatIntervalValue(interval.days, buffer, length, " day", 4);
20071 }
20072 if (interval.micros != 0) {
20073 if (length != 0) {
20074 // space if there is already something in the buffer
20075 buffer[length++] = ' ';
20076 }
20077 int64_t micros = interval.micros;
20078 if (micros < 0) {
20079 // negative time: append negative sign
20080 buffer[length++] = '-';
20081 } else {
20082 micros = -micros;
20083 }
20084 int64_t hour = -(micros / Interval::MICROS_PER_HOUR);
20085 micros += hour * Interval::MICROS_PER_HOUR;
20086 int64_t min = -(micros / Interval::MICROS_PER_MINUTE);
20087 micros += min * Interval::MICROS_PER_MINUTE;
20088 int64_t sec = -(micros / Interval::MICROS_PER_SEC);
20089 micros += sec * Interval::MICROS_PER_SEC;
20090 micros = -micros;
20091
20092 if (hour < 10) {
20093 buffer[length++] = '0';
20094 }
20095 FormatSignedNumber(hour, buffer, length);
20096 buffer[length++] = ':';
20097 FormatTwoDigits(min, buffer, length);
20098 buffer[length++] = ':';
20099 FormatTwoDigits(sec, buffer, length);
20100 if (micros != 0) {
20101 buffer[length++] = '.';
20102 auto trailing_zeros = TimeToStringCast::FormatMicros(NumericCast<int32_t>(micros), buffer + length);
20103 length += NumericCast<idx_t>(6 - trailing_zeros);
20104 }
20105 } else if (length == 0) {
20106 // empty interval: default to 00:00:00
20107 memcpy(buffer, "00:00:00", 8); // NOLINT
20108 return 8;
20109 }
20110 return length;
20111 }
static softfloat min()
::int64_t int64_t
::int32_t int32_t
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
Here is the call graph for this function:

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