00001 #ifndef LIST_H 00002 #define LIST_H 00003 00004 #include <string> 00005 00006 class List; 00007 class Atom; 00008 00009 class ListItem { 00010 public: 00011 virtual bool atomic()=0; 00012 virtual std::string getString()=0; 00013 virtual int getInt()=0; 00014 virtual double getDouble()=0; 00015 virtual List *getList()=0; 00016 virtual std::string firstString()=0; 00017 virtual List *firstList()=0; 00018 virtual void findAndReplace(std::string find, std::string replace)=0; 00019 private: 00020 }; 00021 00022 class List : public ListItem { 00023 public: 00024 List(int lineNumber = -1); 00025 List(List *list); 00026 ~List(); 00027 bool atomic() {return false;} 00028 00029 ListItem *first(); 00030 List *rest(); 00031 00032 std::string getString(); 00033 int getInt(); 00034 double getDouble(); 00035 00036 std::string getRestString(); 00037 00038 List* copy(); 00039 00040 List *cons(ListItem *first); 00041 List *snoc(ListItem *last); 00042 00043 void findAndReplace(std::string find, std::string replace); 00044 00045 bool empty() {return (!_item);} 00046 00047 List *getList() {return this;} 00048 00049 std::string firstString(); 00050 int firstInt(); 00051 double firstDouble(); 00052 00053 List *firstList(); 00054 protected: 00055 // std::list<ListItem*> _list; 00056 ListItem *_item; 00057 List *_next; 00058 int _lineNumber; 00059 }; 00060 00061 class Atom : public ListItem { 00062 public: 00063 Atom(std::string aString, int lineNumber = -1); 00064 Atom(int anInt, int lineNumber = -1); 00065 Atom(double aDouble, int lineNumber = -1); 00066 Atom(Atom *atom); 00067 00068 bool atomic() {return true;} 00069 std::string getString() {return _string;} 00070 int getInt(); 00071 double getDouble(); 00072 List *getList(); 00073 std::string firstString(); 00074 List *firstList(); 00075 00076 void findAndReplace(std::string find, std::string replace); 00077 protected: 00078 std::string _string; 00079 int _lineNumber; 00080 }; 00081 00082 #endif
1.4.6-NO