db_clause.h File Reference
`#include "db_value.h"`

Go to the source code of this file.

## Data Structures

struct | db_clause
struct | db_clause_list

## Macros

#define | DB_CLAUSE_EQ DB_CLAUSE_EQUAL
#define | DB_CLAUSE_NE DB_CLAUSE_NOT_EQUAL
#define | DB_CLAUSE_LT DB_CLAUSE_LESS_THEN
#define | DB_CLAUSE_LE DB_CLAUSE_LESS_OR_EQUAL
#define | DB_CLAUSE_GE DB_CLAUSE_GREATER_OR_EQUAL
#define | DB_CLAUSE_GT DB_CLAUSE_GREATER_THEN
#define | DB_CLAUSE_OP_AND DB_CLAUSE_OPERATOR_AND
#define | DB_CLAUSE_OP_OR DB_CLAUSE_OPERATOR_OR

## Typedefs

typedef struct db_clause | db_clause_t
typedef struct db_clause_list | db_clause_list_t

## Enumerations

enum | db_clause_type_t { DB_CLAUSE_UNKNOWN, DB_CLAUSE_EQUAL, DB_CLAUSE_NOT_EQUAL, DB_CLAUSE_LESS_THEN, DB_CLAUSE_LESS_OR_EQUAL, DB_CLAUSE_GREATER_OR_EQUAL, DB_CLAUSE_GREATER_THEN, DB_CLAUSE_IS_NULL, DB_CLAUSE_IS_NOT_NULL, DB_CLAUSE_NESTED }
enum | db_clause_operator_t { DB_CLAUSE_OPERATOR_UNKNOWN, DB_CLAUSE_OPERATOR_AND, DB_CLAUSE_OPERATOR_OR }

## Functions

db_clause_t * | db_clause_new (void)
void | db_clause_free (db_clause_t *clause)
const char * | db_clause_field (const db_clause_t *clause)
db_clause_type_t | db_clause_type (const db_clause_t *clause)
const db_value_t * | db_clause_value (const db_clause_t *clause)
db_clause_operator_t | db_clause_operator (const db_clause_t *clause)
const db_clause_list_t * | db_clause_list (const db_clause_t *clause)
int | db_clause_set_field (db_clause_t *clause, const char *field)
int | db_clause_set_type (db_clause_t *clause, db_clause_type_t type)
int | db_clause_set_operator (db_clause_t *clause, db_clause_operator_t clause_operator)
int | db_clause_not_empty (const db_clause_t *clause)
const db_clause_t * | db_clause_next (const db_clause_t *clause)
db_value_t * | db_clause_get_value (db_clause_t *clause)
db_clause_list_t * | db_clause_list_new (void)
void | db_clause_list_free (db_clause_list_t *clause_list)
int | db_clause_list_add (db_clause_list_t *clause_list, db_clause_t *clause)
const db_clause_t * | db_clause_list_begin (const db_clause_list_t *clause_list)

## Macro Definition Documentation

## DB_CLAUSE_EQ

#define DB_CLAUSE_EQ DB_CLAUSE_EQUAL

Definition at line 79 of file db_clause.h.

## DB_CLAUSE_GE

#define DB_CLAUSE_GE DB_CLAUSE_GREATER_OR_EQUAL

Definition at line 83 of file db_clause.h.

## DB_CLAUSE_GT

#define DB_CLAUSE_GT DB_CLAUSE_GREATER_THEN

Definition at line 84 of file db_clause.h.

## DB_CLAUSE_LE

#define DB_CLAUSE_LE DB_CLAUSE_LESS_OR_EQUAL

Definition at line 82 of file db_clause.h.

## DB_CLAUSE_LT

#define DB_CLAUSE_LT DB_CLAUSE_LESS_THEN

Definition at line 81 of file db_clause.h.

## DB_CLAUSE_NE

#define DB_CLAUSE_NE DB_CLAUSE_NOT_EQUAL

Definition at line 80 of file db_clause.h.

## DB_CLAUSE_OP_AND

#define DB_CLAUSE_OP_AND DB_CLAUSE_OPERATOR_AND

Definition at line 104 of file db_clause.h.

## DB_CLAUSE_OP_OR

#define DB_CLAUSE_OP_OR DB_CLAUSE_OPERATOR_OR

Definition at line 105 of file db_clause.h.

## Typedef Documentation

## db_clause_list_t

typedef struct db_clause_list db_clause_list_t

Definition at line 110 of file db_clause.h.

## db_clause_t

typedef struct db_clause db_clause_t

Definition at line 109 of file db_clause.h.

## Enumeration Type Documentation

## db_clause_operator_t

enum db_clause_operator_t

The operator to do between the previous clause and this one.

Enumerator
DB_CLAUSE_OPERATOR_UNKNOWN | Empty, not set or unknown.
DB_CLAUSE_OPERATOR_AND | ||
DB_CLAUSE_OPERATOR_OR | &&

Definition at line 89 of file db_clause.h.

## db_clause_type_t

enum db_clause_type_t

The clause operation to make on the value.

Enumerator
DB_CLAUSE_UNKNOWN | Empty, not set or unknown.
DB_CLAUSE_EQUAL | ==
DB_CLAUSE_NOT_EQUAL | !=
DB_CLAUSE_LESS_THEN | <
DB_CLAUSE_LESS_OR_EQUAL | <=
DB_CLAUSE_GREATER_OR_EQUAL | >=
DB_CLAUSE_GREATER_THEN | >
DB_CLAUSE_IS_NULL | Is null.
DB_CLAUSE_IS_NOT_NULL | Is not null.
DB_CLAUSE_NESTED | This adds a nested clause as in wrapping the content with ( ).

