mirror of
https://github.com/NixOS/nix.git
synced 2025-12-12 20:11:03 +01:00
Table: Use std::vectors
This commit is contained in:
parent
863f6811e4
commit
ab6dcf2047
3 changed files with 6 additions and 10 deletions
|
|
@ -2,11 +2,9 @@
|
||||||
|
|
||||||
#include "nix/util/types.hh"
|
#include "nix/util/types.hh"
|
||||||
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
typedef std::list<Strings> Table;
|
typedef std::vector<std::vector<std::string>> Table;
|
||||||
|
|
||||||
void printTable(Table & table);
|
void printTable(Table & table);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,17 +16,15 @@ void printTable(Table & table)
|
||||||
|
|
||||||
for (auto & i : table) {
|
for (auto & i : table) {
|
||||||
assert(i.size() == nrColumns);
|
assert(i.size() == nrColumns);
|
||||||
Strings::iterator j;
|
size_t column = 0;
|
||||||
size_t column;
|
for (auto j = i.begin(); j != i.end(); ++j, ++column)
|
||||||
for (j = i.begin(), column = 0; j != i.end(); ++j, ++column)
|
|
||||||
if (j->size() > widths[column])
|
if (j->size() > widths[column])
|
||||||
widths[column] = j->size();
|
widths[column] = j->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto & i : table) {
|
for (auto & i : table) {
|
||||||
Strings::iterator j;
|
size_t column = 0;
|
||||||
size_t column;
|
for (auto j = i.begin(); j != i.end(); ++j, ++column) {
|
||||||
for (j = i.begin(), column = 0; j != i.end(); ++j, ++column) {
|
|
||||||
std::string s = *j;
|
std::string s = *j;
|
||||||
replace(s.begin(), s.end(), '\n', ' ');
|
replace(s.begin(), s.end(), '\n', ' ');
|
||||||
std::cout << s;
|
std::cout << s;
|
||||||
|
|
|
||||||
|
|
@ -1062,7 +1062,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* For table output. */
|
/* For table output. */
|
||||||
Strings columns;
|
std::vector<std::string> columns;
|
||||||
|
|
||||||
/* For XML output. */
|
/* For XML output. */
|
||||||
XMLAttrs attrs;
|
XMLAttrs attrs;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue