CWB
Macros | Functions
context_descriptor.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "../cl/cl.h"
#include "../cl/corpus.h"
#include "../cl/attributes.h"
#include "../cl/cdaccess.h"
#include "../cl/macros.h"
#include "context_descriptor.h"
#include "output.h"
#include "options.h"

Macros

#define RESET_LEFT_CONTEXT
 
#define RESET_RIGHT_CONTEXT
 

Functions

void context_descriptor_reset_left_context (ContextDescriptor *cd)
 Resets left context scope of a ContextDescriptor to default (25 chars). More...
 
void context_descriptor_reset_right_context (ContextDescriptor *cd)
 Resets right context scope of a ContextDescriptor to default (25 chars). More...
 
int verify_context_descriptor (Corpus *corpus, ContextDescriptor *cd, int remove_illegal_entries)
 Verify the current context settings against the current corpus: check whether structures are still valid, and reset them to defaults if not. More...
 
ContextDescriptorNewContextDescriptor (void)
 Creates (and initialises) a ContextDescriptor object. More...
 
int initialize_context_descriptor (ContextDescriptor *cd)
 Initialises the member variables of a ContextDescriptor object to zero. More...
 
int update_context_descriptor (Corpus *corpus, ContextDescriptor *cd)
 Imports lists of attributes (p-, s-, and a-) from a Corpus record into a ContextDescriptor record (where they can then be used as concordance display info). More...
 
void PrintAttributes (FILE *fd, char *header, AttributeList *al, int show_if_annot)
 attribute (selected/unselected) print helper routine More...
 
void PrintAttributesSimple (FILE *fd, char *type, AttributeList *al, int show_if_annot)
 attribute print helper routine (non pretty-printing mode) ( TODO desperately needs a better name ) More...
 
void PrintContextDescriptor (ContextDescriptor *cdp)
 Prints the contents of a ContextDescriptor either to stdout or a pager (NB this uses its own internal stream). More...
 

Macro Definition Documentation

#define RESET_LEFT_CONTEXT
Value:
cd->left_width = 25; \
cd->left_type = CHAR_CONTEXT; \
if (cd->left_structure_name) { \
free(cd->left_structure_name); \
cd->left_structure_name = NULL; \
} \
cd->left_structure = NULL
#define CHAR_CONTEXT
Context width measured in characters.
Definition: context_descriptor.h:27

Referenced by verify_context_descriptor().

#define RESET_RIGHT_CONTEXT
Value:
cd->right_width = 25; \
cd->right_type = CHAR_CONTEXT; \
if (cd->right_structure_name) { \
free(cd->right_structure_name); \
cd->right_structure_name = NULL; \
} \
cd->right_structure = NULL
#define CHAR_CONTEXT
Context width measured in characters.
Definition: context_descriptor.h:27

Referenced by verify_context_descriptor().

Function Documentation

void context_descriptor_reset_left_context ( ContextDescriptor cd)

Resets left context scope of a ContextDescriptor to default (25 chars).

References CHAR_CONTEXT, cl_free, _context_description_block::left_structure_name, _context_description_block::left_type, and _context_description_block::left_width.

void context_descriptor_reset_right_context ( ContextDescriptor cd)

Resets right context scope of a ContextDescriptor to default (25 chars).

References CHAR_CONTEXT, cl_free, _context_description_block::right_structure_name, _context_description_block::right_type, and _context_description_block::right_width.

int initialize_context_descriptor ( ContextDescriptor cd)

Initialises the member variables of a ContextDescriptor object to zero.

Initial settings are: no attributes for printing, no right context, no left context, no cpos printing.

TODO since this should never be called except when a new context descriptor is being created (structure names can memleak if it is called on one already used, it would make sense ot merge this into the NewC.D. function. (it is, in fact, used in options.c to set up the static global variable CD, which is not malloc'd - perhaps change this to modularise the ContextDescirptor object better?)

See also
ContextDescriptor

References _context_description_block::alignedCorpora, _context_description_block::attributes, CHAR_CONTEXT, _context_description_block::left_structure, _context_description_block::left_structure_name, _context_description_block::left_type, _context_description_block::left_width, _context_description_block::print_cpos, _context_description_block::printStructureTags, _context_description_block::right_structure, _context_description_block::right_structure_name, _context_description_block::right_type, _context_description_block::right_width, and _context_description_block::strucAttributes.

Referenced by init_align_module(), NewContextDescriptor(), printAlignedStrings(), and set_default_option_values().

ContextDescriptor* NewContextDescriptor ( void  )

Creates (and initialises) a ContextDescriptor object.

References cl_malloc(), and initialize_context_descriptor().

void PrintAttributes ( FILE *  fd,
char *  header,
AttributeList al,
int  show_if_annot 
)

attribute (selected/unselected) print helper routine

References _Attribute::any, _attrbuf::attribute, cl_struc_values(), line, _attlist::list, _attrbuf::next, and _attrbuf::status.

Referenced by PrintContextDescriptor().

void PrintAttributesSimple ( FILE *  fd,
char *  type,
AttributeList al,
int  show_if_annot 
)

attribute print helper routine (non pretty-printing mode) ( TODO desperately needs a better name )

References _Attribute::any, _attrbuf::attribute, cl_struc_values(), _attlist::list, and _attrbuf::next.

Referenced by PrintContextDescriptor().

void PrintContextDescriptor ( ContextDescriptor cdp)
int update_context_descriptor ( Corpus corpus,
ContextDescriptor cd 
)

Imports lists of attributes (p-, s-, and a-) from a Corpus record into a ContextDescriptor record (where they can then be used as concordance display info).

Parameters
corpusThe source of the settings.
cdThe destination of the settings.
Returns
Always 1.

References _context_description_block::alignedCorpora, ATT_ALIGN, ATT_POS, ATT_STRUC, _context_description_block::attributes, find_attribute, _attlist::list, _attrbuf::name, NewAttributeList(), _attrbuf::next, _context_description_block::printStructureTags, RecomputeAL(), RemoveNameFromAL(), _context_description_block::strucAttributes, and structure_has_values.

Referenced by printAlignedStrings(), and set_current_corpus().

int verify_context_descriptor ( Corpus corpus,
ContextDescriptor cd,
int  remove_illegal_entries 
)