WvStreams
wvstringlist.cc
00001 /*
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * Some helper functions for WvStringList.
00006  * 
00007  * This is blatantly block-copied from WvStringTable, but I don't care!  Hah!
00008  * (I just know I'm going to regret this someday...)
00009  */
00010 #include "wvstringlist.h"
00011 #include "strutils.h"
00012 
00013 
00014 WvString WvStringList::join(const char *joinchars) const
00015 {
00016     return ::strcoll_join(*this, joinchars);
00017 }
00018 
00019 void WvStringList::split(WvStringParm s, const char *splitchars,
00020     int limit)
00021 {
00022     return ::strcoll_split(*this, s, splitchars, limit);
00023 }
00024 
00025 void WvStringList::splitstrict(WvStringParm s, const char *splitchars,
00026     int limit)
00027 {
00028     return ::strcoll_splitstrict(*this, s, splitchars, limit);
00029 }
00030 
00031 void WvStringList::fill(const char * const *array)
00032 {
00033     while (array && *array)
00034     {
00035         append(new WvString(*array), true);
00036         array++;
00037     }
00038 }
00039 
00040 
00041 void WvStringList::append(WvStringParm str)
00042 {
00043     WvStringListBase::append(new WvString(str), true);
00044 }
00045 
00046 
00047 void WvStringList::append(WvString *strp, bool autofree, char *id)
00048 {
00049     WvStringListBase::append(strp, autofree, id);
00050 }
00051 
00052 
00053 // get the first string in the list, or an empty string if the list is empty.
00054 // Removes the returned string from the list.
00055 WvString WvStringList::popstr()
00056 {
00057     if (isempty())
00058         return "";
00059     
00060     WvString s = *first();
00061     unlink_first();
00062     return s;
00063 }
00064 
00065 
00066 #ifndef _WIN32
00067 void WvStringList::split(WvStringParm s, const WvRegex &regex, int limit)
00068 {
00069     return ::strcoll_split(*this, s, regex, limit);
00070 }
00071 #endif