00001 // glistext.cpp -- Version 0.1 00002 00003 #include "glistext.h" 00004 #include "gstringext.h" 00005 #include "garg.h" 00006 //////////////////////////////////////////////////////////// 00007 // Static members 00008 // --------------------------------------------------------- 00009 // void! 00010 00011 //////////////////////////////////////////////////////////// 00012 gSmartList::gSmartList (char* s, char aSmartChr) 00013 { 00014 SetSmartChr( aSmartChr ); 00015 AddFromStr( s ); 00016 } 00017 00018 gSmartList::~gSmartList () 00019 { 00020 } 00021 00022 unsigned gSmartList::MatchWhere (char* s) 00023 { 00024 // Returns the position where the exact string 's' was first found within the list. 00025 unsigned i, n=N(); 00026 00027 for (i=1; i<=n; i++) { 00028 if ( gStrControl::Self().Match( s, Str(i), doIgnoreCase ) ) 00029 return i; 00030 } 00031 00032 return 0; 00033 } 00034 00035 bool gSmartList::SetSmartChr (char aSmartChr) 00036 { 00037 sSmartChr.SetEmpty(); 00038 smartChr = aSmartChr; 00039 if ( smartChr==0 ) return false; 00040 sSmartChr.Add( smartChr ); 00041 return true; 00042 } 00043 00044 int gSmartList::AddFromStr (char* s) 00045 { 00046 unsigned i, n; 00047 00048 if ( s==nil ) return -1; 00049 00050 if ( sSmartChr.IsEmpty() ) { 00051 Add( s ); 00052 return 0; 00053 } 00054 00055 gParam aParam( s, sSmartChr.Str() ); 00056 n = aParam.N(); 00057 for (i=1; i<=n; i++) 00058 Add( aParam.Str(i) ); 00059 00060 return 0; 00061 } 00062 00063 int gSmartList::AddFromString (gString& aS) 00064 { 00065 return AddFromStr( aS.Str() ); 00066 } 00067 00068 int gSmartList::AddFromList (gList& aL) 00069 { 00070 unsigned i, n; 00071 for (i=1, n=aL.N(); i<=n; i++) 00072 AddFromStr( aL.Str(i) ); 00073 return 0; 00074 } 00075 //////////////////////////////////////////////////////////// 00076