]> www.ginac.de Git - cln.git/blob - include/cl_rational_class.h
Make @exec_prefix@ usable in shell scripts.
[cln.git] / include / cl_rational_class.h
1 // Abstract class of rational numbers.
2
3 #ifndef _CL_RATIONAL_CLASS_H
4 #define _CL_RATIONAL_CLASS_H
5
6 #include "cl_number.h"
7 #include "cl_real_class.h"
8
9
10 class cl_RA : public cl_R {
11 public:
12 // Default constructor.
13         cl_RA ();
14 // Copy constructor.
15         cl_RA (const cl_RA&);
16 // Converters.
17 // Assignment operators.
18         cl_RA& operator= (const cl_RA&);
19 // Constructors and assignment operators from C numeric types.
20         cl_RA (const int);              // |argument| must be < 2^29
21         cl_RA (const unsigned int);     // argument must be < 2^29
22         cl_RA (const long);
23         cl_RA (const unsigned long);
24         cl_RA& operator= (const int);           // |argument| must be < 2^29
25         cl_RA& operator= (const unsigned int);  // argument must be < 2^29
26         cl_RA& operator= (const long);
27         cl_RA& operator= (const unsigned long);
28 // Other constructors.
29         cl_RA (const char *);
30 // Private constructor.
31         cl_RA (cl_private_thing);
32         cl_RA (struct cl_heap_ratio *);
33 public: // Ability to place an object at a given address.
34         void* operator new (size_t size) { return cl_malloc_hook(size); }
35         void* operator new (size_t size, cl_RA* ptr) { (void)size; return ptr; }
36         void operator delete (void* ptr) { cl_free_hook(ptr); }
37 private:
38 // Friend declarations. They are for the compiler. Just ignore them.
39 };
40
41 // Private constructors.
42 inline cl_RA::cl_RA (cl_private_thing ptr) : cl_R (ptr) {}
43 // The assignment operators:
44 CL_DEFINE_ASSIGNMENT_OPERATOR(cl_RA, cl_RA)
45 // The default constructors.
46 inline cl_RA::cl_RA ()
47         : cl_R ((cl_private_thing) cl_combine(cl_FN_tag,0)) {}
48 // The copy constructors.
49 CL_DEFINE_COPY_CONSTRUCTOR2(cl_RA,cl_R)
50 // Constructors and assignment operators from C numeric types.
51 CL_DEFINE_INT_CONSTRUCTORS(cl_RA)
52 CL_DEFINE_INT_ASSIGNMENT_OPERATORS(cl_RA)
53 CL_DEFINE_LONG_CONSTRUCTORS(cl_RA)
54 CL_DEFINE_LONG_ASSIGNMENT_OPERATORS(cl_RA)
55
56
57 #endif /* _CL_RATIONAL_CLASS_H */