]> git.evergreen-ils.org Git - OpenSRF.git/blob - include/opensrf/string_array.h
Docs: Keep all source syntax consistent in README
[OpenSRF.git] / include / opensrf / string_array.h
1 /**
2         @file string_array.h
3         @brief Header for osrfStringArray, a vector of strings.
4
5         An osrfStringArray manages an array of character pointers pointing to nul-terminated
6         strings.  New entries are added at the end.  When a string is removed, entries above
7         it are shifted down to fill in the gap.
8 */
9
10 #ifndef STRING_ARRAY_H
11 #define STRING_ARRAY_H
12
13 #include <stdio.h>
14
15 #include <opensrf/utils.h>
16 #include <opensrf/log.h>
17 #include <opensrf/osrf_list.h>
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 /**
24         @brief Maximum number of strings in an osrfStringArray.
25
26         This ostensible limit is not enforced.  If you exceed it, you'll get an error message,
27         but only as a slap on the wrist.  You'll still get your big list of strings.
28 */
29 #define STRING_ARRAY_MAX_SIZE 4096
30
31 /** @brief Macro version of osrfStringArrayFree() */
32 #define OSRF_STRING_ARRAY_FREE(arr) osrfListFree( (osrfList*) (arr) )
33
34 /**
35         @brief Structure of an osrfStringArray.
36 */
37 typedef struct {
38         /** @brief The underlying container of pointers. */
39     osrfList list;
40         /** @brief The number of strings stored. */
41         int size;    // redundant with list.size
42 } osrfStringArray;
43
44 osrfStringArray* osrfNewStringArray( int size );
45
46 void osrfStringArrayAdd( osrfStringArray*, const char* str );
47
48 const char* osrfStringArrayGetString( const osrfStringArray* arr, int index );
49
50 int osrfStringArrayContains(
51         const osrfStringArray* arr, const char* string );
52
53 void osrfStringArrayFree( osrfStringArray* );
54
55 void osrfStringArrayRemove( osrfStringArray* arr, const char* str );
56
57 osrfStringArray* osrfStringArrayTokenize( const char* src, char delim );
58
59 #ifdef __cplusplus
60 }
61 #endif
62
63 #endif