glist.h

Go to the documentation of this file.
00001 #ifndef gLIST_X_H
00002 #define gLIST_X_H
00003 
00004 #include "gstorage.h"
00005 #include "gstring.h"
00006 ////////////////////////////////////////////////////////////
00007 // Common enums
00008 // ---------------------------------------------------------
00009 enum eFindCriteria {
00010     e_FindExactPosition,
00011     e_FindFromPosition,
00012     e_FindBeforePosition
00013 };
00014 
00015 ////////////////////////////////////////////////////////////
00016 // Arguments and their corresponding support classes
00017 // ---------------------------------------------------------
00018 
00019 ////////////////////////////////////////////////////////////
00020 class gElem : public gStorage {
00021 public:
00022     gElem () ;
00023     gElem (gStorage* newObj) ;
00024     virtual ~gElem () ;
00025 
00026     // Public data-members
00027     gElem* prev;
00028     gElem* next;
00029     gStorage* me;
00030 
00031     // Get methods
00032     virtual int MaximumStorageSize () {
00033         return 1;
00034     }
00035 
00036     virtual t_uchar* ToString (t_uchar* uBuf) ;
00037     virtual char* Str () ;
00038 
00039     // Save/etc methods
00040     virtual gStorage* NewObject () ;
00041     virtual bool SaveGuts (FILE* f) ;
00042     virtual bool RestoreGuts (FILE* f) ;
00043 
00044 private:
00045     //Operators,empty
00046     gElem (gElem& ) ; //empty
00047     gElem& operator= (gElem& ) ; //empty
00048 };
00049 ////////////////////////////////////////////////////////////
00050 class gListGeneric : public gStorage {
00051 public:
00052     // Public enums
00053     enum eListStrategy {
00054         e_LstDefault,
00055         e_LstPointer,
00056         e_LstHash
00057     };
00058     enum eListIndexes {
00059         e_LstIdx1toN,
00060         e_LstIdx1toNstrict,
00061         e_LstIdx0Unused
00062     };
00063 
00064     virtual ~gListGeneric () ;
00065 
00066     // Get methods
00067     virtual bool IsEmpty () {
00068         return size==0;
00069     }
00070     virtual unsigned N () {
00071         return size;
00072     }
00073     virtual bool IsValidIndex (unsigned idx) ;
00074     virtual char* Str (unsigned idx) ;
00075     virtual t_uchar* UStr (unsigned idx) ;
00076 
00077     virtual gElem& GetElement (unsigned idx) ;
00078     virtual gElem* GetElementPtr (unsigned idx) ;
00079 
00080     virtual gStorage* GetObjectPtr (unsigned idx) ;
00081     virtual gStorage* GetFirstObjectPtr () ;
00082     virtual gStorage* GetLastObjectPtr () ;
00083 
00084     virtual eStorage ElementsKind () ;
00085 
00086     virtual int MinimumStorageSize () {
00087         return -1;
00088     }
00089     virtual int MaximumStorageSize () {
00090         return -1;
00091     }
00092 
00093     // Set methods
00094     virtual void Reset () {
00095         Delete();
00096     }
00097 
00098     virtual unsigned Delete (unsigned startPos=0, unsigned endPos=0) ;
00099 
00100     virtual bool SetCaseSense (bool doCaseSense) {
00101         doIgnoreCase = doCaseSense==false;
00102         return doCaseSense;
00103     }
00104     virtual bool AppendObject (gStorage* newObj) {
00105         if ( newObj==nil ) return false;
00106         thisAppend( newObj );
00107         return true;
00108     }
00109 
00110     // Specific methods
00111     virtual gElem* StartPtr () {
00112         return pStart;
00113     }
00114     virtual gElem* EndPtr () {
00115         return pEnd;
00116     }
00117 
00118     // Save/etc methods
00119     virtual gStorage* NewObject () ;
00120     virtual t_uchar* ToString (t_uchar* uBuf) ;
00121     virtual bool SaveGuts (FILE* f) ;
00122     virtual bool RestoreGuts (FILE* f) ;
00123 
00124 protected:
00125     gListGeneric (eStorage aKind,
00126                   eListStrategy aStgy,
00127                   eListIndexes aLstIdxs) ;
00128 
00129     unsigned size, preMaxSize, maxSize;
00130     eListIndexes lstIdxs;
00131     eListStrategy stgy;
00132     gUCharBuffer genUCharBuf;
00133     gElem* pStart;
00134     gElem* pEnd;
00135     gElem* pCurrent;
00136     bool doIgnoreCase;
00137 
00138     void thisPreAllocate (unsigned toSize) ;
00139     unsigned thisDelete () ;
00140     bool thisIndex (unsigned& idx) ;
00141     bool thisAppend (gStorage* newObj) ;
00142 
00143 private:
00144     // Operators,empty
00145     gListGeneric (gListGeneric& ) ;
00146     gListGeneric& operator= (gListGeneric& ) ;
00147 };
00148 ////////////////////////////////////////////////////////////
00149 class gList : public gListGeneric {
00150 public:
00151     gList () ;
00152     virtual ~gList () ;
00153 
00154     // Get methods
00155     virtual int GetInt (unsigned idx) ;
00156     virtual unsigned GetUInt (unsigned idx) ;
00157 
00158     // Find methods
00159     virtual unsigned Match (char* s) ;
00160     virtual unsigned FindFirst (char* s,
00161                                 unsigned strPos,
00162                                 eFindCriteria findCriteria) ;
00163     virtual unsigned Find (char* s,
00164                            unsigned strPos,
00165                            eFindCriteria findCriteria) ;
00166 
00167     virtual unsigned FindAny (char* s,
00168                               unsigned strPos,
00169                               eFindCriteria findCriteria,
00170                               gList& posL) ;
00171 
00172     // Set methods
00173     unsigned Add (int v) ;
00174     unsigned Add (unsigned v) ;
00175     unsigned Add (gString& copy) ;
00176     unsigned Add (t_uchar* s) ;
00177     unsigned Add (char* s) ;
00178 
00179     virtual gList& CopyList (gList& aL) ;
00180 
00181     virtual unsigned DeleteString (gString& s) ;
00182     virtual unsigned DeleteStrings (gString& s) ;
00183 
00184     // Save/etc methods
00185     virtual t_uchar* ToString (t_uchar* uBuf) ;
00186     virtual bool SaveGuts (FILE* f) ;
00187     virtual bool RestoreGuts (FILE* f) ;
00188 
00189     // Show methods
00190     virtual void Show (bool doShowAll=true) ;
00191 
00192 protected:
00193     unsigned thisFind (char* s,
00194                        unsigned strPos,
00195                        eFindCriteria findCriteria,
00196                        bool doStopOnFirst,
00197                        gList& posL) ;
00198 
00199 private:
00200     // Operators,empty
00201     gList (gList& ) ;
00202     gList& operator= (gList& ) ;
00203 };
00204 ////////////////////////////////////////////////////////////
00205 class gListInt : public gList {
00206 public:
00207     gListInt () ;
00208     virtual ~gListInt () ;
00209 
00210     // Get methods
00211     virtual unsigned FindInt (int v) ;
00212 
00213     // Set methods
00214     bool Append (gInt& v) {
00215         return Append( v.GetInt() );
00216     }
00217     bool Append (int v) ;
00218 
00219     // Valid operators
00220     int operator[] (unsigned idx) {
00221         return GetInt( idx );
00222     }
00223 
00224 private:
00225     // Operators,empty
00226     gListInt (gListInt& ) ; //empty
00227     gListInt& operator= (gListInt& ) ; //empty
00228 };
00229 ////////////////////////////////////////////////////////////
00230 #endif //gLIST_X_H
00231 

Generated on Sat Aug 18 02:40:57 2007 for xpfweb_v2x lib by  doxygen 1.4.2