]> www.ginac.de Git - cln.git/blob - include/cln/symbol.h
Ensure that makeinfo ≥ 6.8 checks the @menu structure.
[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 struct cl_symbol : public cl_rcpointer {
13 public:
14         // Conversion to string.
15         operator cl_string () const;
16         // Constructors.
17         cl_symbol (const cl_string&); // create or lookup a symbol from its name
18         cl_symbol (const cl_symbol&);
19         // Assignment operators.
20         cl_symbol& operator= (const cl_symbol&);
21         // Private pointer manipulations.
22         cl_symbol (cl_private_thing p) : cl_rcpointer (p) {}
23 public: /* ugh */
24         // Create a new symbol given its name.
25         cl_symbol (struct hashuniq * null, const cl_string& s);
26 };
27 CL_DEFINE_COPY_CONSTRUCTOR2(cl_symbol,cl_rcpointer)
28 CL_DEFINE_ASSIGNMENT_OPERATOR(cl_symbol,cl_symbol)
29
30 // A symbol points to a string, so to convert cl_symbol -> cl_string, we just
31 // take the pointer and put it into a cl_string.
32 inline cl_symbol::operator cl_string () const
33 {
34         return cl_string(_as_cl_private_thing());
35 }
36
37 // Comparison.
38 inline bool equal (const cl_symbol& s1, const cl_symbol& s2)
39 {
40         return (s1.pointer == s2.pointer);
41 }
42
43 // Hash code.
44 extern uintptr_t hashcode (const cl_symbol& s);
45
46 }  // namespace cln
47
48 #endif /* _CL_SYMBOL_H */