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::StrTimeFormat Struct Reference
Inheritance diagram for duckdb::StrTimeFormat:
Collaboration diagram for duckdb::StrTimeFormat:

Public Member Functions

bool HasFormatSpecifier (StrTimeSpecifier s) const
DUCKDB_API bool Empty () const
 If the string format is empty.

Static Public Member Functions

static DUCKDB_API string ParseFormatSpecifier (const string &format_string, StrTimeFormat &format)

Public Attributes

string format_specifier
 The full format specifier, for error messages.

Protected Member Functions

void AddLiteral (string literal)
virtual DUCKDB_API void AddFormatSpecifier (string preceding_literal, StrTimeSpecifier specifier)

Protected Attributes

vector< StrTimeSpecifier > specifiers
 The format specifiers.
vector< string > literals
 The literals that appear in between the format specifiers The following must hold: literals.size() = specifiers.size() + 1 Format is literals[0], specifiers[0], literals[1], ..., specifiers[n - 1], literals[n].
idx_t constant_size = 0
 The constant size that appears in the format string.
vector< int > numeric_width
 The max numeric width of the specifier (if it is parsed as a number), or -1 if it is not a number.

Constructor & Destructor Documentation

◆ ~StrTimeFormat()

virtual duckdb::StrTimeFormat::~StrTimeFormat ( )
inlinevirtual
46086 {
46087 }

Member Function Documentation

◆ ParseFormatSpecifier()

