data.h

Go to the documentation of this file.
00001 // Copyright (C) 2006 Bryan Jacobson <bryanjacobson@users.sourceforge.net>
00002 // This program is licensed under the terms of the GNU General Public License
00003 // version 2, as published by the Free Software Foundation.
00004 // This program is distributed in the hope that it will be useful,
00005 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00006 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007 
00008 #ifndef DATA_H
00009 #define DATA_H
00010 
00014 
00031 class Data
00032 {
00033   public:
00034     enum DataType { dtError, dtId, dtNum, dtData, dtText};
00035              Data(Id attr, Id value, Data *pNext = NULL);      
00036              Data(Id attr, double number, Data *pNext = NULL); 
00037              Data(Id attr, Data *pData, Data *pNext = NULL);   
00038              Data(Id attr, char *str, Data *pNext = NULL);     
00039     bool     IsUnitNum() { return mType == dtNum || (mType == dtData 
00040                && mpData->mType == dtNum && mpData->mpNext == NULL); };
00041     DataType GetType();
00042     Id       GetAttr() { return mAttr; };
00043     Id       GetId()   { assert(mType == dtId);   return mId; };
00044     double   GetNum();
00045     Data    *GetData() { assert(mType == dtData); return mpData; }
00046     Data    *GetNext() { return mpNext; }
00047     Data    *FindAttr(Id attr);
00048     Data    *FindData(Id data); 
00049 
00050     void     Dump(FILE *fp = stdout, int indent = 0);
00051     void     Print();             
00052     void     AppendData(Data *p); 
00053     void     Insert(Data *p);     
00054 
00056     static Data *Delete(Data **pp, Data *pData);
00057 
00064     static Data* BuildData(Data *p = NULL);
00065   private:
00066     DataType mType;  // dtId, dtNum, dtData
00067     Id       mAttr;
00068     union
00069     {
00070       Id      mId;
00071       double  mNum;
00072       Data   *mpData;
00073       char   *mpText;
00074     };
00075     Data *mpNext;
00076 };
00077 
00078 #endif // DATA_H

Generated on Sun Oct 8 09:32:09 2006 for gabbie by  doxygen 1.4.6