Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

statement.h File Reference

A set of methods to operate with statement. More...

#include "node.h"
#include <time.h>

Include dependency graph for statement.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _statement
 The statement structure. More...

Typedefs

typedef _statement Statement
 The statement structure.

Enumerations

enum  ex_flags { STATEMENT_RETURN_LIE = 1, STATEMENT_SET_LIE = 1 }
enum  statement_mask {
  NO_MASK = 0, CONTEXT_MASK = 1, PREDICATE_MASK = 2, SUBJECT_MASK = 4,
  OBJECT_MASK = 8, MASK_ALL = 15
}
 Statement mask bits. More...
enum  statement_op { STATEMENT_OP_UNSET = 0, STATEMENT_OP_SET = 1, STATEMENT_OP_UNDEF = 2 }
 Statement operation field type. More...

Functions

STORAGE_TYPE void statement_clear (Statement *stmt)
 Clears the statement's nodes.
STORAGE_TYPE Statementstatement_clone (const Statement *src)
 Creates a copy of the source statement.
STORAGE_TYPE Statementstatement_create (const Node *context, const Node *predicate, const Node *subject, const Node *object)
 Creates new statement object with filled values.
STORAGE_TYPE Statementstatement_create_with_op (const Node *c, const Node *p, const Node *s, const Node *o, statement_op op)
 Creates a new statement with given operation.
STORAGE_TYPE void statement_free (Statement *stmt)
 Destroys the statement.
STORAGE_TYPE const Nodestatement_get_context (const Statement *stmt)
 The statement context accessor.
STORAGE_TYPE time_t statement_get_end (const Statement *stmt)
STORAGE_TYPE int statement_get_mask (const Statement *stmt)
 The statement mask accessor.
STORAGE_TYPE const Nodestatement_get_object (const Statement *stmt)
 The statement object accessor.
STORAGE_TYPE statement_op statement_get_op (const Statement *stmt)
 Returns statement operation.
STORAGE_TYPE const Nodestatement_get_predicate (const Statement *stmt)
 The statement predicate accessor.
STORAGE_TYPE time_t statement_get_start (const Statement *stmt)
STORAGE_TYPE const Nodestatement_get_subject (const Statement *stmt)
 The statement subject accessor.
STORAGE_TYPE void statement_init (Statement *stmt, const Node *c, const Node *p, const Node *s, const Node *o)
STORAGE_TYPE int statement_match (const Statement *mask, const Statement *stmt)
 Check the matching of stmt against mask returns zero if there is no match and positive value otherwise.
STORAGE_TYPE Statementstatement_new ()
 Creates empty statement object.
STORAGE_TYPE void statement_result_append (Statement **result, Statement *s)
 Appends a new statement to the statement bunch.
STORAGE_TYPE void statement_result_compact (unsigned *count, Statement ***result)
 Compacts the statement bunch.
STORAGE_TYPE unsigned int statement_result_count (Statement *result)
STORAGE_TYPE void statement_result_free (Statement **result)
 Destroys the result model_storage_get() and model_storage_get_nr() functions.
STORAGE_TYPE int statement_result_pop (Statement **result, Statement *head)
 Withdraws the head of a list and returns it.
STORAGE_TYPE void statement_result_remove (Statement **result, Statement *stmt)
 Removes from the bunch and frees the statement with given index.
STORAGE_TYPE void statement_set_context (Statement *stmt, const Node *context)
 Sets the context of the statement.
STORAGE_TYPE void statement_set_end (Statement *stmt, time_t t)
STORAGE_TYPE void statement_set_mask (Statement *stmt, int mask)
 Sets the mask of the statement.
STORAGE_TYPE void statement_set_object (Statement *stmt, const Node *object)
 Sets the object of the statement.
STORAGE_TYPE Statementstatement_set_op (Statement *stmt, statement_op operation)
 Sets statement operation.
STORAGE_TYPE void statement_set_predicate (Statement *stmt, const Node *predicate)
 Sets the predicate of the statement.
STORAGE_TYPE void statement_set_start (Statement *stmt, time_t t)
STORAGE_TYPE void statement_set_subject (Statement *stmt, const Node *subject)
 Sets the subject of the statement.
STORAGE_TYPE void statement_swap_op (Statement *op)
 Swaps the operation of the statement and its previsous state.
STORAGE_TYPE Statementstmt_from_strings (const char *c, const char *p, const char *s, const char *o)
 Creates new statement that contains nodes, created from given literals.
STORAGE_TYPE void stmt_init_from_strings (Statement *stmt, const char *c, const char *p, const char *s, const char *o)
 Automatically creates nodes from strings and initializes a statement with them.


Detailed Description

A set of methods to operate with statement.

The statement holds four members (context, predicate, subject, object). These members are all of Node (Node) type.

To create a new statement:

 Statement *s;
 Node a,b,c,d;
 char *prefix = "noprefix";
 node_init_string(&a, prefix, "Context");
 node_init_string(&b, prefix, "Predicate");
 node_init_string(&c, prefix, "Subject");
 node_init_string(&d, prefix, "Object");
 s = statement_create(&a, &b, &c, &d); 
Becasue of the statement manages its fields by itself, for changing one of the filed you should use the propriate statement_set_xxx() accessor. Other fields (not of Node type) can be accessed directly as Statement structure members.
See also:
statement_set_context(), statement_set_predicate(), statement_set_subject(), statement_set_object()

Typedef Documentation

typedef struct _statement Statement
 

The statement structure.

Contains the quadruplet nodes: context, predicate, subject and object. It also contains the mask bits.


Enumeration Type Documentation

enum ex_flags
 

Enumerator:
STATEMENT_RETURN_LIE 
STATEMENT_SET_LIE 

