Doesn't compile yet. Working on it.
[lispp.git] / LispSymbol.h
blob646839821aa2cb478ed6d9c09e082fc6c9d5ffdd
1 #if !defined(LISP_SYMBOL_H_INCLUDED)
2 #define LISP_SYMBOL_H_INCLUDED
4 namespace Lisp
8 struct Symbol : public LispObj
10 void make(const CharType *symname)
12 int i = 0;
14 setType(eSymbolObj);
16 // calc length
17 while (*symname != '\0')
19 ++i;
20 ++symname;
23 // insert the pigs
24 object.resize(i+1);
25 symname = symname - i;
26 i = 0;
27 while(*symname != '\0')
29 object[i] = *symname;
30 ++i;
31 ++symname;
33 object[i+1] = '\0';
36 CharType& operator[](std::size_t i)
38 return object[i];
41 const CharType& operator[](std::size_t i) const
43 return object[i];
46 std::size_t length()
48 return object[i].size();
51 bool operator==(const Symbol& sym)
53 if (sym.length() == length())
55 bool result = true;
56 std::size_t i = 0;
58 while ((i < size()) && result)
60 result = (object[i] == sym.object[i]);
61 i++;
63 return result
65 return false;
69 } // end namespace lisp
72 #endif