libicl.h File Reference

#include <stdlib.h>
#include "glib.h"

Go to the source code of this file.

Defines

#define EXTERN   extern
#define FALSE   0
#define TRUE   1
#define CHECK_LEAKS()
#define ICL_TRUE   icl_True()
#define ICL_FALSE   icl_False()
#define ICL_EMPTY   icl_Empty()
#define ICL_VAR   icl_Var()
#define icl_Free(A)   if (A) {icl_FreeTerm(A); A = 0;}
#define icl_copy_term(T, V)   icl_copy_term_nonrec(T,V)

Typedefs

typedef iclTerm ICLTerm
typedef iclListType ICLListType
typedef iclGroupType ICLGroupType
typedef iclStructType ICLStructType

Enumerations

enum  ICLType {
  icl_no_type, icl_int_type, icl_float_type, icl_str_type,
  icl_struct_type, icl_list_type, icl_group_type, icl_var_type,
  icl_callback_type, icl_dataq_type
}

Functions

EXTERN ICLTermicl_NewTermFromString (char *s)
 Returns a pointer to a new structured Icl term given string containing an ICL expression, or NULL if a valid object could not be created.
EXTERN ICLTermicl_NewTermFromData (char *data, size_t len)
 Create a new IclTerm from the given data.
EXTERN char * icl_NewStringFromTerm (ICLTerm const *t)
 Creates a string representation from an ICL term.
EXTERN char * icl_NewStringStructFromTerm (ICLTerm *t)
 Creates a string representation from an ICL term.
EXTERN char * icl_UnquotedStringFromStr (ICLTerm *t)
 Get an unquoted string from an IclStr.
EXTERN char * icl_ForcedQuotedStringFromStr (ICLTerm *t)
 Get a string from an IclStr, quoting it even if the quotes are not necessary.
EXTERN char * icl_MinimallyQuotedStringFromStr (ICLTerm *t)
 Get a minimally quoted string from an IclStr.
EXTERN int icl_WriteTerm (ICLTerm *t)
 Writes a term to standard out.
EXTERN ICLTermicl_CopyTerm (ICLTerm const *t)
 Creates a copy of the term, all in new memory.
EXTERN ICLListTypeicl_CopyListType (ICLListType *list)
 Creates a new copy of a ListType list.
EXTERN ICLTermicl_NewInt (gint64 i)
 Creates a new ICL object of type integer.
EXTERN ICLTermicl_NewFloat (double f)
 Creates a new ICL object of type float.
EXTERN ICLTermicl_NewStr (char const *s)
 Creates a new ICL object of type string.
EXTERN ICLTermicl_NewVar (char *name)
 Creates a new ICL object of type variable.
EXTERN ICLTermicl_NewStruct (char const *functor, int arity,...)
 Creates a new ICL object of type structure.
EXTERN ICLTermicl_NewStructFromList (char const *functor, ICLTerm *args)
 Creates a new ICL object of type structure given args as a list.
EXTERN ICLListTypeicl_NewCons (ICLTerm *elt, ICLListType *tail)
 Returns a new element of ICLListType.
EXTERN ICLTermicl_NewList (ICLListType *list)
 Creates a new ICL object of type list.
EXTERN ICLTermicl_NewGroup (char sChar, char *sep, ICLListType *list)
 Creates a new ICL object of type group.
EXTERN ICLTermicl_NewDataQ (void const *data, size_t dataLen)
EXTERN void icl_FreeTerm (ICLTerm *elt)
EXTERN void icl_FreeTermSingle (ICLTerm *elt)
EXTERN int icl_IsList (ICLTerm const *elt)
 Returns TRUE if object is of type List.
EXTERN int icl_IsGroup (ICLTerm const *elt)
 Returns TRUE if object is of type Group.
EXTERN int icl_IsStruct (ICLTerm const *elt)
 Returns TRUE if object is of type Struct.
EXTERN int icl_IsStr (ICLTerm const *elt)
 Returns TRUE if object is of type Str.
EXTERN int icl_IsVar (ICLTerm const *elt)
 Returns TRUE if object is of type Var.
