CWB
Defines | Functions | Variables

variables.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "../cl/corpus.h"
#include "../cl/attributes.h"
#include "../cl/cdaccess.h"
#include "../cl/macros.h"
#include "variables.h"
#include "output.h"

Defines

Functions

Variables


Define Documentation

#define ITEM_REALLOC   8

How many pointers to allocate space for at one time to a Variable's ->items array.

Referenced by VariableAddItem().

#define VARIABLE_REALLOC   16

How many pointers to allocate space for at one time to the gloval array VariableSpace.

Referenced by NewVariable().


Function Documentation

int DropVariable ( Variable vp)
Variable FindVariable ( char *  varname)

Finds the Variable object of the given name, if it exists in VariableSpace.

Parameters:
varnameThe name of the variable required.
Returns:
The Variable requested, or NULL if no Variable by that name could be found.

References nr_variables.

Referenced by do_AddSubVariables(), do_flagged_re_variable(), do_printVariableSize(), do_PrintVariableValue(), do_SetVariableValue(), SetVariableValue(), and Varref2IDList().

int* GetVariableItems ( Variable  v,
Corpus corpus,
Attribute attribute,
int *  nr_items 
)

Get lexicon IDs of variable's strings in corpus.attribute lexicon.

Parameters:
vThe Variable object.
corpusThe corpus we are working with.
attributeThe attribute against which to verify the Variable's items
nr_itemsThis will be set to the number of integers in the returned array.
Returns:
Pointer to block of integers based on valid items from the variable; NULL if there were no valid items (i.e. items found in the attribute's lexicon).

References cl_malloc(), _variable_item::free, intcompare(), _variable_buf::items, _variable_item::ival, _variable_buf::nr_items, _variable_buf::nr_valid_items, and VerifyVariable().

Referenced by Varref2IDList().

char** GetVariableStrings ( Variable  v,
int *  nr_items 
)

Returns an array of pointers to a variable's strings.

Return value is NULL if there were no strings stored in the variable. The number of strings that were found is inserted into nr_items.

The array that is returned must be freed by the caller.

Parameters:
vThe Variable whose strings you want.
nr_itemsThe number of strings found will be put here.
Returns:
Table of pointers to the Variable's strings.

References cl_malloc(), _variable_item::free, _variable_buf::items, _variable_buf::nr_items, and _variable_item::sval.

Referenced by do_AddSubVariables(), and do_flagged_re_variable().

static int intcompare ( const void *  i,
const void *  j 
) [static]

comparison function for qsort() of id_list returned by GetVariableItems

Referenced by GetVariableItems().

Variable NewVariable ( char *  varname)
int SetVariableValue ( char *  varName,
char  operator,
char *  varValues 
)
int VariableAddItem ( Variable  v,
char *  item 
)
int VariableDeleteItems ( Variable  v)
int VariableItemMember ( Variable  v,
char *  item 
)
void variables_iterator_new ( void  )

Resets the variables iterator to the beginning of the global VariableSpace array.

References variables_iterator_idx.

Referenced by do_PrintAllVariables().

Variable variables_iterator_next ( void  )

Gets the next Variable object from the variables iterator.

Returns NULL if the iterator has reached the end of the global VariableSpace array.

See also:
VariableSpace
Returns:
The next Variable object from the iterator.

References nr_variables, and variables_iterator_idx.

Referenced by do_PrintAllVariables().

int VariableSubtractItem ( Variable  v,
char *  item 
)
int VerifyVariable ( Variable  v,
Corpus corpus,
Attribute attribute 
)

Variable Documentation

int nr_variables = 0

Number of variables in VariableArray (exported)

Referenced by DropVariable(), FindVariable(), NewVariable(), and variables_iterator_next().

Global array of Variables (exported)