#include "attrib.h"

This page has information from files attrib.h and attrib.c.

Contents


Public Routines in File attrib.c

Index

attribute_name_to_idcopy_term_attributeinheritable_att_instancesset_int_attribute
attributes_contain_variablesdeclare_term_attribute_inheritableinstantiate_inheritable_attributesset_string_attribute
attributes_to_termdelete_attributeslabel_attset_term_attribute
build_attr_termexists_attributep_attrib_memset_vars_attributes
cat_attfprint_attrib_memregister_attributestring_attribute_member
copy_attributesget_int_attributerenumber_vars_attributesterm_to_attributes
copy_int_attributeget_string_attributereplace_int_attributevars_in_attributes
copy_string_attributeget_term_attributereplace_term_attributezap_attributes

Details


int attribute_name_to_id(char *name);
Given an attribute name, return the attribute ID which is used for the "get" and "set" operations. Return -1 if the name has not been registered with "register_attribute".
BOOL attributes_contain_variables(Attribute a);
Does the list of attributes contain a Term attribute that contains a constant that looks like a variable?
Term attributes_to_term(Attribute a, char *operator);
This routine takes a list of attributes and constructs a term representation. It is a right-associated binary tree with Term forms of the attributes at the leaves.
Term build_attr_term(Attribute a);
Given an attribute, build (and return) a term representation of it. The name of the attribute will be the (unary) function symbol, and the value will be the argument.

This is typically used for printing attributes.


Attribute cat_att(Attribute a, Attribute b);
Concatenate two lists of attributes. Either may be NULL. Return the result.
Attribute copy_attributes(Attribute a);
This routine copies a list of attributes.
Attribute copy_int_attribute(Attribute source, Attribute dest, int attr_id);

Attribute copy_string_attribute(Attribute source, Attribute dest, int attr_id);

Attribute copy_term_attribute(Attribute source, Attribute dest, int attr_id);

void declare_term_attribute_inheritable(int id);
This routine makes a term attribute (which has already been registered) inheritable. This usually means that when the clause to which the attribute is attached begets a child, the child gets a copy of the instantiated attribute. This was designed for answer literals and ordering constraints.
Attribute delete_attributes(Attribute a, int id);
This routine frees all attributes of the given type.
BOOL exists_attribute(Attribute a, int id);
This routine checks if there are any attributes of the given type.
void fprint_attrib_mem(FILE *fp, BOOL heading);
This routine prints (to FILE *fp) memory usage statistics for data types associated with the attrib package. The Boolean argument heading tells whether to print a heading on the table.
int get_int_attribute(Attribute a, int id, int n);
This routine gets the n-th (counting from 1) attribute value associated with an attribute ID. If nothing matches, INT_MAX is returned.

A fatal error occurs if the ID does not refer to an integer type attribute (see register_attribute).


char *get_string_attribute(Attribute a, int id, int n);
This routine gets the n-th (counting from 1) attribute value associated with an attribute ID. If nothing matches, NULL is returned.

A fatal error occurs if the ID does not refer to a string type attribute (see register_attribute).


Term get_term_attribute(Attribute a, int id, int n);
This routine gets the n-th (counting from 1) attribute value associated with an attribute ID. If nothing matches, NULL is returned.

A fatal error occurs if the ID does not refer to a Term type attribute (see register_attribute).


Attribute inheritable_att_instances(Attribute a, Context subst);
Given a list of attributes, this routine copies, instantiates, and returns the inheritable attributes. The Context can be NULL.
void instantiate_inheritable_attributes(Attribute a, Context subst);
This routine
int label_att(void);
Return the attribute identifier for label attributes. If it does not exist, return -1.
void p_attrib_mem();
This routine prints (to stdout) memory usage statistics for data types associated with the attrib package.
int register_attribute(char *name, Attribute_type type);
This routine associates an attribute name and attribute type and returns an integer ID to be used with the attribute operations (set, get, etc).
void renumber_vars_attributes(Attribute attrs, int vmap[], int max_vars);
This routine renumbers the variables in the inheritable attribute terms.
void replace_int_attribute(Attribute a, int id, int val, int n);
This routine replaces that n-th int attribute for given attribute ID.

A fatal error occurs if the ID does not refer to an int type attribute (see register_attribute), or if there are not n attributes identified by ID.


void replace_term_attribute(Attribute a, int id, Term val, int n);
This routine replaces that n-th term attribute for given ID. The term that is already there is zapped, and the new term is NOT copied.

A fatal error occurs if the ID does not refer to a Term type attribute (see register_attribute), or if there are not n attributes identified by ID.


Attribute set_int_attribute(Attribute a, int id, int val);
This routine appends an pair to a list of attributes.

A fatal error occurs if the ID does not refer to an integer type attribute (see register_attribute).


Attribute set_string_attribute(Attribute a, int id, char *val);
This routine appends an pair to a list of attributes. If the string is not already in the symbol table, it is inserted (which copies the string).

A fatal error occurs if the ID does not refer to a string type attribute (see register_attribute).


Attribute set_term_attribute(Attribute a, int id, Term val);
This routine appends an pair to a list of attributes. The term is not copied.

A fatal error occurs if the ID does not refer to a Term type attribute (see register_attribute).


void set_vars_attributes(Attribute attrs, char *vnames[], int max_vars);
This routine sets the variables in the inheritable attribute terms.
BOOL string_attribute_member(Attribute a, int id, char *s);
This routine checks of a list of attributes contains a particular attribute/value.

A fatal error occurs if the ID does not refer to a string type attribute (see register_attribute).


Attribute term_to_attributes(Term t, char *operator);
This routine takes a term representing a list of attributes and builds list of attributes. The input term form is a binary term, constructed with the given operator, with the attributes at the leaves. For example,
    label("hi there!") # answer(XGK(x,y,z)) # hint_wt(32)
If anuthing goes wrong, a fatal error occurs.
Plist vars_in_attributes(Attribute attrs);
This routine returns the set of variables (as a Plist) in the inheritable attributes.
void zap_attributes(Attribute a);
This routine frees a list of attributes and any associated memory. In particular, the terms in term attributes are zapped.

Public Definitions in File attrib.h

typedef enum { INT_ATTRIBUTE,
	       STRING_ATTRIBUTE,
               TERM_ATTRIBUTE
             } Attribute_type;

typedef struct attribute * Attribute;


Introduction

This package is about lists of attributes. Each attribute is a pair (attribute-id, attribute-value). Each attribute-id is associated with a data type.

To use an attribute, you first have to call register_attribute(), giving and ID, name, and type of the attribute. The ID is used with the "set" and "get" operations.

For example,

  register_attribute(label_attr, "label", STRING_ATTRIBUTE);
  ...
  Attribute a = set_string_attribute(NULL, label_attr, "clause_32");
  ...
  char *s = get_string_attribute(a, label_attr, 1);