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"); }
void print_error(param_list data, XSSProject project) { str id = variant_cast<str>(data.get("id"), ""); str desc = variant_cast<str>(data.get("desc"), ""); std::cout << "Error [" << id << "] " << desc << '\n'; for(size_t i = 0; i < data.size(); i++) { str name = data.get_name(i); if (name == "id" || name == "desc") continue; variant value = data.get(i); str value_str; try { value_str = variant_cast<str>(value, str()); } catch(type_mismatch) { value_str = "[cannot-resolve]"; } std::cout << name << " = " << value_str << '\n'; } std::cout << "\nFile:" << project->top_file() << '\n'; std::cout << "\nLast Rendererd: \n\n" << project->last_rendered(5); }
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)); }