List tidy
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 11s

This commit is contained in:
Your Name
2025-05-24 17:00:43 +12:00
parent b3398582ca
commit 60907e5e02
18 changed files with 128 additions and 89 deletions

View File

@ -173,7 +173,7 @@ namespace localpath {
std::string remotepath::DROPSHELL_DIR() const
{
return server_config(mServer_name).get_user_dir(mUser);
return ServerConfig(mServer_name).get_user_dir(mUser);
}
std::string remotepath::services() const

View File

@ -147,6 +147,27 @@ void tableprint::set_title(const std::string title) {
this->title = title;
}
// gives the columns to sort by, starting at 0.
void tableprint::sort(std::vector<int> sort_columns)
{
// Skip header row and sort remaining rows
if (rows.size() <= 1) return; // Only header or empty table
// Create a custom comparator that compares rows based on the specified columns
auto comparator = [this, &sort_columns](const std::vector<std::string>& a, const std::vector<std::string>& b) {
for (int col : sort_columns) {
if (col >= 0 && col < a.size() && col < b.size()) {
int cmp = a[col].compare(b[col]);
if (cmp != 0) return cmp < 0;
}
}
return false; // Equal rows maintain original order
};
// Sort rows starting from index 1 (after header)
std::sort(rows.begin() + 1, rows.end(), comparator);
}
void tableprint::add_row(const std::vector<std::string>& row) {
std::vector<std::string> trimmed_row;
for (const auto& cell : row) {

View File

@ -16,6 +16,7 @@ class tableprint {
void add_row(const std::vector<std::string>& row);
void print();
void set_title(const std::string title);
void sort(std::vector<int> sort_columns);
private:
std::vector<std::vector<std::string>> rows;
std::string title;