further camelcase fixing
[rrq/rrqmisc.git] / vector / Query.c
index 54d413b4809fb5dcc3d2d980f346c6f827aa7718..68efa3fb73f1d568bf1aa58a7fdb9cf5a0bb1f4c 100644 (file)
@@ -4,7 +4,7 @@
 #include <Query.h>
 #include <BindingTable.h>
 
-enum next_state {
+enum NextState {
     /**
      * This state tells the "next" function that it should capture the
      * incoming BindingTable state and provide the initial Binding of
@@ -24,30 +24,28 @@ enum next_state {
     restore
 };
 
-//enum compound_state { reset, started, ended };
-
 /**
- * A struct query_callbacks record defines the callbacks for a
- * specific query type.
+ * A struct Query_callbacks record defines the callbacks for a
+ * specific Query type.
  */
-struct query_callbacks {
+struct QueryCallbacks {
     /**
-     * \brief Callback function to reclaim the query memory for a
-     * given query.
+     * \brief Callback function to reclaim the Query memory for a
+     * given Query.
      *
-     * \param this is the specific \ref query concerned.
+     * \param this is the specific \ref Query concerned.
      *
      * Ground queries recalim their own state memory. Composite
      * queries first propagate the reclaim call to its components, and
      * thereafter reclaim their local state memory.
      */
-    void (*reclaim)(query *this);
-    void (*start)(query *this,BindingTable *bt,enum next_state s);
+    void (*reclaim)(Query *this);
+    void (*start)(Query *this,BindingTable *bt,enum NextState s);
     /**
      * \brief Callback function to update the Binding table with a
      * succession of alternative bindings.
      *
-     * \param this is the specific \ref query concerned.
+     * \param this is the specific \ref Query concerned.
      *
      * \param bt is the Binding table to set bindings in.
      *
@@ -56,7 +54,7 @@ struct query_callbacks {
      * \returns 1 if a new Binding is provided and 0 otherwise.
      *
      * This function is called repeatedly for successively obtaining
-     * the alternative bindings that satisfy the query. The "initial"
+     * the alternative bindings that satisfy the Query. The "initial"
      * state sub-command tells the function to capture the incoming
      * BindingTable state so that the function can later restore it
      * upon the "restore" sub-command. Upon the "initial" command, the
@@ -67,12 +65,12 @@ struct query_callbacks {
      * return 1 after any successful Binding setup, and return 0 when
      * it cannot setup any (more) Binding.
      */
-    int (*next)(query *this,BindingTable *bt,enum next_state state);
+    int (*next)(Query *this,BindingTable *bt,enum NextState state);
 };
 
 /* ==================== AssignmentQuery ==================== */
 typedef struct {
-    struct query_callbacks *def;
+    struct QueryCallbacks *def;
     int arity;
     tuple *names;
     tuple *values;
@@ -80,7 +78,7 @@ typedef struct {
 } AssignmentQuery;
 
 // Release any memory.
-static void AssignmentQuery_reclaim(query *this) {
+static void AssignmentQuery_reclaim(Query *this) {
     AssignmentQuery *q = (AssignmentQuery*) this;
     free( q->saved );
     free( this );
@@ -113,7 +111,7 @@ static void AssignmentQuery_assign(
 // Make names have given values and return 1. If any name has a
 // different value then return 0. Values are strings.
 static int AssignmentQuery_next(
-    query *this,BindingTable *bt,enum next_state state) {
+    Query *this,BindingTable *bt,enum NextState state) {
     AssignmentQuery *q = (AssignmentQuery*) this;
     switch ( state ) {
     case initial:
@@ -140,16 +138,16 @@ static int AssignmentQuery_next(
     return 0;
 }
 
-static struct query_callbacks AssignmentQuery_def = {
+static struct QueryCallbacks AssignmentQuery_def = {
     .reclaim = AssignmentQuery_reclaim,
     .next = AssignmentQuery_next
 };
 
 /**
- * Return a query object representing an assignment of one or more
+ * Return a Query object representing an assignment of one or more
  * variables.
  */
-query *query_assign(int arity,tuple *names,tuple *values) {
+Query *Query_assign(int arity,tuple *names,tuple *values) {
     AssignmentQuery *q = (AssignmentQuery*)
        malloc( sizeof( AssignmentQuery ) );
     (*q) = (AssignmentQuery) {
@@ -159,18 +157,18 @@ query *query_assign(int arity,tuple *names,tuple *values) {
        .values = values,
        .saved = 0
     };
-    return (query*) q;
+    return (Query*) q;
 }
 
 /* ==================== conjunction ==================== */
 typedef struct {
-    struct query_callbacks *def;
+    struct QueryCallbacks *def;
     int active;
     int size;
-    query **conjuncts;
+    Query **conjuncts;
 } ConjunctionQuery;
 
-static void ConjunctionQuery_reclaim(query *this) {
+static void ConjunctionQuery_reclaim(Query *this) {
     ConjunctionQuery *q = (ConjunctionQuery*) this;
     int i;
     for ( i = 0; i < q->size; i++ ) {
@@ -181,11 +179,11 @@ static void ConjunctionQuery_reclaim(query *this) {
 }
 
 static int ConjunctionQuery_next(
-    query *this,BindingTable *bt,enum next_state state)
+    Query *this,BindingTable *bt,enum NextState state)
 {
     ConjunctionQuery *q = (ConjunctionQuery*) this;
     int i = q->size - 1;
-    enum next_state s = subsequent;
+    enum NextState s = subsequent;
     switch ( state ) {
     case initial:
        q->active = 1;
@@ -218,12 +216,12 @@ static int ConjunctionQuery_next(
     return 0;
 }
 
-static struct query_callbacks ConjunctionQuery_def = {
+static struct QueryCallbacks ConjunctionQuery_def = {
     .reclaim = ConjunctionQuery_reclaim,
     .next = ConjunctionQuery_next
 };
 
-query *query_and(int n,...) {
+Query *Query_and(int n,...) {
     va_list args;
     ConjunctionQuery *q = (ConjunctionQuery *)
        malloc( sizeof( ConjunctionQuery ) );
@@ -231,26 +229,26 @@ query *query_and(int n,...) {
        .def = &ConjunctionQuery_def,
        .active = 0,
        .size = n,
-       .conjuncts = (query**) malloc( n * sizeof( query* ) )
+       .conjuncts = (Query**) malloc( n * sizeof( Query* ) )
     };
     int i;
     va_start( args, n );
     for ( i = 0; i < n; i++ ) {
-       q->conjuncts[i] = va_arg( args, query* );
+       q->conjuncts[i] = va_arg( args, Query* );
     }
     va_end( args );
-    return (query*) q;
+    return (Query*) q;
 }
 
 /* ==================== disjunction ==================== */
 typedef struct {
-    struct query_callbacks *def;
+    struct QueryCallbacks *def;
     int index;
     int size;
-    query **disjuncts;
+    Query **disjuncts;
 } DisjunctionQuery;
 
-static void DisjunctionQuery_reclaim(query *this) {
+static void DisjunctionQuery_reclaim(Query *this) {
     DisjunctionQuery *q = (DisjunctionQuery*) this;
     int i;
     for ( i = 0; i < q->size; i++ ) {
@@ -261,10 +259,10 @@ static void DisjunctionQuery_reclaim(query *this) {
 }
 
 static int DisjunctionQuery_next(
-    query *this,BindingTable *bt,enum next_state state) {
+    Query *this,BindingTable *bt,enum NextState state) {
     DisjunctionQuery *q = (DisjunctionQuery*) this;
     int i = q->index;
-    enum next_state s = subsequent;
+    enum NextState s = subsequent;
     switch ( state ) {
     case initial:
        i = 0;
@@ -290,12 +288,12 @@ static int DisjunctionQuery_next(
     return 0;
 }
 
-static struct query_callbacks DisjunctionQuery_def = {
+static struct QueryCallbacks DisjunctionQuery_def = {
     .reclaim = DisjunctionQuery_reclaim,
     .next = DisjunctionQuery_next,
 };
 
-query *query_or(int n,...) {
+Query *Query_or(int n,...) {
     va_list args;
     DisjunctionQuery *q = (DisjunctionQuery *)
        malloc( sizeof( DisjunctionQuery ) );
@@ -303,20 +301,20 @@ query *query_or(int n,...) {
        .def = &DisjunctionQuery_def,
        .index = -1,
        .size = n,
-       .disjuncts = (query**) malloc( n * sizeof( query* ) ),
+       .disjuncts = (Query**) malloc( n * sizeof( Query* ) ),
     };
     int i;
     va_start( args, n );
     for ( i = 0; i < n; i++ ) {
-       q->disjuncts[i] = va_arg( args, query* );
+       q->disjuncts[i] = va_arg( args, Query* );
     }
     va_end( args );
-    return (query*) q;
+    return (Query*) q;
 }
 
 /* ==================== Relation access ==================== */
 typedef struct {
-    struct query_callbacks *def;
+    struct QueryCallbacks *def;
     Relation *rel;
     VectorIndex index;
     tuple *names;
@@ -325,7 +323,7 @@ typedef struct {
 } RelationQuery;
 
 // Release any memory.
-static void RelationQuery_reclaim(query *this) {
+static void RelationQuery_reclaim(Query *this) {
     RelationQuery *q = (RelationQuery*) this;
     free( q->saved );
     free( this );
@@ -334,7 +332,7 @@ static void RelationQuery_reclaim(query *this) {
 // Make names have given values and return 1. If any name has a
 // different value then return 0. Values are strings.
 static int RelationQuery_next(
-    query *this,BindingTable *bt,enum next_state state) {
+    Query *this,BindingTable *bt,enum NextState state) {
     RelationQuery *q = (RelationQuery*) this;
     int arity = ((TupleSchema*) q->rel->content.type)->arity;
     VectorIndex index = q->index + 1;
@@ -349,7 +347,7 @@ static int RelationQuery_next(
        // Fall through
     case subsequent:
        for ( ; index < q->rel->content.table.size; index++ ) {
-           tuple *values = relation_next( q->rel, &index, q->values );
+           tuple *values = Relation_next( q->rel, &index, q->values );
            if ( values ) {
                q->index = index;
                AssignmentQuery_assign( bt, arity, q->names, values, 1 );
@@ -367,16 +365,16 @@ static int RelationQuery_next(
     return 0;
 }
 
-static struct query_callbacks RelationQuery_def = {
+static struct QueryCallbacks RelationQuery_def = {
     .reclaim = RelationQuery_reclaim,
     .next = RelationQuery_next
 };
 
 /**
- * Return a query object representing an Relation of one or more
+ * Return a Query object representing an Relation of one or more
  * variables.
  */
-query *query_Relation(Relation *r,tuple *names,tuple *values) {
+Query *Query_Relation(Relation *r,tuple *names,tuple *values) {
     RelationQuery *q = (RelationQuery*) malloc( sizeof( RelationQuery ) );
     (*q) = (RelationQuery) {
        .def = &RelationQuery_def,
@@ -385,5 +383,5 @@ query *query_Relation(Relation *r,tuple *names,tuple *values) {
        .values = values,
        .saved = 0
     };
-    return (query*) q;
+    return (Query*) q;
 }