CWB
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../cl/macros.h"
#include "../cl/corpus.h"
#include "../cl/attributes.h"
#include "attlist.h"
AttributeInfo* AddNameToAL | ( | AttributeList * | list, |
char * | name, | ||
int | initial_status, | ||
int | position | ||
) |
Adds a new AttributeInfo to an AttributeList object.
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). |
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.
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.
list | The list to search. |
name | The name of the element to search for. |
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.
list | The list to search. |
name | The name of the element to search for. |
References FindInAL().
Referenced by AddNameToAL().
AttributeList* NewAttributeList | ( | int | element_type | ) |
Creates a new AttributeList.
element_type | What type of attribute is this? ATT_POS, ATT_STRUC, etc. |
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.
list | The list to size up. |
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.
list | The AttributeList to recompute. |
corpus | The corpus in which these attributes are found. |
init_status | Not currently used. |
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.
list | The list from which to delete. |
name | The name of the AttributeInfo to delete. |
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.
list | The list from which to delete. |
this | The address (pointer) of the AttributeInfo to delete. |
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.
list | The list to verify. |
corpus | The corpus for which this list should be valid. |
remove_illegal_entries | Boolean: see function description. |
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().