00001
00002
00003
00004
00005
00006
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;
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