Definition at line 36 of file db_clause.h.

## Function Documentation

## db_clause_field()

const char* db_clause_field | ( | const db_clause_t * | clause | ) |

Get the field name of a database clause.

Parameters

  [in] | a | db_clause_t pointer.

Returns
  a character pointer or NULL on error or if no field name has been set.

Definition at line 69 of file db_clause.c.

Referenced by test_class_db_clause().

## db_clause_free()

void db_clause_free | ( | db_clause_t * | clause | ) |

Delete a database clause.

Parameters

  [in] | clause | a db_clause_t pointer.

Definition at line 56 of file db_clause.c.

Referenced by clean_suite_classes().

## db_clause_get_value()

db_value_t* db_clause_get_value | ( | db_clause_t * | clause | ) |

Get the writable database value of a database clause.

Parameters

  [in] | a | db_clause_t pointer.

Returns
  a db_value_t pointer or NULL on error.

Definition at line 187 of file db_clause.c.

Referenced by test_class_db_clause().

## db_clause_list()

const db_clause_list_t* db_clause_list | ( | const db_clause_t * | clause | ) |

Get the database clause list of a database clause, this is used for nested database clauses.

Parameters

  [in] | a | db_clause_t pointer.

Returns
  a db_clause_list_t pointer or NULL on error or if no database clause list has been set.

Definition at line 101 of file db_clause.c.

## db_clause_list_add()

int db_clause_list_add | ( | db_clause_list_t * | clause_list,
|  | db_clause_t * | clause
| ) |  |

Add a database clause to a database clause list, this takes over the ownership of the database clause.

Parameters

  [in] | clause_list | a db_clause_list_t pointer.
  [in] | a | db_clause_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 226 of file db_clause.c.

## db_clause_list_begin()

const db_clause_t* db_clause_list_begin | ( | const db_clause_list_t * | clause_list | ) |

Return the first database clause of a database clause list.

Parameters

  [in] | clause_list | a db_clause_list_t pointer.

Returns
  a db_clause_t pointer or NULL on error or if the list is empty.

Definition at line 255 of file db_clause.c.

## db_clause_list_free()

void db_clause_list_free | ( | db_clause_list_t * | clause_list | ) |

Delete a database clause list and all database clauses in the list.

Parameters

  [in] | clause_list | a db_clause_list_t pointer.

Definition at line 209 of file db_clause.c.

Referenced by clean_suite_classes().

## db_clause_list_new()

db_clause_list_t* db_clause_list_new | ( | void |  | ) |

Create a new database clause list.

Returns
  a db_clause_list_t pointer or NULL on error.

Definition at line 202 of file db_clause.c.

## db_clause_new()

db_clause_t* db_clause_new | ( | void |  | ) |

Create a new database clause.

Returns
  a db_clause_t pointer or NULL on error.

Definition at line 43 of file db_clause.c.

Referenced by test_class_db_clause().

## db_clause_next()

const db_clause_t* db_clause_next | ( | const db_clause_t * | clause | ) |

Return the next database clause connected in a database clause list.

Parameters

  [in] | a | db_clause_t pointer.

Returns
  a db_clause_t pointer or NULL on error or if there are no more database clauses in the list.

Definition at line 179 of file db_clause.c.

Referenced by test_class_db_clause().

## db_clause_not_empty()

int db_clause_not_empty | ( | const db_clause_t * | clause | ) |

Check if the database clause is not empty.

Parameters

  [in] | a | db_clause_t pointer.

Returns
  DB_ERROR_* if empty, otherwise DB_OK.

Definition at line 154 of file db_clause.c.

Referenced by test_class_db_clause().

## db_clause_operator()

db_clause_operator_t db_clause_operator | ( | const db_clause_t * | clause | ) |

Get the database clause operator of a database clause.

Parameters

  [in] | a | db_clause_t pointer.

Returns
  a db_clause_operator_t.

Definition at line 93 of file db_clause.c.

Referenced by test_class_db_clause().

## db_clause_set_field()

int db_clause_set_field | ( | db_clause_t * | clause,
|  | const char * | field
| ) |  |

Set the field name of a database clause.

Parameters

  [in] | a | db_clause_t pointer.
  [in] | field | a character pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 109 of file db_clause.c.

Referenced by test_class_db_clause().

## db_clause_set_operator()

int db_clause_set_operator | ( | db_clause_t * | clause,
|  | db_clause_operator_t | clause_operator
| ) |  |

Set the database clause operator of a database clause.

Parameters

  [in] | a | db_clause_t pointer.
  [in] | clause_operator | a db_clause_operator_t.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 142 of file db_clause.c.

Referenced by test_class_db_clause().

## db_clause_set_type()

int db_clause_set_type | ( | db_clause_t * | clause,
|  | db_clause_type_t | type
| ) |  |

Set the database clause type of a database clause.

Parameters

  [in] | a | db_clause_t pointer.
  [in] | type | a db_clause_type_t.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 130 of file db_clause.c.

Referenced by test_class_db_clause().

## db_clause_type()

db_clause_type_t db_clause_type | ( | const db_clause_t * | clause | ) |

Get the database clause type of a database clause.

Parameters

  [in] | a | db_clause_t pointer.

Returns
  a db_clause_type_t.

Definition at line 77 of file db_clause.c.

Referenced by test_class_db_clause().

## db_clause_value()

const db_value_t* db_clause_value | ( | const db_clause_t * | clause | ) |

Get the database value of a database value.

Parameters

  [in] | a | db_clause_t pointer.

Returns
  a db_value_t pointer or NULL on error.

Definition at line 85 of file db_clause.c.

Referenced by test_class_db_clause().