]> www.ginac.de Git - cln.git/blob - include/cln/symbol.h
Make @exec_prefix@ usable in shell scripts.
[cln.git] / include / cln / symbol.h
1 // Symbols.
2
3 #ifndef _CL_SYMBOL_H
4 #define _CL_SYMBOL_H
5
6 #include "cln/string.h"
7
8 namespace cln {
9
10 // Symbols are just strings, uniquified through a global hash table.
11
12 #if (defined(__alpha__) && !defined(__GNUC__))
13 struct hashuniq;
14 #endif
15
16 struct cl_symbol : public cl_rcpointer {
17 public:
18         // Conversion to string.
19         operator cl_string () const;
20         // Constructors.
21         cl_symbol (const cl_string&); // create or lookup a symbol from its name
22         cl_symbol (const cl_symbol&);
23         // Assignment operators.
24         cl_symbol& operator= (const cl_symbol&);
25         // Private pointer manipulations.
26         cl_symbol (cl_private_thing p) : cl_rcpointer (p) {}
27 public: /* ugh */
28         // Create a new symbol given its name.
29         cl_symbol (struct hashuniq * null, const cl_string& s);
30 };
31 CL_DEFINE_COPY_CONSTRUCTOR2(cl_symbol,cl_rcpointer)
32 CL_DEFINE_ASSIGNMENT_OPERATOR(cl_symbol,cl_symbol)
33
34 // A symbol points to a string, so to convert cl_symbol -> cl_string, we just
35 // take the pointer and put it into a cl_string.
36 inline cl_symbol::operator cl_string () const
37 {
38         return cl_string(_as_cl_private_thing());
39 }
40
41 // Comparison.
42 inline bool equal (const cl_symbol& s1, const cl_symbol& s2)
43 {
44         return (s1.pointer == s2.pointer);
45 }
46
47 // Hash code.
48 extern unsigned long hashcode (const cl_symbol& s);
49
50 CL_REQUIRE(cl_symbol)
51
52 }  // namespace cln
53
54 #endif /* _CL_SYMBOL_H */