![]() | ![]() | ![]() | Libmergeant Reference Manual | ![]() |
---|
#define MG_CONDITION_TYPE #define MG_CONDITION (obj) #define IS_MG_CONDITION (obj) #define MG_CONDITION_CLASS (klass) struct MgCondition; enum MgConditionType; enum MgConditionOperator; guint mg_condition_get_type (void); GObject* mg_condition_new (MgQuery *query, MgConditionType type); GObject* mg_condition_new_copy (MgCondition *orig, GHashTable *replacements); void mg_condition_set_cond_type (MgCondition *condition, MgConditionType type); MgConditionType mg_condition_get_cond_type (MgCondition *condition); GSList* mg_condition_get_children (MgCondition *condition); MgCondition* mg_condition_get_parent (MgCondition *condition); MgCondition* mg_condition_get_child_by_xml_id (MgCondition *condition, const gchar *xml_id); gboolean mg_condition_is_ancestor (MgCondition *condition, MgCondition *ancestor); gboolean mg_condition_is_leaf (MgCondition *condition); gboolean mg_condition_node_add_child (MgCondition *condition, MgCondition *child, GError **error); void mg_condition_node_del_child (MgCondition *condition, MgCondition *child); void mg_condition_leaf_set_operator (MgCondition *condition, MgConditionOperator op, MgQfield *field); MgQfield* mg_condition_leaf_get_operator (MgCondition *condition, MgConditionOperator op); GSList* mg_condition_get_ref_objects_all (MgCondition *condition); gboolean mg_condition_represents_join (MgCondition *condition, MgTarget **target1, MgTarget **target2, gboolean *is_equi_join); GSList* mg_condition_get_main_conditions (MgCondition *condition);
This object represents a condition within a query. Usually there is one such object to express a WHERE condition and sometimes a MgJoin object con contain one as well to express a specific joinning condition.
There are two types of conditions: 'node' conditions (AND, OR, NOT), where there are one or more children condition and 'leaf' conditions, where there are only operands.
#define MG_CONDITION(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, mg_condition_get_type(), MgCondition)
obj : |
|
#define IS_MG_CONDITION(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, mg_condition_get_type ())
obj : |
|
#define MG_CONDITION_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, mg_condition_get_type (), MgConditionClass)
klass : |
|
typedef enum { MG_CONDITION_NODE_AND, MG_CONDITION_NODE_OR, MG_CONDITION_NODE_NOT, MG_CONDITION_LEAF_EQUAL, MG_CONDITION_LEAF_DIFF, MG_CONDITION_LEAF_SUP, MG_CONDITION_LEAF_SUPEQUAL, MG_CONDITION_LEAF_INF, MG_CONDITION_LEAF_INFEQUAL, MG_CONDITION_LEAF_LIKE, MG_CONDITION_LEAF_REGEX, MG_CONDITION_LEAF_IN, MG_CONDITION_LEAF_BETWEEN, MG_CONDITION_TYPE_UNKNOWN } MgConditionType;
typedef enum { MG_CONDITION_OP_LEFT = 0, MG_CONDITION_OP_RIGHT = 1, MG_CONDITION_OP_RIGHT2 = 2 } MgConditionOperator;
GObject* mg_condition_new (MgQuery *query, MgConditionType type);
Creates a new MgCondition object
query : | a MgQuery object |
type : | the condition type |
Returns : | the newly created object |
GObject* mg_condition_new_copy (MgCondition *orig, GHashTable *replacements);
This is a copy constructor
orig : | a MgCondition to copy |
replacements : | a hash table to store replacements, or NULL |
Returns : | the new object |
void mg_condition_set_cond_type (MgCondition *condition, MgConditionType type);
Sets the kind of condition condition represents. If type implies a node condition and condition currently represents a leaf, or if type implies a leaf condition and condition currently represents a node, then condition is changed without any error.
condition : | a MgCondition object |
type : |
MgConditionType mg_condition_get_cond_type (MgCondition *condition);
Get the type of condition
condition : | a MgCondition object |
Returns : | the type |
GSList* mg_condition_get_children (MgCondition *condition);
Get a list of MgCondition objects which are children of condition
condition : | a MgCondition object |
Returns : | a new list of MgCondition objects |
MgCondition* mg_condition_get_parent (MgCondition *condition);
Get the MgCondition object which is parent of condition
condition : | a MgCondition object |
Returns : | the parent object, or NULL |
MgCondition* mg_condition_get_child_by_xml_id (MgCondition *condition, const gchar *xml_id);
Get a pointer to a MgCondition child from its XML Id
condition : | a MgCondition object |
xml_id : | the XML Id of the requested MgCondition child |
Returns : | the MgCondition object, or NULL if not found |
gboolean mg_condition_is_ancestor (MgCondition *condition, MgCondition *ancestor);
Tests if ancestor is an ancestor of condition
condition : | a MgCondition object |
ancestor : | a MgCondition object |
Returns : | TRUE if ancestor is an ancestor of condition |
gboolean mg_condition_is_leaf (MgCondition *condition);
Tells if condition is a leaf condition (not AND, OR, NOT, etc)
condition : | a MgCondition object |
Returns : | TRUE if condition is a leaf condition |
gboolean mg_condition_node_add_child (MgCondition *condition, MgCondition *child, GError **error);
Adds a child to condition; this is possible only if condition is a node type (AND, OR, etc)
condition : | a MgCondition object |
child : | a MgCondition object |
error : | location to store error, or NULL |
Returns : | TRUE if no error occured |
void mg_condition_node_del_child (MgCondition *condition, MgCondition *child);
Removes a child from condition; this is possible only if condition is a node type (AND, OR, etc)
condition : | a MgCondition object |
child : | a MgCondition object |
void mg_condition_leaf_set_operator (MgCondition *condition, MgConditionOperator op, MgQfield *field);
condition : | |
op : | |
field : |
|
MgQfield* mg_condition_leaf_get_operator (MgCondition *condition, MgConditionOperator op);
Get one of condition's operators.
condition : | a MgCondition object |
op : | which oparetor is concerned |
Returns : | the requested MgQfield object |
GSList* mg_condition_get_ref_objects_all (MgCondition *condition);
Get a complete list of the objects referenced by cond, including its descendants (unlike the mg_referer_get_ref_objects() function applied to cond).
condition : | |
Returns : | a new list of referenced objects |
gboolean mg_condition_represents_join (MgCondition *condition, MgTarget **target1, MgTarget **target2, gboolean *is_equi_join);
Tells if condition represents a join condition: it is a condition (within a MgQuery object) for which the only MgQfField fields taking part in the condition are from two distincts MgTarget objects. Such conditions can be assigned to a MgJoin object using the mg_join_set_condition() method.
Additionnaly, if condition is a join condition, and if target1 and target2 are not NULL then they are set to point to the two MgTarget objects taking part in the condition. In this case target1 and target2 wil hold non NULL values.
In a similar way, if is_equi_join is not NULL, then it will be set to TRUE if the join condition is an equi join (that is the only comparison operator is the equal sign and there are only AND operators in the condition).
If condition is not a join condition, then target1, target2 and is_equi_join are left untouched.
condition : | a MgCondition object |
target1 : | place to store one of the targets, or NULL |
target2 : | place to store the other target, or NULL |
is_equi_join : | place to store if the join is an equi join |
Returns : | TRUE if condition is a join condition |
GSList* mg_condition_get_main_conditions (MgCondition *condition);
Makes a list of all the conditions which are always verified by condition returns TRUE when evaluated. Basically the returned list lists the atomic conditions which are AND'ed together to form the complex condition.
Examples: if condition is: --> "A and B" then the list will contains {A, B} --> "A and (B or C)" it will contain {A, B or C} --> "A and (B and not C)", it will contain {A, B, not C}
condition : | a MgCondition object |
Returns : | a new list of MgCondition objects |
<<< MgJoin | MgParameter >>> |