EXTERN int icl_IsInt (ICLTerm const *elt)
 Returns TRUE if object is of type Int.
EXTERN int icl_IsFloat (ICLTerm const *elt)
 Returns TRUE if object is of type Float.
EXTERN int icl_IsDataQ (ICLTerm const *elt)
EXTERN int icl_IsValid (ICLTerm const *elt)
 Returns TRUE if object is valid.
EXTERN int icl_IsGround (ICLTerm const *elt)
EXTERN void * icl_DataQ (ICLTerm const *elt)
 Get the data associated with this ICLTerm if it is of type icl_dataq_type.
EXTERN size_t icl_DataQLen (ICLTerm const *elt)
EXTERN size_t icl_Len (ICLTerm const *elt)
 Returns 0 if invalid.
EXTERN gint64 icl_Int (ICLTerm const *elt)
 Returns the value for an ICL int.
EXTERN double icl_Float (ICLTerm const *elt)
 Returns the value for an ICL float.
EXTERN char * icl_Str (ICLTerm const *elt)
 Returns the value for an ICL str (minimally quoted), struct (functor), or an ICL var (returns name).
EXTERN char * icl_Functor (ICLTerm const *elt)
 Returns the functor for an ICL struct.
EXTERN ICLListTypeicl_Arguments (ICLTerm const *elt)
 Returns a pointer to the list of arguments for an ICL structure.
EXTERN int icl_GetGroupChars (ICLTerm const *group, char *startC, char **sep)
 Returns the start character and separators for a group.
EXTERN int icl_Arity (ICLTerm const *inTerm)
 Return the arity of an incoming term.
EXTERN int icl_ReplaceElement (ICLTerm *term, int index, ICLTerm *replacement, int freeReplaced)
 Replace the element at the given index with the replacement term.
EXTERN int icl_ReplaceUnifying (ICLTerm *term, ICLTerm const *selector, ICLTerm const *replacement, int freeReplaced)
 Replace elements that unify with the selector with the replacement term.
EXTERN ICLListTypeicl_List (ICLTerm const *elt)
 Returns a pointer to the list of elements for an ICL list.
EXTERN ICLListTypeicl_ListNext (ICLListType const *t)
EXTERN ICLTermicl_ListElt (ICLListType const *t)
EXTERN ICLListTypeicl_ListCopy (ICLTerm const *elt)
 Returns a pointer to the list of elements for an ICL list.
EXTERN ICLTermicl_NthTerm (ICLTerm const *elt, int n)
 Returns a pointer to the Nth argument in a structure, or the Nth element of a list or of a group.
EXTERN int icl_NthTermAsInt (ICLTerm const *elt, int n, int *Value)
 Returns the integer value of the nth element in a term.
EXTERN int icl_NumTerms (ICLTerm const *elt)
 Returns the number of terms in a list (or group) object, or the number of arguments in a structure.
EXTERN int icl_ListLen (ICLTerm const *elt)
 Returns the number of terms in a list (or group) object, or the number of arguments in a structure.
EXTERN int icl_AddToList (ICLTerm *list, ICLTerm *elt, int atEnd)
 Adds an object at the beginning or the end of the list or a group.
EXTERN int icl_ClearList (ICLTerm *list)
 Removes all the components of the incoming list.
EXTERN int icl_SortList (ICLTerm *list, int(*user_function)(ICLTerm *Elt1, ICLTerm *Elt2))
 Sorts the incoming list, using the given sorting function.
EXTERN int icl_Append (ICLTerm *list1, ICLTerm *list2)
 Append list2 to the end of list1.
EXTERN int icl_AppendCopy (ICLTerm *list1, ICLTerm const *list2)
 Append a copy of list2 to the end of list1.
EXTERN int icl_Union (ICLTerm *list1, ICLTerm *list2, ICLTerm **dest)
 Merges two incoming lists into a third one.
EXTERN int icl_ListHasMoreElements (ICLListType const *l)
 Determine if you have iterated to the end of a list.
