WvStreams
|
00001 #include "wvstringtable.h" 00002 #include "wvhashtable.h" 00003 #include <stdio.h> 00004 00005 int main() 00006 { 00007 WvStringTable t(10); 00008 // size: 10 elements 00009 // WvStringTable is essentially a WvHashTable 00010 00011 00012 00013 WvString s("one"), s2("two"), s3("three"); 00014 00015 t.add(&s, false); 00016 t.add(&s2,false); 00017 t.add(&s3,false); 00018 // t.add("foo") is not allowed 00019 // refer to WvHashTable for more information 00020 00021 printf("%s\n", t.join(",").cstr()); 00022 //prints out: one,two,three 00023 00024 00025 printf("%s\n", t.join().cstr()); 00026 // By default, t.join() is using " \t" as a delimiter 00027 // prints out: one two three 00028 00029 00030 t.zap(); 00031 //erasing all contents of t 00032 00033 00034 t.split("a : b : c : d ", ":"); 00035 00036 printf("%s\n", t.join(",").cstr()); 00037 // prints out: a , b , c , d 00038 00039 00040 t.split("x"); 00041 t.split("y"); 00042 t.split("z"); 00043 00044 printf("%s\n", t.join(",").cstr()); 00045 // prints out: a , b , c , d ,x,y,z 00046 00047 return 0; 00048 }