enum statement_mask
 

Statement mask bits.

Enumerator:
NO_MASK  NULL mask.
CONTEXT_MASK  Context field is masked.
PREDICATE_MASK  Predicate field is masked.
SUBJECT_MASK  Subject field is masked.
OBJECT_MASK  Object field is masked.
MASK_ALL  All fields are masked.

enum statement_op
 

Statement operation field type.

Enumerator:
STATEMENT_OP_UNSET  Unset statement operation.

Statement should be or was unset (in the context of transaction). It makes sense only in the values passed to model_storage_set() and model_storage_set_nr() funcitons or values filled by notification_read() function,

STATEMENT_OP_SET  Set statement operation.

The Statement sould be or was set (in the context of transaction) It mases sence only in the values passed to model_storage_set() and model_storage_set_nr() functions or values filled by notification_read() function.

STATEMENT_OP_UNDEF  Internal statement operation.

It is used in stmtbase only.


Function Documentation

STORAGE_TYPE void statement_clear Statement stmt  ) 
 

Clears the statement's nodes.

Note:
It destroys the nodes the stmt reffers to.

STORAGE_TYPE Statement* statement_clone const Statement src  ) 
 

Creates a copy of the source statement.

The newly created statement refers to the same nodes and mask as the source statement.

STORAGE_TYPE Statement* statement_create const Node context,
const Node predicate,
const Node subject,
const Node object
 

Creates new statement object with filled values.

The nodes passed to this function are cloned and managed by it So the caller is responsible for the arguments (depending on how has he got them).

STORAGE_TYPE Statement* statement_create_with_op const Node c,
const Node p,
const Node s,
const Node o,
statement_op  op
 

Creates a new statement with given operation.

  • op -- operation of this statement

STORAGE_TYPE void statement_free Statement stmt  ) 
 

Destroys the statement.

Note:
It destroys the nodes the stmt reffers to.

STORAGE_TYPE const Node* statement_get_context const Statement stmt  ) 
 

The statement context accessor.

STORAGE_TYPE time_t statement_get_end const Statement stmt  ) 
 

STORAGE_TYPE int statement_get_mask const Statement stmt  ) 
 

The statement mask accessor.

STORAGE_TYPE const Node* statement_get_object const Statement stmt  ) 
 

The statement object accessor.

STORAGE_TYPE statement_op statement_get_op const Statement stmt  ) 
 

Returns statement operation.

STORAGE_TYPE const Node* statement_get_predicate const Statement stmt  ) 
 

The statement predicate accessor.

STORAGE_TYPE time_t statement_get_start const Statement stmt  ) 
 

STORAGE_TYPE const Node* statement_get_subject const Statement stmt  ) 
 

The statement subject accessor.

STORAGE_TYPE void statement_init Statement stmt,
const Node c,
const Node p,
const Node s,
const Node o
 

STORAGE_TYPE int statement_match const Statement mask,
const Statement stmt
 

Check the matching of stmt against mask returns zero if there is no match and positive value otherwise.

STORAGE_TYPE Statement* statement_new  ) 
 

Creates empty statement object.

STORAGE_TYPE void statement_result_append Statement **  result,
Statement s
 

Appends a new statement to the statement bunch.

This function automatically reallocates the memory for the list of statements. The result should be cleared with statement_result_free() function.

STORAGE_TYPE void statement_result_compact unsigned *  count,
Statement ***  result
 

Compacts the statement bunch.

Statement result should be compactified after massive removing with statement_result_remove() function and before any usage. This function reallocates the memory for the list compacted.

Deprecated:
This function is not needed any more.

STORAGE_TYPE unsigned int statement_result_count Statement result  ) 
 

STORAGE_TYPE void statement_result_free Statement **  result  ) 
 

Destroys the result model_storage_get() and model_storage_get_nr() functions.

STORAGE_TYPE int statement_result_pop Statement **  result,
Statement head
 

Withdraws the head of a list and returns it.

Returns:
0 if the list if empty, 1 if the head was withdrawn successfully.

STORAGE_TYPE void statement_result_remove Statement **  result,
Statement stmt
 

Removes from the bunch and frees the statement with given index.

The result should be compacted with statement_result_compact() function

STORAGE_TYPE void statement_set_context Statement stmt,
const Node context
 

Sets the context of the statement.

STORAGE_TYPE void statement_set_end Statement stmt,
time_t  t
 

STORAGE_TYPE void statement_set_mask Statement stmt,
int  mask
 

Sets the mask of the statement.

STORAGE_TYPE void statement_set_object Statement stmt,
const Node object
 

Sets the object of the statement.

STORAGE_TYPE Statement* statement_set_op Statement stmt,
statement_op  operation
 

Sets statement operation.

Returns:
the pointer to the same statement.

STORAGE_TYPE void statement_set_predicate Statement stmt,
const Node predicate
 

Sets the predicate of the statement.

STORAGE_TYPE void statement_set_start Statement stmt,
time_t  t
 

STORAGE_TYPE void statement_set_subject Statement stmt,
const Node subject
 

Sets the subject of the statement.

STORAGE_TYPE void statement_swap_op Statement op  ) 
 

Swaps the operation of the statement and its previsous state.

STORAGE_TYPE Statement* stmt_from_strings const char *  c,
const char *  p,
const char *  s,
const char *  o
 

Creates new statement that contains nodes, created from given literals.

STORAGE_TYPE void stmt_init_from_strings Statement stmt,
const char *  c,
const char *  p,
const char *  s,
const char *  o
 

Automatically creates nodes from strings and initializes a statement with them.


Generated on Wed Dec 27 16:52:26 2006 for VRB Online Server by  doxygen 1.4.4