|
NAMEsinit , sclear ,
sfree , sadd ,
sadd2 , sadd_attach ,
saddp , sdel ,
sins , sfind ,
find , scfind ,
cfind , sget2 ,
scget2 , sgetp ,
scgetp , simport ,
scopy , sarray ,
mkarray , charize ,
free_values , count_values ,
copy_values —
string vector manipulation functions
SYNOPSIS#include <strfunc.h>
Create, clear and destroy the string vector
void
void
Add values to the end of the vector
int
int
int
Delete an element of the vector. Return value is -1 in case of an
error, or the number of the remaining elements.
Insert data to the vector before num's element. Return value is -1
in case of an error, or the newly added element's index.
Find element within the vector
ssize_t
ssize_t
ssize_t
Get an appropriate element from the vector b
when tofind is found in vector a
char *
char *
char *
Import values
Copy string vector
Create the string array
char **
Self-desriptive
void
size_t
int
DESCRIPTIONThese routines give the user a method of manipulating string vectors (arrays). To create a string vector you must invokesinit ()
first. Then you will be able to do whatever you want using functions with
svect * parameter. After all the necessary operations, the
svect * structure must be freed with
sfree ().
After the vector creation, you might want to add a values to it.
It can be done using
There is two functions to clear the vector,
EXAMPLESHere is an example of creating and filling the string vectors.void main() { svect *sl; /* Declare a pointer to a string vector */ sl = sinit(); /* Create and initialize */ /* Add some values using the different approaches */ sadd(sl, "one"); sadd2(sl, "two", 3); sadd_attach(sl, sf_strdup("three"), 5); /* Numbers are zero-based, * so it will delete the second element, * "two" */ sdel(sl, 1); /* This will produce: * "one, three" */ printf("%s\n", sjoin(sl, ", ")); /* Destroy the vector */ sfree(sl); }; And here is the usage example. void test(svect *sl) { int i; /* We will show some hidden info. * Refer to strfunc.h for the definition * of the svect * structure */ printf("sl has %d elements\n", sl->count); printf("the maximum element length is %d\n", sl->maxlen); printf("elements are:\n"); for(i=0; i < sl->count; i++) printf("element %d: [%s] with length %d\n", i, sl->list[i], sl->lens[i]); printf("join them together: [%s]\n", sjoin(sl, "|")); }; SEE ALSOstrfunc(3), sf_split(3), sf_misc(3).AUTHORSLev Walkin <vlm@lionet.info>
Visit the GSP FreeBSD Man Page Interface. |