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 
14 WvString WvStringList::join(const char *joinchars) const
15 {
16  return ::strcoll_join(*this, joinchars);
17 }
18 
19 void WvStringList::split(WvStringParm s, const char *splitchars,
20  int limit)
21 {
22  return ::strcoll_split(*this, s, splitchars, limit);
23 }
24 
25 void WvStringList::splitstrict(WvStringParm s, const char *splitchars,
26  int limit)
27 {
28  return ::strcoll_splitstrict(*this, s, splitchars, limit);
29 }
30 
31 void WvStringList::fill(const char * const *array)
32 {
33  while (array && *array)
34  {
35  append(new WvString(*array), true);
36  array++;
37  }
38 }
39 
40 
41 void WvStringList::append(WvStringParm str)
42 {
43  WvStringListBase::append(new WvString(str), true);
44 }
45 
46 
47 void 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
67 void WvStringList::split(WvStringParm s, const WvRegex &regex, int limit)
68 {
69  return ::strcoll_split(*this, s, regex, limit);
70 }
71 #endif
WvStringList::popstr
WvString popstr()
get the first string in the list, or an empty string if the list is empty.
Definition: wvstringlist.cc:55
strcoll_join
WvString strcoll_join(const StringCollection &coll, const char *joinchars=" \t")
Concatenates all strings in a collection and returns the result.
Definition: wvstrutils.h:420
WvStringList::splitstrict
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 ...
Definition: wvstringlist.cc:25
WvString
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:329
WvStringList::join
WvString join(const char *joinchars=" ") const
concatenates all elements of the list seperating on joinchars
Definition: wvstringlist.cc:14
WvRegex
WvRegex – Unified support for regular expressions.
Definition: wvregex.h:47
strcoll_splitstrict
void strcoll_splitstrict(StringCollection &coll, WvStringParm _s, const char *splitchars=" \t", int limit=0)
Splits a string and adds each substring to a collection.
Definition: wvstrutils.h:344
strcoll_split
void strcoll_split(StringCollection &coll, WvStringParm _s, const char *splitchars=" \t", int limit=0)
Splits a string and adds each substring to a collection.
Definition: wvstrutils.h:280
WvStringList::split
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.
Definition: wvstringlist.cc:19