EXTERN ICLListTypeicl_ListNextElement (ICLListType const *l)
 Return the next element in a list.
EXTERN ICLTermicl_ListElement (ICLListType const *list)
 Return the icl term associated with this list element.
EXTERN int icl_ListDelete (ICLTerm *list, ICLTerm *elem, ICLTerm **residue)
 Return TRUE if list is a list.
EXTERN ICLTermicl_GenerateSimpleUnifyingTerm (ICLTerm const *term)
 Generate a general unifying term for the given term.
EXTERN int icl_Unify (ICLTerm const *t1, ICLTerm const *t2, ICLTerm **answer)
 Perform true unification and return resulting term.
EXTERN int icl_ParamValue (char *func, ICLTerm *match, ICLTerm *params, ICLTerm **answer)
 Searches for a parameter in a parameter list.
EXTERN gint64 icl_ParamValueAsInt (char *func, ICLTerm *params, gint64 *Value)
 Returns integer value for a parameter in a parameter list.
EXTERN int icl_Member (ICLTerm const *elt, ICLTerm const *list, ICLTerm **res)
 Searches for an element in a list, returning unification.
EXTERN char * icl_stFixQuotes (char *s)
 Converts any '' marks inside a string to just ', and removes any external quote marks around the string.
EXTERN int icl_stIsProperlyQuoted (char *s)
 return TRUE if the given string is properly quoted
EXTERN int icl_list_has_more_elements (ICLListType *l)
 Determine if you have iterated to the end of a list.
EXTERN ICLListTypeicl_list_next_element (ICLListType *l)
 Return the next element in a list.
EXTERN ICLTermicl_list_element (ICLListType *list)
 Return the icl term associated with this list element.
EXTERN int icl_list_delete (ICLTerm *list, ICLTerm *elem, ICLTerm **residue)
 Return TRUE if list is a list.
EXTERN int icl_append_to_list (ICLTerm *list1, ICLTerm *list2, ICLTerm **list3)
 Append list2 to the end of list1 and place the results in list3.
EXTERN ICLTermicl_True ()
 Convenience functions which return a pointer to a commonly used datastructure.
EXTERN ICLTermicl_False ()
EXTERN ICLTermicl_Empty ()
EXTERN ICLTermicl_Var ()
EXTERN void icl_stFree (void *p)
 Free a memory pointer (string or term) and set it to NULL afterwards.
EXTERN int icl_match_terms (ICLTerm *t1, ICLTerm *t2, struct dyn_array *vars)
 Returns TRUE if Term1 matches Term2, saving variable bindings as it goes (if requested).
EXTERN ICLTermicl_copy_term_nonrec (ICLTerm const *t, struct dyn_array *vars)
 Creates a copy of the term, all in new memory.
EXTERN void icl_init_dyn_array (struct dyn_array *da)
 Initializes a dynamic array.


Detailed Description

Definition in file libicl.h.


Define Documentation

 
#define CHECK_LEAKS (  ) 

Definition at line 54 of file libicl.h.

#define EXTERN   extern

Definition at line 39 of file libicl.h.

#define FALSE   0

Definition at line 43 of file libicl.h.

#define icl_copy_term ( T,
 )     icl_copy_term_nonrec(T,V)

Definition at line 222 of file libicl.h.

#define ICL_EMPTY   icl_Empty()

Definition at line 202 of file libicl.h.

#define ICL_FALSE   icl_False()

Definition at line 201 of file libicl.h.

#define icl_Free (  )     if (A) {icl_FreeTerm(A); A = 0;}

Definition at line 217 of file libicl.h.

#define ICL_TRUE   icl_True()

Definition at line 200 of file libicl.h.

#define ICL_VAR   icl_Var()

Definition at line 203 of file libicl.h.

#define TRUE   1

Definition at line 44 of file libicl.h.


Typedef Documentation

typedef struct iclGroupType ICLGroupType

Definition at line 68 of file libicl.h.

typedef struct iclListType ICLListType

Definition at line 67 of file libicl.h.

typedef struct iclStructType ICLStructType

