2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
5 * WvStrings are used a lot more often than WvStringLists, so the List need
6 * not be defined most of the time. Include this file if you need it.
9 #ifndef __WVSTRINGLIST_H
10 #define __WVSTRINGLIST_H
13 #include "wvlinklist.h"
17 DeclareWvList2(WvStringListBase
, WvString
);
20 * This is a WvList of WvStrings, and is a really handy way to parse
21 * strings. If you ever find yourself using strtok(3) or strpbrk(3),
22 * or find yourself needing to parse a line of input, WvStringList,
23 * WvStringList::split(), and WvStringList::popstr() are probably what you
24 * want, and avoid all sorts of nasty security bugs caused by doing it any
27 class WvStringList
: public WvStringListBase
29 // copy constructor: not defined anywhere!
30 WvStringList(const WvStringList
&l
);
33 * Instatiate a new WvStringList()
38 * concatenates all elements of the list seperating on joinchars
40 WvString
join(const char *joinchars
= " ") const;
43 * split s and form a list ignoring splitchars (except at beginning and end)
44 * ie. " happy birthday to you" split on " " will populate the list with
51 void split(WvStringParm s
, const char *splitchars
= " \t\r\n",
54 * split s and form a list creating null entries when there are multiple
56 * ie " happy birthday to you" split on " " will populate the list with
66 void splitstrict(WvStringParm s
, const char *splitchars
= " \t\r\n",
71 * split s and form a list ignoring regex (except at beginning and end)
72 * Note that there is no splitstrict for regexes, since the differece is
73 * taken care of through the regex (...)+ syntax
75 void split(WvStringParm s
, const WvRegex
®ex
, int limit
= 0);
79 * populate the list from an array of strings
81 void fill(const char * const *array
);
83 void append(WvStringParm str
);
84 void append(WVSTRING_FORMAT_DECL
)
85 { append(WvString(WVSTRING_FORMAT_CALL
)); }
86 void append(WvString
*strp
, bool autofree
, char *id
= NULL
);
89 * get the first string in the list, or an empty string if the list is empty.
90 * Removes the returned string from the list.
95 #endif // __WVSTRINGLIST_H