]> git.evergreen-ils.org Git - OpenSRF.git/blob - include/opensrf/string_array.h
In osrfNewHash(): specify a size for the osrfList used as a hash table,
[OpenSRF.git] / include / opensrf / string_array.h
1 #ifndef STRING_ARRAY_H
2 #define STRING_ARRAY_H
3
4 #include <stdio.h>
5
6 #include <opensrf/utils.h>
7 #include <opensrf/log.h>
8 #include <opensrf/osrf_list.h>
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 #define STRING_ARRAY_MAX_SIZE 4096
15
16 #define OSRF_STRING_ARRAY_FREE(arr) osrfListFree( (osrfList*) (arr) )
17
18 typedef struct {
19     osrfList list;
20         int size;    // redundant with osrfList.size
21 } osrfStringArray;
22
23 osrfStringArray* osrfNewStringArray( int size );
24
25 void osrfStringArrayAdd( osrfStringArray*, const char* str );
26
27 char* osrfStringArrayGetString( osrfStringArray* arr, int index );
28
29 /* returns true if this array contains the given string */
30 int osrfStringArrayContains(
31         const osrfStringArray* arr, const char* string );
32
33 void osrfStringArrayFree( osrfStringArray* );
34
35 void osrfStringArrayRemove( osrfStringArray* arr, const char* str );
36
37 /**
38   Parse a string into tokens separated by a specified delimiter,
39   as if by strtok() or strtok_r().  Load the tokens into an
40   osrfStringArray.
41   */
42 osrfStringArray* osrfStringArrayTokenize( const char* src, char delim );
43
44 #ifdef __cplusplus
45 }
46 #endif
47
48 #endif