Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JClass.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JCLASS__
2 #define __JLANG__JCLASS__
3 
4 
5 /**
6  * \author mdejong
7  */
8 
9 namespace JLANG {}
10 namespace JPP { using namespace JLANG; }
11 
12 namespace JLANG {
13 
14 
15  /**
16  * Data structure for primitive types.
17  */
18  template<class T>
19  struct JPrimitive {
20 
21  typedef const T argument_type;
22 
23  enum { is_primitive = true };
24  };
25 
26 
27  /**
28  * Data structure for method argument types.
29  */
30  template<class T>
31  struct JArgument {
32 
33  typedef const T& argument_type;
34 
35  enum { is_primitive = false };
36  };
37 
38 
39  /**
40  * Specialisations of JArgument for primitive types.
41  */
42  template<> struct JArgument<bool> : public JPrimitive<bool> {};
43  template<> struct JArgument<char> : public JPrimitive<char> {};
44  template<> struct JArgument<unsigned char> : public JPrimitive<unsigned char> {};
45  template<> struct JArgument<short> : public JPrimitive<short> {};
46  template<> struct JArgument<unsigned short> : public JPrimitive<unsigned short> {};
47  template<> struct JArgument<int> : public JPrimitive<int> {};
48  template<> struct JArgument<unsigned int> : public JPrimitive<unsigned int> {};
49  template<> struct JArgument<long int> : public JPrimitive<long int> {};
50  template<> struct JArgument<unsigned long int> : public JPrimitive<unsigned long int> {};
51  template<> struct JArgument<long long int> : public JPrimitive<long long int> {};
52  template<> struct JArgument<unsigned long long int> : public JPrimitive<unsigned long long int> {};
53  template<> struct JArgument<float> : public JPrimitive<float> {};
54  template<> struct JArgument<double> : public JPrimitive<double> {};
55  template<> struct JArgument<long double> : public JPrimitive<long double> {};
56 
57 
58  /**
59  * Template for generic class types.
60  */
61  template<class T>
62  struct JClass {
63 
65  typedef T value_type;
68 
70  enum { is_reference = false };
71  enum { is_pointer = false };
72  enum { is_constant = false };
73  };
74 
75 
76  /**
77  * Specialisation of JClass for const class types.
78  */
79  template<class T>
80  struct JClass<const T> {
81 
83  typedef T value_type;
84  typedef const value_type& reference_type;
85  typedef const value_type* pointer_type;
86 
88  enum { is_reference = false };
89  enum { is_pointer = false };
90  enum { is_constant = true };
91  };
92 
93 
94  /**
95  * Specialisation of JClass for reference class types.
96  */
97  template<class T>
98  struct JClass<T&> {
99 
100  typedef T& argument_type;
101  typedef T value_type;
102  typedef value_type& reference_type;
103  typedef value_type* pointer_type;
104 
105  enum { is_primitive = JArgument<T>::is_primitive };
106  enum { is_reference = true };
107  enum { is_pointer = false };
108  enum { is_constant = false };
109  };
110 
111 
112  /**
113  * Specialisation of JClass for const reference class types.
114  */
115  template<class T>
116  struct JClass<const T&> {
117 
118  typedef const T& argument_type;
119  typedef T value_type;
120  typedef const value_type& reference_type;
121  typedef const value_type* pointer_type;
122 
123  enum { is_primitive = JArgument<T>::is_primitive };
124  enum { is_reference = true };
125  enum { is_pointer = false };
126  enum { is_constant = true };
127  };
128 
129 
130  /**
131  * Specialisation of JClass for pointer class types.
132  */
133  template<class T>
134  struct JClass<T*> {
135 
136  typedef T* argument_type;
137  typedef T value_type;
138  typedef value_type*& reference_type;
139  typedef value_type* pointer_type;
140 
141  enum { is_primitive = JArgument<T>::is_primitive };
142  enum { is_reference = false };
143  enum { is_pointer = true };
144  enum { is_constant = false };
145  };
146 
147 
148  /**
149  * Specialisation of JClass for const pointer class types.
150  */
151  template<class T>
152  struct JClass<const T*> {
153 
154  typedef const T* argument_type;
155  typedef T value_type;
156  typedef const value_type*& reference_type;
157  typedef const value_type* pointer_type;
158 
159  enum { is_primitive = JArgument<T>::is_primitive };
160  enum { is_reference = false };
161  enum { is_pointer = true };
162  enum { is_constant = true };
163  };
164 
165 
166  /**
167  * Specialisation of JClass for pointer class types.
168  */
169  template<class T>
170  struct JClass<T*&> {
171 
172  typedef T*& argument_type;
173  typedef T value_type;
174  typedef value_type*& reference_type;
175  typedef value_type* pointer_type;
176 
177  enum { is_primitive = JArgument<T>::is_primitive };
178  enum { is_reference = true };
179  enum { is_pointer = true };
180  enum { is_constant = false };
181  };
182 
183 
184  /**
185  * Specialisation of JClass for const pointer class types.
186  */
187  template<class T>
188  struct JClass<const T*&> {
189 
190  typedef const T*& argument_type;
191  typedef T value_type;
192  typedef const value_type*& reference_type;
193  typedef const value_type* pointer_type;
194 
195  enum { is_primitive = JArgument<T>::is_primitive };
196  enum { is_reference = true };
197  enum { is_pointer = true };
198  enum { is_constant = true };
199  };
200 }
201 
202 #endif
const value_type * pointer_type
Definition: JClass.hh:157
const value_type & reference_type
Definition: JClass.hh:120
const value_type * pointer_type
Definition: JClass.hh:121
JArgument< T >::argument_type argument_type
Definition: JClass.hh:82
const T argument_type
Definition: JClass.hh:21
Data structure for primitive types.
Definition: JClass.hh:19
value_type & reference_type
Definition: JClass.hh:66
const value_type *& reference_type
Definition: JClass.hh:156
JArgument< T >::argument_type argument_type
Definition: JClass.hh:64
const T & argument_type
Definition: JClass.hh:33
value_type *& reference_type
Definition: JClass.hh:174
value_type * pointer_type
Definition: JClass.hh:139
value_type *& reference_type
Definition: JClass.hh:138
value_type * pointer_type
Definition: JClass.hh:103
value_type * pointer_type
Definition: JClass.hh:67
const value_type * pointer_type
Definition: JClass.hh:193
const value_type * pointer_type
Definition: JClass.hh:85
Template for generic class types.
Definition: JClass.hh:62
const value_type *& reference_type
Definition: JClass.hh:192
value_type * pointer_type
Definition: JClass.hh:175
const value_type & reference_type
Definition: JClass.hh:84
value_type & reference_type
Definition: JClass.hh:102
Data structure for method argument types.
Definition: JClass.hh:31