WvStreams
wvstringlist.cc
1/*
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4 *
5 * Some helper functions for WvStringList.
6 *
7 * This is blatantly block-copied from WvStringTable, but I don't care! Hah!
8 * (I just know I'm going to regret this someday...)
9 */
10#include "wvstringlist.h"
11#include "strutils.h"
12
13
14WvString WvStringList::join(const char *joinchars) const
15{
16 return ::strcoll_join(*this, joinchars);
17}
18
19void WvStringList::split(WvStringParm s, const char *splitchars,
20 int limit)
21{
22 return ::strcoll_split(*this, s, splitchars, limit);
23}
24
25void WvStringList::splitstrict(WvStringParm s, const char *splitchars,
26 int limit)
27{
28 return ::strcoll_splitstrict(*this, s, splitchars, limit);
29}
30
31void WvStringList::fill(const char * const *array)
32{
33 while (array && *array)
34 {
35 append(new WvString(*array), true);
36 array++;
37 }
38}
39
40
41void WvStringList::append(WvStringParm str)
42{
43 WvStringListBase::append(new WvString(str), true);
44}
45
46
47void WvStringList::append(WvString *strp, bool autofree, char *id)
48{
49 WvStringListBase::append(strp, autofree, id);
50}
51
52
53// get the first string in the list, or an empty string if the list is empty.
54// Removes the returned string from the list.
56{
57 if (isempty())
58 return "";
59
60 WvString s = *first();
61 unlink_first();
62 return s;
63}
64
65
66#ifndef _WIN32
67void WvStringList::split(WvStringParm s, const WvRegex &regex, int limit)
68{
69 return ::strcoll_split(*this, s, regex, limit);
70}
71#endif
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
WvRegex – Unified support for regular expressions.
WvString join(const char *joinchars=" ") const
concatenates all elements of the list seperating on joinchars
void splitstrict(WvStringParm s, const char *splitchars=" \t\r\n", int limit=0)
split s and form a list creating null entries when there are multiple splitchars ie " happy birthday ...
void split(WvStringParm s, const char *splitchars=" \t\r\n", int limit=0)
split s and form a list ignoring splitchars (except at beginning and end) ie.
WvString popstr()
get the first string in the list, or an empty string if the list is empty.
WvString is an implementation of a simple and efficient printable-string class.