Beispiel #1
0
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);
  }
Beispiel #2
0
Datei: shell.cpp Projekt: xkp/XKP
void dsl_shell::add_parameters(param_list& pl, dsl& info, XSSContext ctx)
  {
    str callback      = variant_cast<str>(ctx->resolve("#wax_callback"), str());
    
    pl.add("callback", callback);
    pl.add("error_handler", ctx->resolve("#wax_error_handler"));

    param_list options;
    load_parameter("cwd", ctx, info.params, options);
    load_parameter("env", ctx, info.params, options);

    std::ostringstream oss;
    oss << "{";
    bool first = true;
    for(size_t i = 0; i < options.size(); i++)
      {
        if (first) first = false;
        else oss << ", ";

        str pname = options.get_name(i);
        str pvalue = variant_cast<str>(options.get(i), str("null"));

        oss << pname << " : " << pvalue;
      }

    oss << "}";
    pl.add("options", oss.str());
  }
Beispiel #3
0
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");
}
Beispiel #4
0
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));
}