28 lines
735 B
C++
28 lines
735 B
C++
|
|
#include "table.h"
|
|
|
|
Table::Table(const std::string name, const std::vector<ColDefNode> columns) {
|
|
m_name = name;
|
|
m_col_defs = columns;
|
|
m_rows.clear();
|
|
}
|
|
|
|
ColDefNode Table::get_column_def(const std::string col_name) {
|
|
auto name_cmp = [col_name](ColDefNode cd){ return cd.name == col_name; };
|
|
auto col_def = std::find_if(begin(m_col_defs), end(m_col_defs), name_cmp );
|
|
if (col_def != std::end(m_col_defs)) {
|
|
return *col_def;
|
|
} else {
|
|
// TODO throw exception
|
|
}
|
|
}
|
|
|
|
void Table::print() {
|
|
std::cout << "** " << m_name << " **" << std::endl;
|
|
for(auto row : m_rows) {
|
|
for( auto col : row) {
|
|
std::cout << col << ",";
|
|
}
|
|
std::cout << std::endl;
|
|
}
|
|
} |