|
PH Logo
Logo intepreter modeled after UCB Logo.
|
00001 /* 00002 * Thing.h 00003 * 00004 * Author: Paul Hamilton 00005 * Date: 8 Jun 2011 00006 * 00007 */ 00008 #ifndef _THING_H 00009 #define _THING_H 00010 00011 #include "Types.h" 00012 #include "List.h" 00013 #include "Array.h" 00014 00015 #include <string> 00016 #include <boost/variant.hpp> 00017 #include <boost/tuple/tuple.hpp> 00018 00019 namespace phlogo { 00020 00021 class List; 00022 00027 class Thing { 00028 00029 public: 00030 Thing() {} 00031 Thing(const std::string &s); 00032 00036 void set(pThing thing); 00037 void set(const std::string &s); 00038 void set(long num); 00039 void set(double num); 00040 00044 List allocList(); 00045 Array allocArray(int size); 00046 List allocList(const tListArray &list); 00047 Array allocArray(const tListArray &array); 00048 00052 std::string getWord(); 00053 long getLong(); 00054 double getDouble(); 00055 List getList(); 00056 Array getArray(); 00057 00058 long asLong(); 00059 double asDouble(); 00060 00064 bool isWord(); 00065 bool isLong(); 00066 bool isDouble(); 00067 bool isList(); 00068 bool isArray(); 00069 00073 std::string str(); 00074 00078 std::string type(); 00079 00080 private: 00081 00082 typedef boost::tuple<bool, tListArray > tListData; 00083 00084 boost::variant< 00085 tListData 00086 , std::string 00087 , long 00088 , double 00089 > _data; 00090 00091 }; 00092 00093 } 00094 00095 #endif // _THING_H
1.7.4