23 #include "pedigree/native/config/Config.h" 27 std::cout <<
"config: Query and update the Pedigree configuration manager." 29 <<
"usage: config <sql>" << std::endl;
32 int main(
int argc,
char **argv)
40 const char *sql = argv[1];
47 std::cerr <<
"Unable to query" << std::endl;
54 std::cerr <<
"error: " << pResult->
errorMessage() << std::endl;
62 std::cout <<
"Ø" << std::endl;
67 size_t cols = pResult->
cols();
68 size_t *col_lens =
new size_t[cols];
71 for (
size_t col = 0; col < cols; col++)
74 std::cout <<
" " << colName;
75 col_lens[col] = colName.length();
76 while (col_lens[col] < 15)
83 std::cout << std::endl;
86 for (
size_t col = 0; col < cols; col++)
89 for (
size_t i = 0; i < col_lens[col]; i++)
93 std::cout << std::endl;
96 for (
size_t row = 0; row < pResult->
rows(); row++)
98 for (
size_t col = 0; col < cols; col++)
100 std::string value = pResult->
getStr(row, col);
101 std::cout <<
" " << value <<
"\t";
102 for (
size_t i = value.length(); i < col_lens[col]; i++)
106 std::cout << std::endl;
size_t cols()
Returns the number of columns.
size_t rows()
Returns the number of rows.
std::string getColumnName(size_t col, size_t buffSz=256)
Returns the name of the col'th column.
std::string getStr(size_t row, size_t col, size_t buffSz=256)
Returns the value in column 'col' of the result, in string form.
Result * query(const char *sql)
bool succeeded()
Returns true if the result is valid, false if there was an error.
std::string errorMessage(size_t buffSz=256)
Returns the error message.