C:/Documents and Settings/mtauraso/Desktop/proj3/projectX/List.h

Go to the documentation of this file.
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 *cons(ListItem *first);
00039         List *snoc(ListItem *last);
00040     
00041         void findAndReplace(std::string find, std::string replace);
00042 
00043         bool empty() {return (!_item);}
00044         
00045         List *getList() {return this;}
00046         
00047         std::string firstString();
00048         int firstInt();
00049         double firstDouble();
00050         
00051         List *firstList();
00052 protected:
00053 //      std::list<ListItem*> _list;
00054         ListItem *_item;
00055         List *_next;
00056         int _lineNumber;
00057 };
00058 
00059 class Atom : public ListItem {
00060 public:
00061         Atom(std::string aString, int lineNumber = -1);
00062         Atom(int anInt, int lineNumber = -1);
00063         Atom(double aDouble, int lineNumber = -1);
00064         Atom(Atom *atom);
00065 
00066         bool atomic() {return true;}
00067         std::string getString() {return _string;}
00068         int getInt();
00069         double getDouble();
00070         List *getList();
00071         std::string firstString();
00072         List *firstList();
00073 
00074         void findAndReplace(std::string find, std::string replace);
00075 protected:
00076         std::string _string;
00077         int _lineNumber;
00078 };
00079 
00080 #endif

Generated on Sat Apr 22 15:05:20 2006 for ProjectX by  doxygen 1.4.6-NO