string duckdb::StrTimeFormat::ParseFormatSpecifier ( const string & format_string,
StrTimeFormat & format )
static
230668 {
230669 if (format_string.empty()) {
230670 return "Empty format string";
230671 }
230672 format.format_specifier = format_string;
230673 format.specifiers.clear();
230674 format.literals.clear();
230675 format.numeric_width.clear();
230676 format.constant_size = 0;
230677 idx_t pos = 0;
230678 string current_literal;
230679 for (idx_t i = 0; i < format_string.size(); i++) {
230680 if (format_string[i] == '%') {
230681 if (i + 1 == format_string.size()) {
230682 return "Trailing format character %";
230683 }
230684 if (i > pos) {
230685 // push the previous string to the current literal
230686 current_literal += format_string.substr(pos, i - pos);
230687 }
230688 char format_char = format_string[++i];
230689 if (format_char == '%') {
230690 // special case: %%
230691 // set the pos for the next literal and continue
230692 pos = i;
230693 continue;
230694 }
230695 StrTimeSpecifier specifier;
230696 if (format_char == '-' && i + 1 < format_string.size()) {
230697 format_char = format_string[++i];
230698 switch (format_char) {
230699 case 'd':
230700 specifier = StrTimeSpecifier::DAY_OF_MONTH;
230701 break;
230702 case 'm':
230703 specifier = StrTimeSpecifier::MONTH_DECIMAL;
230704 break;
230705 case 'y':
230706 specifier = StrTimeSpecifier::YEAR_WITHOUT_CENTURY;
230707 break;
230708 case 'H':
230709 specifier = StrTimeSpecifier::HOUR_24_DECIMAL;
230710 break;
230711 case 'I':
230712 specifier = StrTimeSpecifier::HOUR_12_DECIMAL;
230713 break;
230714 case 'M':
230715 specifier = StrTimeSpecifier::MINUTE_DECIMAL;
230716 break;
230717 case 'S':
230718 specifier = StrTimeSpecifier::SECOND_DECIMAL;
230719 break;
230720 case 'j':
230721 specifier = StrTimeSpecifier::DAY_OF_YEAR_DECIMAL;
230722 break;
230723 default:
230724 return "Unrecognized format for strftime/strptime: %-" + string(1, format_char);
230725 }
230726 } else {
230727 switch (format_char) {
230728 case 'a':
230729 specifier = StrTimeSpecifier::ABBREVIATED_WEEKDAY_NAME;
230730 break;
230731 case 'A':
230732 specifier = StrTimeSpecifier::FULL_WEEKDAY_NAME;
230733 break;
230734 case 'w':
230735 specifier = StrTimeSpecifier::WEEKDAY_DECIMAL;
230736 break;
230737 case 'u':
230738 specifier = StrTimeSpecifier::WEEKDAY_ISO;
230739 break;
230740 case 'd':
230741 specifier = StrTimeSpecifier::DAY_OF_MONTH_PADDED;
230742 break;
230743 case 'h':
230744 case 'b':
230745 specifier = StrTimeSpecifier::ABBREVIATED_MONTH_NAME;
230746 break;
230747 case 'B':
230748 specifier = StrTimeSpecifier::FULL_MONTH_NAME;
230749 break;
230750 case 'm':
230751 specifier = StrTimeSpecifier::MONTH_DECIMAL_PADDED;
230752 break;
230753 case 'y':
230754 specifier = StrTimeSpecifier::YEAR_WITHOUT_CENTURY_PADDED;
230755 break;
230756 case 'Y':
230757 specifier = StrTimeSpecifier::YEAR_DECIMAL;
230758 break;
230759 case 'G':
230760 specifier = StrTimeSpecifier::YEAR_ISO;
230761 break;
230762 case 'H':
230763 specifier = StrTimeSpecifier::HOUR_24_PADDED;
230764 break;
230765 case 'I':
230766 specifier = StrTimeSpecifier::HOUR_12_PADDED;
230767 break;
230768 case 'p':
230769 specifier = StrTimeSpecifier::AM_PM;
230770 break;
230771 case 'M':
230772 specifier = StrTimeSpecifier::MINUTE_PADDED;
230773 break;
230774 case 'S':
230775 specifier = StrTimeSpecifier::SECOND_PADDED;
230776 break;
230777 case 'n':
230778 specifier = StrTimeSpecifier::NANOSECOND_PADDED;
230779 break;
230780 case 'f':
230781 specifier = StrTimeSpecifier::MICROSECOND_PADDED;
230782 break;
230783 case 'g':
230784 specifier = StrTimeSpecifier::MILLISECOND_PADDED;
230785 break;
230786 case 'z':
230787 specifier = StrTimeSpecifier::UTC_OFFSET;
230788 break;
230789 case 'Z':
230790 specifier = StrTimeSpecifier::TZ_NAME;
230791 break;
230792 case 'j':
230793 specifier = StrTimeSpecifier::DAY_OF_YEAR_PADDED;
230794 break;
230795 case 'U':
230796 specifier = StrTimeSpecifier::WEEK_NUMBER_PADDED_SUN_FIRST;
230797 break;
230798 case 'W':
230799 specifier = StrTimeSpecifier::WEEK_NUMBER_PADDED_MON_FIRST;
230800 break;
230801 case 'V':
230802 specifier = StrTimeSpecifier::WEEK_NUMBER_ISO;
230803 break;
230804 case 'c':
230805 case 'x':
230806 case 'X':
230807 case 'T': {
230808 string subformat;
230809 if (format_char == 'c') {
230810 // %c: Locale’s appropriate date and time representation.
230811 // we push the ISO timestamp representation here
230812 subformat = "%Y-%m-%d %H:%M:%S";
230813 } else if (format_char == 'x') {
230814 // %x - Locale’s appropriate date representation.
230815 // we push the ISO date format here
230816 subformat = "%Y-%m-%d";
230817 } else if (format_char == 'X' || format_char == 'T') {
230818 // %X - Locale’s appropriate time representation.
230819 // we push the ISO time format here
230820 subformat = "%H:%M:%S";
230821 }
230822 // parse the subformat in a separate format specifier
230823 StrfTimeFormat locale_format;
230824 string error = StrTimeFormat::ParseFormatSpecifier(subformat, locale_format);
230825 if (!error.empty()) {
230826 throw InternalException("Failed to bind sub-format specifier \"%s\": %s", subformat, error);
230827 }
230828 // add the previous literal to the first literal of the subformat
230829 locale_format.literals[0] = std::move(current_literal) + locale_format.literals[0];
230830 current_literal = "";
230831 // now push the subformat into the current format specifier
230832 for (idx_t i = 0; i < locale_format.specifiers.size(); i++) {
230833 format.AddFormatSpecifier(std::move(locale_format.literals[i]), locale_format.specifiers[i]);
230834 }
230835 pos = i + 1;
230836 continue;
230837 }
230838 default:
230839 return "Unrecognized format for strftime/strptime: %" + string(1, format_char);
230840 }
230841 }
230842 format.AddFormatSpecifier(std::move(current_literal), specifier);
230843 current_literal = "";
230844 pos = i + 1;
230845 }
230846 }
230847 // add the final literal
230848 if (pos < format_string.size()) {
230849 current_literal += format_string.substr(pos, format_string.size() - pos);
230850 }
230851 format.AddLiteral(std::move(current_literal));
230852 return string();
230853}
std::basic_string< Char > format(const S &format_str, Args &&... args)
Definition duckdb.cpp:16295
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ HasFormatSpecifier()

bool duckdb::StrTimeFormat::HasFormatSpecifier ( StrTimeSpecifier s) const
inline
46091 {
46092 return std::find(specifiers.begin(), specifiers.end(), s) != specifiers.end();
46093 }
vector< StrTimeSpecifier > specifiers
The format specifiers.
Definition duckdb.hpp:46102

◆ Empty()

bool duckdb::StrTimeFormat::Empty ( ) const

If the string format is empty.

231637 {
231638 return format_specifier.empty();
231639}
string format_specifier
The full format specifier, for error messages.
Definition duckdb.hpp:46098

◆ AddLiteral()

void duckdb::StrTimeFormat::AddLiteral ( string literal)
protected
230244 {
230245 constant_size += literal.size();
230246 literals.push_back(std::move(literal));
230247}
idx_t constant_size
The constant size that appears in the format string.
Definition duckdb.hpp:46108
vector< string > literals
The literals that appear in between the format specifiers The following must hold: literals....
Definition duckdb.hpp:46106

◆ AddFormatSpecifier()

void duckdb::StrTimeFormat::AddFormatSpecifier ( string preceding_literal,
StrTimeSpecifier specifier )
protectedvirtual
230249 {
230250 AddLiteral(std::move(preceding_literal));
230251 specifiers.push_back(specifier);
230252}

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