void TableBuilder::checkParams(const param_list& args) { if (args.size() == 0) throw TableBuilderError("Cannot build a table with no columns"); // TODO check if the number of columns in groups is correct size_t sum = 0; for (const auto& i : args.groups()) sum += i; if (sum != args.size()) throw TableBuilderError("Specified Layout does not match number of columns"); }
atable_ptr_t TableBuilder::build(param_list args, const bool compressed) { if (args.groups().size() == 0) args.appendGroup(args.size()); checkParams(args); std::vector<atable_ptr_t> base; auto offset = args.params().begin(); // For each group calculate the offset that is used to extract the columns for (size_t g = 0; g < args.groups().size(); ++g) { // Calculate the upper bound for the current layout auto end = offset; auto tmp = args.groups()[g]; while (tmp-- != 0) ++end; base.push_back(createTable(offset, end, compressed)); offset = end; } return std::move(std::make_shared<MutableVerticalTable>(base)); }