Example #1
0
static void
print_bindings_result_simple(rasqal_query_results *results, FILE* output,
                             int quiet)
{
  while(!rasqal_query_results_finished(results)) {
    int i;
    
    fputs("result: [", output);
    for(i = 0; i < rasqal_query_results_get_bindings_count(results); i++) {
      const unsigned char *name;
      rasqal_literal *value;
      
      name = rasqal_query_results_get_binding_name(results, i);
      value = rasqal_query_results_get_binding_value(results, i);
      
      if(i > 0)
        fputs(", ", output);
      
      fprintf(output, "%s=", name);
      
      if(value)
        rasqal_literal_print(value, output);
      else
        fputs("NULL", output);
    }
    fputs("]\n", output);
    
    rasqal_query_results_next(results);
  }

  if(!quiet)
    fprintf(stderr, "%s: Query returned %d results\n", program, 
            rasqal_query_results_get_count(results));
}
Example #2
0
static int
librdf_query_rasqal_results_get_count(librdf_query_results *query_results)
{
  librdf_query *query=query_results->query;
  librdf_query_rasqal_context *context=(librdf_query_rasqal_context*)query->context;
  return rasqal_query_results_get_count(context->results);
}
Example #3
0
void
rasqal_cmdline_print_bindings_results_simple(const char* program,
                                             rasqal_query_results *results,
                                             FILE* output, int quiet, int count)
{
  if(!quiet)
    fprintf(stderr, "%s: Query has a variable bindings result\n", program);

  while(!rasqal_query_results_finished(results)) {
    if(!count) {
      int i;

      fputs("row: [", output);
      for(i = 0; i < rasqal_query_results_get_bindings_count(results); i++) {
        const unsigned char *name;
        rasqal_literal *value;

        name = rasqal_query_results_get_binding_name(results, i);
        value = rasqal_query_results_get_binding_value(results, i);

        if(i > 0)
          fputs(", ", output);

        fprintf(output, "%s=", name);
        rasqal_literal_print(value, output);
      }
      fputs("]\n", output);
    }

    rasqal_query_results_next(results);
  }

  if(!quiet)
    fprintf(stderr, "%s: Query returned %d results\n", program,
            rasqal_query_results_get_count(results));
}