attlist.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../cl/macros.h"
#include "../cl/corpus.h"
#include "../cl/attributes.h"
#include "attlist.h"

Functions


Function Documentation

AttributeInfo* AddNameToAL ( AttributeList list,
char *  name,
int  initial_status,
int  position 
)

Adds a new AttributeInfo to an AttributeList object.

Parameters:
list The list to add to.
name The name of the Attribvute that this AttributeInfo refers to.
initial_status Initial setting for the status member of the new AttributeInfo.
position If this is 1, the new AttributeInfo is added at the beginning of the list. If it is 0, it is added at the end of the list. Otherwise, this specifies a particular insertion position (the given number of steps down the linked list).
Returns:
A pointer to the new AttributeInfo, or NULL for error.

References _attrbuf::attribute, cl_malloc(), cl_strdup(), _attlist::list, _attlist::list_valid, MemberAL(), _attrbuf::name, _attrbuf::next, _attrbuf::prev, and _attrbuf::status.

Referenced by compose_kwic_line(), ComputePrintStructures(), and RecomputeAL().

int DestroyAttributeList ( AttributeList **  list  ) 

Deletes an AttributeList object.

Parameters:
list Address of the pointer to the list to delete.

References _attrbuf::attribute, cl_free, _attrbuf::name, _attrbuf::next, _attrbuf::prev, and _attrbuf::status.

Referenced by ComputePrintStructures(), execute_side_effects(), set_current_corpus(), and verify_context_descriptor().

AttributeInfo* FindInAL ( AttributeList list,
char *  name 
)

Finds an entry in an AttribvuteList.

Parameters:
list The list to search.
name The name of the element to search for.
Returns:
Pointer to the AttributeInfo with the matching name, or NULL if the name was not found.

References _attlist::list.

Referenced by compose_kwic_line(), do_attribute_show(), MemberAL(), printAlignedStrings(), and set_current_corpus().

int MemberAL ( AttributeList list,
char *  name 
)

Checks whether the AttributeList contains an entry with the given attribute name.

Parameters:
list The list to search.
name The name of the element to search for.
Returns:
Boolean: true if the element is found as a member of the list.

References FindInAL().

Referenced by AddNameToAL().

AttributeList* NewAttributeList ( int  element_type  ) 

Creates a new AttributeList.

Parameters:
element_type What type of attribute is this? ATT_POS, ATT_STRUC, etc.
Returns:
Pointer to the new AttributeList object.

References cl_malloc(), _attlist::element_type, _attlist::list, and _attlist::list_valid.

Referenced by compose_kwic_line(), ComputePrintStructures(), and update_context_descriptor().

int NrOfElementsAL ( AttributeList list  ) 

Gets the number of entries in an AttributeList.

Parameters:
list The list to size up.
Returns:
The number of elements in the list.

References _attlist::list, and _attrbuf::next.

int RecomputeAL ( AttributeList list,
Corpus corpus,
int  init_status 
)

Goes through an AttributeList, deletes entries for attributes that don't exist, and adds entries for those that do.

Note that all AttributeInfo entries are linked to the actual Attribute objects by this function.

Parameters:
list The AttributeList to recompute.
corpus The corpus in which these attributes are found.
init_status Not currently used.
Returns:
Always 1.

References AddNameToAL(), _Attribute::any, _attrbuf::attribute, TCorpus::attributes, cl_free, _attlist::element_type, find_attribute(), _attlist::list, _attlist::list_valid, _attrbuf::next, _attrbuf::prev, and _Attribute::type.

Referenced by update_context_descriptor().

int RemoveNameFromAL ( AttributeList list,
char *  name 
)

Deletes an AttributeInfo from the AttributeList.

Parameters:
list The list from which to delete.
name The name of the AttributeInfo to delete.
Returns:
True if the attribute info was found and deleted; otherwise false.

References cl_free, _attlist::list, _attrbuf::next, and _attrbuf::prev.

Referenced by update_context_descriptor().

int Unchain ( AttributeList list,
AttributeInfo this 
)

Deletes an AttributeInfo from the AttributeList.

Unlike RemoveNameFromAL(), this function deletes an AttributeInfo known by its pointer, rather than one known by its name.

See also:
RemoveNameFromAL
Parameters:
list The list from which to delete.
this The address (pointer) of the AttributeInfo to delete.
Returns:
True if the attribute info was found and deleted; otherwise false.

References cl_free, _attlist::list, _attrbuf::next, and _attrbuf::prev.

int VerifyList ( AttributeList list,
Corpus corpus,
int  remove_illegal_entries 
)

Verifies an AttributeList.

Note that all AttributeInfo entries are linked to the actual Attribute objects by this function.

If the relevant attribute cannot be found, the entry is deleted iff remove_illegal_entries.

Parameters:
list The list to verify.
corpus The corpus for which this list should be valid.
remove_illegal_entries Boolean: see function description.
Returns:
Boolean: true for all OK, false for error.

References _attrbuf::attribute, cl_free, _attlist::element_type, find_attribute(), _attlist::list, _attlist::list_valid, _attrbuf::name, _attrbuf::next, and _attrbuf::prev.

Referenced by compose_kwic_line(), ComputePrintStructures(), and verify_context_descriptor().


Generated on Sun Feb 28 18:08:04 2010 for CWB by  doxygen 1.6.1