1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-12 12:01:05 +01:00

Table: Use std::vectors

This commit is contained in:
Eelco Dolstra 2025-12-01 20:12:15 +01:00
parent 863f6811e4
commit ab6dcf2047
3 changed files with 6 additions and 10 deletions

View file

@ -2,11 +2,9 @@
#include "nix/util/types.hh"
#include <list>
namespace nix {
typedef std::list<Strings> Table;
typedef std::vector<std::vector<std::string>> Table;
void printTable(Table & table);

View file

@ -16,17 +16,15 @@ void printTable(Table & table)
for (auto & i : table) {
assert(i.size() == nrColumns);
Strings::iterator j;
size_t column;
for (j = i.begin(), column = 0; j != i.end(); ++j, ++column)
size_t column = 0;
for (auto j = i.begin(); j != i.end(); ++j, ++column)
if (j->size() > widths[column])
widths[column] = j->size();
}
for (auto & i : table) {
Strings::iterator j;
size_t column;
for (j = i.begin(), column = 0; j != i.end(); ++j, ++column) {
size_t column = 0;
for (auto j = i.begin(); j != i.end(); ++j, ++column) {
std::string s = *j;
replace(s.begin(), s.end(), '\n', ' ');
std::cout << s;

View file

@ -1062,7 +1062,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
continue;
/* For table output. */
Strings columns;
std::vector<std::string> columns;
/* For XML output. */
XMLAttrs attrs;