Definition at line 69 of file libicl.h.

typedef struct iclTerm ICLTerm

Definition at line 66 of file libicl.h.


Enumeration Type Documentation

enum ICLType

Enumerator:
icl_no_type 
icl_int_type 
icl_float_type 
icl_str_type 
icl_struct_type 
icl_list_type 
icl_group_type 
icl_var_type 
icl_callback_type 
icl_dataq_type 

Definition at line 57 of file libicl.h.


Function Documentation

EXTERN int icl_AddToList ( ICLTerm list,
ICLTerm elt,
int  atEnd 
)

Adds an object at the beginning or the end of the list or a group.

Returns:
TRUE if the object can be added

Definition at line 2820 of file libicl.c.

EXTERN int icl_Append ( ICLTerm list1,
ICLTerm list2 
)

Append list2 to the end of list1.

Definition at line 2981 of file libicl.c.

EXTERN int icl_append_to_list ( ICLTerm list1,
ICLTerm list2,
ICLTerm **  list3 
)

Append list2 to the end of list1 and place the results in list3.

Definition at line 3746 of file libicl.c.

EXTERN int icl_AppendCopy ( ICLTerm list1,
ICLTerm const *  list2 
)

Append a copy of list2 to the end of list1.

Definition at line 2960 of file libicl.c.

EXTERN ICLListType* icl_Arguments ( ICLTerm const *  elt  ) 

Returns a pointer to the list of arguments for an ICL structure.

If not valid, returns NULL.

Definition at line 2692 of file libicl.c.

EXTERN int icl_Arity ( ICLTerm const *  elt  ) 

Return the arity of an incoming term.

Parameters:
elt the incoming term
Returns:
the arity of elt, or -1 for elements which are not lists, groups or structs

Definition at line 3035 of file libicl.c.

EXTERN int icl_ClearList ( ICLTerm list  ) 

Removes all the components of the incoming list.

Returns:
TRUE if successful

Definition at line 2862 of file libicl.c.

EXTERN ICLTerm* icl_copy_term_nonrec ( ICLTerm const *  t,
struct dyn_array *  vars 
)

Creates a copy of the term, all in new memory.

Deref vars from binding list if available. Nonrecursive.

Definition at line 1451 of file libicl.c.

EXTERN ICLListType* icl_CopyListType ( ICLListType list  ) 

Creates a new copy of a ListType list.

Definition at line 1735 of file libicl.c.

EXTERN ICLTerm* icl_CopyTerm ( ICLTerm const *  t  ) 

Creates a copy of the term, all in new memory.

Definition at line 1724 of file libicl.c.

EXTERN void* icl_DataQ ( ICLTerm const *  elt  ) 

Get the data associated with this ICLTerm if it is of type icl_dataq_type.

Returns:
a pointer to the data, or NULL
See also:
icl_dataq_type

Definition at line 2573 of file libicl.c.

EXTERN size_t icl_DataQLen ( ICLTerm const *  elt  ) 

Definition at line 2585 of file libicl.c.

EXTERN ICLTerm* icl_Empty (  ) 

Definition at line 3655 of file libicl.c.

EXTERN ICLTerm* icl_False (  ) 

Definition at line 3641 of file libicl.c.

EXTERN double icl_Float ( ICLTerm const *  elt  ) 

Returns the value for an ICL float.

If not valid, returns 0.0.

Definition at line 2634 of file libicl.c.

EXTERN char* icl_ForcedQuotedStringFromStr ( ICLTerm t  ) 

Get a string from an IclStr, quoting it even if the quotes are not necessary.

The newly created string should be freed with icl_stFree(...)

Returns:
the new string or NULL if t is not an atom

Definition at line 1185 of file libicl.c.

EXTERN void icl_FreeTerm ( ICLTerm elt  ) 

Definition at line 2265 of file libicl.c.

EXTERN void icl_FreeTermSingle ( ICLTerm elt  ) 

Definition at line 2257 of file libicl.c.

EXTERN char* icl_Functor ( ICLTerm const *  elt  ) 

