sexp_ops.h(3)

sexp_ops.h(3) Library Functions Manual sexp_ops.h(3)

NAME

sexp_ops.h -

A collection of useful operations to perform on s-expressions.

SYNOPSIS

#include 'sexp.h'

Defines


#define hd_sexp(s) ((s)->list)
#define tl_sexp(s) ((s)->list->next)
#define next_sexp(s) ((s)->next)
#define reset_pcont(c) ((c)->lastPos = NULL)

Functions


sexp_t * find_sexp (const char *name, sexp_t *start)
sexp_t * bfs_find_sexp (const char *name, sexp_t *start)
int sexp_list_length (const sexp_t *sx)
sexp_t * copy_sexp (const sexp_t *sx)

Detailed Description

A collection of useful operations to perform on s-expressions.

A set of routines for operating on s-expressions.

Define Documentation

#define hd_sexp(s) ((s)->list) Return the head of a list s by reference, not copy.

#define next_sexp(s) ((s)->next) Return the element following the argument s.

#define reset_pcont(c) ((c)->lastPos = NULL) Reset the continuation c by setting the lastPos pointer to NULL.

#define tl_sexp(s) ((s)->list->next) Return the tail of a list s by reference, not copy.

Function Documentation

sexp_t* bfs_find_sexp (const char *name, sexp_t *start) Breadth first search for s-expressions. Depth first search will find the first occurance of a string in an s-expression by basically finding the earliest occurance in the string representation of the expression itself. Breadth first search will find the first occurance of a string in relation to the structure of the expression itself (IE: the instance with the lowest depth will be found).

Parameters:

name Value to search for.
start Root element of the s-expression to search from.

Returns:

If the value is found, return a pointer to the first occurrence in a breadth-first traversal. NULL if not found.

sexp_t* copy_sexp (const sexp_t *sx) Copy an s-expression. This is a deep copy - so the resulting s-expression shares no pointers with the original. The new one can be changed without damaging the contents of the original.

Parameters:

sx S-expression to copy.

Returns:

A pointer to a copy of sx. This is a deep copy, so no memory is shared between the original and the returned copy.

sexp_t* find_sexp (const char *name, sexp_t *start) Find an atom in a sexpression data structure and return a pointer to it. Return NULL if the string doesn't occur anywhere as an atom. This is a depth-first search algorithm.

Parameters:

name Value to search for.
start Root element of the s-expression to search from.

Returns:

If the value is found, return a pointer to the first occurrence in a depth-first traversal. NULL if not found.

int sexp_list_length (const sexp_t *sx) Given an s-expression, determine the length of the list that it encodes. A null expression has length 0. An atom has length 1. A list has length equal to the number of sexp_t elements from the list head to the end of the ->next linked list from that point.

Parameters:

sx S-expression input.

Returns:

Number of sexp_t elements at the same level as sx, 0 for NULL, 1 for an atom.

Author

Generated automatically by Doxygen for Small, Fast S-Expression Library from the source code.

Thu Nov 21 2013 Small, Fast S-Expression Library