Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

wvstringtable.cc

Go to the documentation of this file.
00001 /*
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * Some helper functions for WvStringTable.
00006  */
00007 #include "wvstringtable.h"
00008 #include "strutils.h"
00009 
00010 
00011 WvString WvStringTable::join(const char *joinchars)
00012 {
00013     WvStringTable::Iter s(*this);
00014     size_t totlen;
00015     WvString total;
00016     char *te;
00017     int x;
00018     
00019     totlen = 1;
00020     for (s.rewind(); s.next(); )
00021         totlen += strlen(s()) + strlen(joinchars);
00022     
00023     total.setsize(totlen);
00024     te = total.edit();
00025     
00026     te[0] = 0;
00027     x = 0;
00028     for (s.rewind(); s.next(); )
00029     {
00030         if (x++)
00031             strcat(te, joinchars);
00032         strcat(te, s());
00033     }
00034     
00035     if (te[0])
00036         trim_string(te);
00037     
00038     return total;
00039 }
00040 
00041 
00042 void WvStringTable::split(const WvString &_s, const char *splitchars)
00043 {
00044     WvString s(_s);
00045     char *sptr = s.edit(), *eptr, oldc;
00046     
00047     while (sptr && *sptr)
00048     {
00049         sptr += strspn(sptr, splitchars);
00050         eptr = sptr + strcspn(sptr, splitchars);
00051         
00052         oldc = *eptr;
00053         *eptr = 0;
00054         
00055         WvString *newstr = new WvString(sptr);
00056         newstr->unique();
00057         add(newstr, true);
00058         
00059         *eptr = oldc;
00060         sptr = eptr;
00061     }
00062 }
00063 

Generated on Sun Mar 16 01:01:12 2003 for WvStreams by doxygen1.3-rc3