Returns the functor for an ICL struct.

If not valid, returns NULL. Otherwise returns a pointer to the true string value, which should not be deallocated or changed!!!

Definition at line 2674 of file libicl.c.

EXTERN ICLTerm* icl_GenerateSimpleUnifyingTerm ( ICLTerm const *  term  ) 

Generate a general unifying term for the given term.

Returns:
ICLTerm* a term that unifies with the given one. Must be freed using icl_FreeTerm(ICLTerm*)

Definition at line 3771 of file libicl.c.

EXTERN int icl_GetGroupChars ( ICLTerm const *  group,
char *  startC,
char **  sep 
)

Returns the start character and separators for a group.

If not valid group, returns FALSE.

example:

   {a ; b ; c}  returns '{' and ";"
 

Definition at line 2711 of file libicl.c.

EXTERN void icl_init_dyn_array ( struct dyn_array *  da  ) 

Initializes a dynamic array.

Definition at line 143 of file libicl.c.

EXTERN gint64 icl_Int ( ICLTerm const *  elt  ) 

Returns the value for an ICL int.

If not valid, returns 0.

Definition at line 2616 of file libicl.c.

EXTERN int icl_IsDataQ ( ICLTerm const *  elt  ) 

Definition at line 2516 of file libicl.c.

EXTERN int icl_IsFloat ( ICLTerm const *  elt  ) 

Returns TRUE if object is of type Float.

Definition at line 2509 of file libicl.c.

EXTERN int icl_IsGround ( ICLTerm const *  elt  ) 

Definition at line 2537 of file libicl.c.

EXTERN int icl_IsGroup ( ICLTerm const *  elt  ) 

Returns TRUE if object is of type Group.

Definition at line 2455 of file libicl.c.

EXTERN int icl_IsInt ( ICLTerm const *  elt  ) 

Returns TRUE if object is of type Int.

Definition at line 2498 of file libicl.c.

EXTERN int icl_IsList ( ICLTerm const *  elt  ) 

Returns TRUE if object is of type List.

Definition at line 2445 of file libicl.c.

EXTERN int icl_IsStr ( ICLTerm const *  elt  ) 

Returns TRUE if object is of type Str.

Definition at line 2476 of file libicl.c.

EXTERN int icl_IsStruct ( ICLTerm const *  elt  ) 

Returns TRUE if object is of type Struct.

Definition at line 2465 of file libicl.c.

EXTERN int icl_IsValid ( ICLTerm const *  elt  ) 

Returns TRUE if object is valid.

Definition at line 2527 of file libicl.c.

EXTERN int icl_IsVar ( ICLTerm const *  elt  ) 

Returns TRUE if object is of type Var.

Definition at line 2487 of file libicl.c.

EXTERN size_t icl_Len ( ICLTerm const *  elt  ) 

Returns 0 if invalid.

Definition at line 2600 of file libicl.c.

EXTERN ICLListType* icl_List ( ICLTerm const *  elt  ) 

Returns a pointer to the list of elements for an ICL list.

If not valid, returns NULL. Also works for an icl_Struct (equivalent to icl_Arguments) or an icl_Group.

Definition at line 2730 of file libicl.c.

EXTERN int icl_list_delete ( ICLTerm list,
ICLTerm elem,
ICLTerm **  residue 
)

Return TRUE if list is a list.

Residue is list with all the elements that unify with elem removed.

Definition at line 3726 of file libicl.c.

EXTERN ICLTerm* icl_list_element ( ICLListType list  ) 

Return the icl term associated with this list element.

Definition at line 3717 of file libicl.c.

EXTERN int icl_list_has_more_elements ( ICLListType l  ) 

Determine if you have iterated to the end of a list.

Definition at line 3696 of file libicl.c.

EXTERN ICLListType* icl_list_next_element ( ICLListType l  ) 

Return the next element in a list.

Definition at line 3706 of file libicl.c.

EXTERN ICLListType* icl_ListCopy ( ICLTerm const *  elt  ) 

Returns a pointer to the list of elements for an ICL list.

