Beispiel #1
0
int
rasqal_rowsource_set_requirements(rasqal_rowsource* rowsource, unsigned int flags)
{
  return rasqal_rowsource_visit(rowsource, 
                                rasqal_rowsource_visitor_set_requirements,
                                &flags);
}
Beispiel #2
0
/**
 * rasqal_rowsource_visit:
 * @node: #rasqal_rowsource row source
 * @fn: pointer to function to apply that takes user data and rowsource parameters
 * @user_data: user data for applied function 
 * 
 * Visit a user function over a #rasqal_rowsource
 *
 * If the user function @fn returns 0, the visit is truncated.
 *
 * Return value: non-0 if the visit was truncated or on failure.
 **/
int
rasqal_rowsource_visit(rasqal_rowsource* rowsource,
                       rasqal_rowsource_visit_fn fn,
                       void *user_data)
{
  int result;
  int offset;
  rasqal_rowsource* inner_rs;
  
  if(!rowsource || !fn)
    return 1;

  result = fn(rowsource, user_data);
  /* end if failed */
  if(result < 0)
    return result;

  /* Do not recurse if handled */
  if(result > 0)
    return 0;

  for(offset = 0;
      (inner_rs = rasqal_rowsource_get_inner_rowsource(rowsource, offset));
      offset++) {
    result = rasqal_rowsource_visit(inner_rs, fn, user_data);
    /* end if failed */
    if(result < 0)
      return result;
  }

  return 0;
}
Beispiel #3
0
int
rasqal_rowsource_set_origin(rasqal_rowsource* rowsource,
                            rasqal_literal *literal)
{
    rasqal_rowsource_visit(rowsource,
                           rasqal_rowsource_visitor_set_origin,
                           literal);

    return 0;
}
Beispiel #4
0
/**
 * rasqal_rowsource_visit:
 * @node: #rasqal_rowsource row source
 * @fn: pointer to function to apply that takes user data and rowsource parameters
 * @user_data: user data for applied function
 *
 * Visit a user function over a #rasqal_rowsource
 *
 * If the user function @fn returns 0, the visit is truncated.
 *
 * Return value: 0 if the visit was truncated.
 **/
int
rasqal_rowsource_visit(rasqal_rowsource* rowsource,
                       rasqal_rowsource_visit_fn fn,
                       void *user_data)
{
    int result;
    int offset;
    rasqal_rowsource* inner_rs;

    result = fn(rowsource, user_data);
    if(result)
        return result;

    for(offset = 0;
            (inner_rs = rasqal_rowsource_get_inner_rowsource(rowsource, offset));
            offset++) {
        result = rasqal_rowsource_visit(inner_rs, fn, user_data);
        if(result)
            return result;
    }

    return 0;
}