JULEA
Typedefs | Enumerations | Functions
jdb-selector.h File Reference
#include <glib.h>
#include <db/jdb-schema.h>
#include <db/jdb-type.h>

Go to the source code of this file.

Typedefs

typedef enum JDBSelectorMode JDBSelectorMode
 
typedef enum JDBSelectorOperator JDBSelectorOperator
 
typedef struct JDBSelector JDBSelector
 

Enumerations

enum  JDBSelectorMode { J_DB_SELECTOR_MODE_AND , J_DB_SELECTOR_MODE_OR }
 
enum  JDBSelectorOperator {
  J_DB_SELECTOR_OPERATOR_LT , J_DB_SELECTOR_OPERATOR_LE , J_DB_SELECTOR_OPERATOR_GT , J_DB_SELECTOR_OPERATOR_GE ,
  J_DB_SELECTOR_OPERATOR_EQ , J_DB_SELECTOR_OPERATOR_NE
}
 

Functions

G_END_DECLS G_BEGIN_DECLS JDBSelectorj_db_selector_new (JDBSchema *schema, JDBSelectorMode mode, GError **error)
 
JDBSelectorj_db_selector_ref (JDBSelector *selector)
 
void j_db_selector_unref (JDBSelector *selector)
 
gboolean j_db_selector_add_field (JDBSelector *selector, gchar const *name, JDBSelectorOperator operator_, gconstpointer value, guint64 length, GError **error)
 
gboolean j_db_selector_add_selector (JDBSelector *selector, JDBSelector *sub_selector, GError **error)
 Add a second selector as sub selector. More...
 
gboolean j_db_selector_add_join (JDBSelector *selector, gchar const *selector_field, JDBSelector *sub_selector, gchar const *sub_selector_field, GError **error)
 

Typedef Documentation

◆ JDBSelector

typedef struct JDBSelector JDBSelector

◆ JDBSelectorMode

◆ JDBSelectorOperator

Enumeration Type Documentation

◆ JDBSelectorMode

Enumerator
J_DB_SELECTOR_MODE_AND 
J_DB_SELECTOR_MODE_OR 

◆ JDBSelectorOperator

Enumerator
J_DB_SELECTOR_OPERATOR_LT 
J_DB_SELECTOR_OPERATOR_LE 
J_DB_SELECTOR_OPERATOR_GT 
J_DB_SELECTOR_OPERATOR_GE 
J_DB_SELECTOR_OPERATOR_EQ 
J_DB_SELECTOR_OPERATOR_NE 

Function Documentation

◆ j_db_selector_add_field()

gboolean j_db_selector_add_field ( JDBSelector selector,
gchar const *  name,
JDBSelectorOperator  operator_,
gconstpointer  value,
guint64  length,
GError **  error 
)

add a search field to the selector.

Parameters
[in]selectorto add a search field to
[in]namethe name of the field to compare
[in]operator_the operator to use to compare the stored value with the given value
[in]valuethe value to compare with
[in]lengththe length of the value. Only used if value is binary
[out]errorA GError pointer. Will point to a GError object in case of failure.
Precondition
selector != NULL
name != NULL
name must exist in the schema
operator must be applyable to the defined type of the variable
selector including all previously added sub_selectors must not contain more than 500 search fields after applying this operation
Postcondition
the value may be freed or modified by the caller immediately after calling this function
Returns
TRUE on success, FALSE otherwise

◆ j_db_selector_add_join()

gboolean j_db_selector_add_join ( JDBSelector selector,
gchar const *  selector_field,
JDBSelector sub_selector,
gchar const *  sub_selector_field,
GError **  error 
)

Add a JOIN to the primary selector using the schema from the sub selector.

This function will join both schemas using the given fields and also copy previous add_join and add_selector data from the secondary selector to the primary selector. The given selectors must represent different primary schemas in the same namepsace.

Parameters
[in]selectorPrimary selector.
[in]selector_fieldName of a field in the primary schema of the selector.
[in]sub_selectorThe second selector to be used in the join.
[in]sub_selector_fieldName of a field in the primary schema of the sub_selector.
Precondition
selector != NULL
sub_selector != NULL
selector != sub_selector
selector including all previously added sub_selectors must not contain more than 500 search fields after applying this operation
Returns
TRUE on success, FALSE otherwise

◆ j_db_selector_add_selector()

gboolean j_db_selector_add_selector ( JDBSelector selector,
JDBSelector sub_selector,
GError **  error 
)

Add a second selector as sub selector.

Using this function it is possible to build nested expressions (e.g. "A and B and (C or D)" where "C or D" is given by a sub selector). The namespace and schema of both selectors must be the same.

Parameters
[in]selectorprimary selector
[in]sub_selectorsub selector
[out]errorA GError pointer. Will point to a GError object in case of failure.
Precondition
selector != NULL
sub_selector != NULL
selector != sub_selector
selector including all previously added sub_selectors must not contain more than 500 search fields after applying this operation
Returns
TRUE on success, FALSE otherwise

◆ j_db_selector_new()

G_END_DECLS G_BEGIN_DECLS JDBSelector* j_db_selector_new ( JDBSchema schema,
JDBSelectorMode  mode,
GError **  error 
)

Allocates a new selector.

Parameters
[in]schemaThe schema defines the structure of the selector
[in]modethe more of the selector
[out]errorA GError pointer. Will point to a GError object in case of failure.
Precondition
schema != NULL
schema is initialized
Returns
the new selector or NULL on failure

◆ j_db_selector_ref()

JDBSelector* j_db_selector_ref ( JDBSelector selector)

Increase the ref_count of the given selector.

Parameters
[in]selectorthe selector to increase the ref_count
Precondition
selector != NULL
Returns
the selector or NULL on failure

◆ j_db_selector_unref()

void j_db_selector_unref ( JDBSelector selector)

Decrease the ref_count of the given selector - and automatically call free if ref_count is 0. This is a noop if selector == NULL.

Parameters
[in]selectorthe selector to decrease the ref_count