If not valid, returns NULL. Also works for an icl_Struct (equivalent to icl_Arguments) or an icl_Group.

Definition at line 2787 of file libicl.c.

EXTERN int icl_ListDelete ( ICLTerm list,
ICLTerm elem,
ICLTerm **  residue 
)

Return TRUE if list is a list.

Residue is list with all the elements that unify with elem removed. Residue will contain entirely new memory

Definition at line 2939 of file libicl.c.

EXTERN ICLTerm* icl_ListElement ( ICLListType const *  list  ) 

Return the icl term associated with this list element.

Definition at line 2927 of file libicl.c.

EXTERN ICLTerm* icl_ListElt ( ICLListType const *  t  ) 

Definition at line 2757 of file libicl.c.

EXTERN int icl_ListHasMoreElements ( ICLListType const *  l  ) 

Determine if you have iterated to the end of a list.

Definition at line 2900 of file libicl.c.

EXTERN int icl_ListLen ( ICLTerm const *  elt  ) 

Returns the number of terms in a list (or group) object, or the number of arguments in a structure.

Returns 0 for elements which are not lists, groups or structs. Same as icl_NumTerms; convenience function for lists.

Definition at line 3073 of file libicl.c.

EXTERN ICLListType* icl_ListNext ( ICLListType const *  t  ) 

Definition at line 2751 of file libicl.c.

EXTERN ICLListType* icl_ListNextElement ( ICLListType const *  l  ) 

Return the next element in a list.

Definition at line 2914 of file libicl.c.

EXTERN int icl_match_terms ( ICLTerm t1,
ICLTerm t2,
struct dyn_array *  vars 
)

Returns TRUE if Term1 matches Term2, saving variable bindings as it goes (if requested).

Parameters:
t1 term to match (unify)
t2 term to match (unify)
vars a list where variable bindings will be stored during unification. If vars is NULL, no var bindings are kept, acting as a simple match instead of a true unify.
Returns:
the stringlist of vars/bindings which must be deallocated when finished (free_dyn_list)

Definition at line 3323 of file libicl.c.

EXTERN int icl_Member ( ICLTerm const *  elt,
ICLTerm const *  list,
ICLTerm **  res 
)

Searches for an element in a list, returning unification.

Returns:
TRUE if successful, FALSE otherwise (doesn't change res). If res is NULL, just returns TRUE if element was found

Definition at line 3233 of file libicl.c.

EXTERN char* icl_MinimallyQuotedStringFromStr ( ICLTerm t  ) 

Get a minimally quoted string from an IclStr.

The newly created string should be freed with icl_stFree(...). This is equivalent to calling icl_NewStringFromTerm(t), but is named consistently with the other quoted string functions.

Returns:
the new string or NULL if t is not an atom

Definition at line 1196 of file libicl.c.

EXTERN ICLListType* icl_NewCons ( ICLTerm elt,
ICLListType tail 
)

Returns a new element of ICLListType.

Definition at line 2152 of file libicl.c.

EXTERN ICLTerm* icl_NewDataQ ( void const *  data,
size_t  dataLen 
)

Definition at line 2167 of file libicl.c.

EXTERN ICLTerm* icl_NewFloat ( double  f  ) 

Creates a new ICL object of type float.

Parameters:
f double value for the structure
Returns:
a pointer to the new ICL object

Definition at line 1774 of file libicl.c.

EXTERN ICLTerm* icl_NewGroup ( char  startC,
char *  separator,
ICLListType list 
)

Creates a new ICL object of type group.

Parameters:
startC a character which initially delimits the group (e.g. '{')
separator separator character
list a value of type list, probably returned by icl_NewCons()
Returns:
a pointer to the new ICL object
See also:
icl_NewCons

Definition at line 2212 of file libicl.c.

EXTERN ICLTerm* icl_NewInt ( gint64  i  ) 

Creates a new ICL object of type integer.

Parameters:
i integer value for the structure
Returns:
a pointer to the new ICL object

Definition at line 1749 of file libicl.c.

EXTERN ICLTerm* icl_NewList ( ICLListType list  ) 

Creates a new ICL object of type list.

Parameters:
list a value of type list, probably returned by icl_NewCons()
Returns:
a pointer to the new ICL object
See also:
icl_NewCons

Definition at line 2239 of file libicl.c.

EXTERN ICLTerm* icl_NewStr ( char const *  s  ) 

Creates a new ICL object of type string.

Uses a copy of the given string.

Parameters:
s string value for the structure
Returns:
a pointer to the new ICL object or NULL if s is not valid

Definition at line 1958 of file libicl.c.

EXTERN char* icl_NewStringFromTerm ( ICLTerm const *  t  ) 

Creates a string representation from an ICL term.

The string value is created in a new space which should be icl_stFree'd when finished using.

Definition at line 1030 of file libicl.c.

EXTERN char* icl_NewStringStructFromTerm ( ICLTerm t  ) 

Creates a string representation from an ICL term.

The string value is created in a new space which should be icl_stFree'd when finished using.

See also:
icl_stFree

Definition at line 1225 of file libicl.c.

EXTERN ICLTerm* icl_NewStruct ( char const *  functor,
int  arity,
  ... 
)

Creates a new ICL object of type structure.

Uses a copy of functor.

Parameters:
functor string name for the structure
arity the new structure's arity
... a variable length argument list containing pointers to ICLTerms, owned by returned ICLTerm
Returns:
a pointer to the new ICL object or NULL if not valid args

Definition at line 2101 of file libicl.c.

EXTERN ICLTerm* icl_NewStructFromList ( char const *  functor,
ICLTerm args 
)

Creates a new ICL object of type structure given args as a list.

Parameters:
functor string name for the structure
args an icl List object; will be owned by the returned ICLTerm
Returns:
a pointer to the new ICL object or NULL if invalid args or invalid functor

Definition at line 2059 of file libicl.c.

EXTERN ICLTerm* icl_NewTermFromData ( char *  data,
size_t  len 
)

Create a new IclTerm from the given data.

Parameters:
data the data representing the term.
len the length of the data. If data is a char*, this does not include the ending '' character.

Definition at line 993 of file libicl.c.

EXTERN ICLTerm* icl_NewTermFromString ( char *  t  ) 

Returns a pointer to a new structured Icl term given string containing an ICL expression, or NULL if a valid object could not be created.

Deprecated:
Use icl_NewTermFromData() instead

Definition at line 1009 of file libicl.c.

EXTERN ICLTerm* icl_NewVar ( char *  name  ) 

Creates a new ICL object of type variable.

Parameters:
name string value containing the name for the structure
Returns:
a pointer to the new ICL object or NULL if name isn't valid

Definition at line 2011 of file libicl.c.

EXTERN ICLTerm* icl_NthTerm ( ICLTerm const *  elt,
int  n 
)

Returns a pointer to the Nth argument in a structure, or the Nth element of a list or of a group.

Returns NULL if an error occurs.

Definition at line 3083 of file libicl.c.

EXTERN int icl_NthTermAsInt ( ICLTerm const *  elt,
int  n,
int *  Value 
)

Returns the integer value of the nth element in a term.

Makes a copy into Value.

Returns:
TRUE if successful, FALSE otherwise (doesn't change Value).

Definition at line 3114 of file libicl.c.

EXTERN int icl_NumTerms ( ICLTerm const *  elt  ) 

Returns the number of terms in a list (or group) object, or the number of arguments in a structure.

Returns 0 for elements which are not lists, groups or structs.

Definition at line 3047 of file libicl.c.

EXTERN int icl_ParamValue ( char *  func,
ICLTerm match,
ICLTerm paramlist,
ICLTerm **  value 
)

Searches for a parameter in a parameter list.

Examples:

   icl_ParamValue("a", ICL_EMPTY, params, NULL) : looks for "a([])"
   icl_ParamValue("a", NULL, params, &value) : returns value like a(X)
 
Parameters:
match may be NULL, or a value to unify against
value may be NULL, in which case just returns TRUE if found
Returns:
TRUE if found

Definition at line 3138 of file libicl.c.

EXTERN gint64 icl_ParamValueAsInt ( char *  func,
ICLTerm paramlist,
gint64 *  Value 
)

Returns integer value for a parameter in a parameter list.

Returns:
TRUE if successful, FALSE otherwise (doesn't change Value)

Definition at line 3208 of file libicl.c.

EXTERN int icl_ReplaceElement ( ICLTerm term,
int  index,
ICLTerm replacement,
int  freeReplaced 
)

Replace the element at the given index with the replacement term.

If freeReplaced is non-zero, icl_FreeTerm(ICLTerm*) is called on the replaced term.

Takes ownership of replacement.

Definition at line 3811 of file libicl.c.

EXTERN int icl_ReplaceUnifying ( ICLTerm term,
ICLTerm const *  selector,
ICLTerm const *  replacement,
int  freeReplaced 
)

Replace elements that unify with the selector with the replacement term.

If freeReplaced is non-zero, icl_FreeTerm(ICLTerm*) is called on the replaced term. Uses copies of replacement. Returns the number of elements replaced.

Definition at line 3840 of file libicl.c.

EXTERN int icl_SortList ( ICLTerm list,
int(*)(ICLTerm *Elt1, ICLTerm *Elt2)  user_function 
)

Sorts the incoming list, using the given sorting function.

Returns:
TRUE if successful

Definition at line 2888 of file libicl.c.

EXTERN char* icl_stFixQuotes ( char *  s  ) 

Converts any '' marks inside a string to just ', and removes any external quote marks around the string.

Calls icl_stRemoveQuotes, followed by icl_stUndoubleQuotes. should be okay for icldataq, since we assume s does not contain an icldataq.

Parameters:
s a string containing an ICL Str.
Returns:
a pointer to the original string, which has been modified appropriately.

Definition at line 269 of file libicl.c.

EXTERN void icl_stFree ( void *  p  ) 

Free a memory pointer (string or term) and set it to NULL afterwards.

Parameters:
p a variable to deallocate
Remarks:

Definition at line 2284 of file libicl.c.

EXTERN int icl_stIsProperlyQuoted ( char *  s  ) 

return TRUE if the given string is properly quoted

Definition at line 1833 of file libicl.c.

EXTERN char* icl_Str ( ICLTerm const *  elt  ) 

Returns the value for an ICL str (minimally quoted), struct (functor), or an ICL var (returns name).

If not valid, returns NULL. Otherwise returns a pointer to the true string value, which should not be deallocated or changed!!!

Definition at line 2654 of file libicl.c.

EXTERN ICLTerm* icl_True (  ) 

Convenience functions which return a pointer to a commonly used datastructure.

The results should not be free'd!

Definition at line 3627 of file libicl.c.

EXTERN int icl_Unify ( ICLTerm const *  t1,
ICLTerm const *  t2,
ICLTerm **  answer 
)

Perform true unification and return resulting term.

Remarks

Returns:
if the two terms unify, returns TRUE and answer will contain the unified term. Otherwise returns FALSE (answer not changed).

Definition at line 3504 of file libicl.c.

EXTERN int icl_Union ( ICLTerm list1,
ICLTerm list2,
ICLTerm **  dest 
)

Merges two incoming lists into a third one.

Allocates memory pointed to by *dest

Returns:
TRUE if successful.

Definition at line 3014 of file libicl.c.

EXTERN char* icl_UnquotedStringFromStr ( ICLTerm t  ) 

Get an unquoted string from an IclStr.

The newly created string should be freed with icl_stFree(...).

Returns:
the new string or NULL if t is not an atom

Definition at line 1174 of file libicl.c.

EXTERN ICLTerm* icl_Var (  ) 

Definition at line 3671 of file libicl.c.

EXTERN int icl_WriteTerm ( ICLTerm t  ) 

Writes a term to standard out.

Returns:
TRUE if the term is valid and could be written

Definition at line 3603 of file libicl.c.


Generated on Wed May 23 17:20:15 2007 using doxygen 1.5.2