rvm  1.11
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
types.cc
Go to the documentation of this file.
1 #include "config.h"
2 
3 #include "types.h"
4 
5 /** \file types.cc Basic types implementation. */
6 
7 // ----------------------------------------------------------------------------
8 
9 /** Return false for any variable that is not a char */
10 // template<typename T>
11 // static bool is_signed_char(const T& a_arg)
12 // { return(false); }
13 
14 /** Return true for any variable that is a char */
15 // template<>
16 bool is_signed_char(const char& a_arg)
17 { return(true); }
18 
19 /** Return false for any variable that is not an unsigned char */
20 // template<typename T>
21 // static bool is_unsigned_char(const T& a_arg)
22 // { return(false); }
23 
24 /** Return true for any variable that is an unsigned char */
25 // template<>
26 bool is_unsigned_char(const unsigned char& a_arg)
27 { return(true); }
28 
29 /** Return true for any variable that is either a signed or unsigned char */
30 // template<typename T>
31 // static bool is_char(const T& a_arg)
32 // { return(is_signed_char(a_arg) || is_unsigned_char(a_arg)); }
33 
34 // -----
35 
36 /** Return false for any variable that is not a short */
37 // template<typename T>
38 // static bool is_signed_short(const T& a_arg)
39 // { return(false); }
40 
41 /** Return true for any variable that is a short */
42 // template<>
43 bool is_signed_short(const short& a_arg)
44 { return(true); }
45 
46 /** Return false for any variable that is not an unsigned short */
47 // template<typename T>
48 // static bool is_unsigned_short(const T& a_arg)
49 // { return(false); }
50 
51 /** Return true for any variable that is an unsigned short */
52 // template<>
53 bool is_unsigned_short(const unsigned short& a_arg)
54 { return(true); }
55 
56 /** Return true for any variable that is either a signed or unsigned short */
57 // template<typename T>
58 // static bool is_short(const T& a_arg)
59 // { return(is_signed_short(a_arg) || is_unsigned_short(a_arg)); }
60 
61 // -----
62 
63 /** Return false for any variable that is not a int */
64 // template<typename T>
65 // static bool is_signed_int(const T& a_arg)
66 // { return(false); }
67 
68 /** Return true for any variable that is a int */
69 // template<>
70 bool is_signed_int(const int& a_arg)
71 { return(true); }
72 
73 /** Return false for any variable that is not an unsigned int */
74 // template<typename T>
75 // static bool is_unsigned_int(const T& a_arg)
76 // { return(false); }
77 
78 /** Return true for any variable that is an unsigned int */
79 // template<>
80 bool is_unsigned_int(const unsigned int& a_arg)
81 { return(true); }
82 
83 /** Return true for any variable that is either a signed or unsigned int */
84 // template<typename T>
85 // static bool is_int(const T& a_arg)
86 // { return(is_signed_int(a_arg) || is_unsigned_int(a_arg)); }
87 
88 // -----
89 
90 /** Return false for any variable that is not a long */
91 // template<typename T>
92 // static bool is_signed_long(const T& a_arg)
93 // { return(false); }
94 
95 /** Return true for any variable that is a long */
96 // template<>
97 bool is_signed_long(const long& a_arg)
98 { return(true); }
99 
100 /** Return false for any variable that is not an unsigned long */
101 // template<typename T>
102 // static bool is_unsigned_long(const T& a_arg)
103 // { return(false); }
104 
105 /** Return true for any variable that is an unsigned long */
106 // template<>
107 bool is_unsigned_long(const unsigned long& a_arg)
108 { return(true); }
109 
110 /** Return true for any variable that is either a signed or unsigned long */
111 // template<typename T>
112 // static bool is_long(const T& a_arg)
113 // { return(is_signed_long(a_arg) || is_unsigned_long(a_arg)); }
114 
115 // -----
116 
117 /** Return false for any variable that is not a long long */
118 // template<typename T>
119 // static bool is_signed_long_long(const T& a_arg)
120 // { return(false); }
121 
122 /** Return true for any variable that is a long long */
123 // template<>
124 bool is_signed_long_long(const long long& a_arg)
125 { return(true); }
126 
127 /** Return false for any variable that is not an unsigned long long */
128 // template<typename T>
129 // static bool is_unsigned_long_long(const T& a_arg)
130 // { return(false); }
131 
132 /** Return true for any variable that is an unsigned long long */
133 // template<>
134 bool is_unsigned_long_long(const unsigned long long& a_arg)
135 { return(true); }
136 
137 /** Return true for any variable that is either a signed or unsigned long long */
138 // template<typename T>
139 // static bool is_long_long(const T& a_arg)
140 // { return(is_signed_long_long(a_arg) || is_unsigned_long_long(a_arg)); }
141 
142 // -----
143 
144 /** Return false for any variable that is not a float */
145 // template<typename T>
146 // static bool is_float(const T& a_arg)
147 // { return(false); }
148 
149 /** Return true for any variable that is a float */
150 // template<>
151 bool is_float(const float& a_arg)
152 { return(true); }
153 
154 // -----
155 
156 /** Return false for any variable that is not a double */
157 // template<typename T>
158 // static bool is_double(const T& a_arg)
159 // { return(false); }
160 
161 /** Return true for any variable that is a double */
162 // template<>
163 bool is_double(const double& a_arg)
164 { return(true); }
165 
166 // -----
167 
168 /** Return false for any variable that is not a bool */
169 // template<typename T>
170 // static bool is_bool(const T& a_arg)
171 // { return(false); }
172 
173 /** Return true for any variable that is a bool */
174 // template<>
175 bool is_bool(const bool& a_arg)
176 { return(true); }
177 
178 // -----
179 
180 /** Return true for any variable that is a signed type */
181 // template<typename T>
182 // static bool is_signed(const T& a_arg)
183 // {
184 // return(
185 // is_signed_char(a_arg)
186 // || is_signed_short(a_arg)
187 // || is_signed_int(a_arg)
188 // || is_signed_long(a_arg)
189 // || is_signed_long_long(a_arg)
190 // || is_float(a_arg)
191 // || is_double(a_arg)
192 // );
193 // }
194 
195 /** Return true for any variable that is an unsigned type */
196 // template<typename T>
197 // static bool is_unsigned(const T& a_arg)
198 // {
199 // return(
200 // is_unsigned_char(a_arg)
201 // || is_unsigned_short(a_arg)
202 // || is_unsigned_int(a_arg)
203 // || is_unsigned_long(a_arg)
204 // || is_unsigned_long_long(a_arg)
205 // );
206 // }
207 
208 // ----------------------------------------------------------------------------
209 
210 // template<typename T>
211 // static const char * type_name(const T & a_arg)
212 // { return("unknown"); }
213 
214 // template<>
215 const char * type_name(const unsigned char & a_arg)
216 { return("unsigned char"); }
217 
218 // template<>
219 const char * type_name(const char & a_arg)
220 { return("char"); }
221 
222 // template<>
223 const char * type_name(const unsigned short & a_arg)
224 { return("unsigned short"); }
225 
226 // template<>
227 const char * type_name(const short & a_arg)
228 { return("short"); }
229 
230 // template<>
231 const char * type_name(const unsigned int & a_arg)
232 { return("unsigned int"); }
233 
234 // template<>
235 const char * type_name(const int & a_arg)
236 { return("int"); }
237 
238 // template<>
239 const char * type_name(const unsigned long & a_arg)
240 { return("unsigned long"); }
241 
242 // template<>
243 const char * type_name(const long & a_arg)
244 { return("long"); }
245 
246 // template<>
247 const char * type_name(const unsigned long long & a_arg)
248 { return("unsigned long long"); }
249 
250 // template<>
251 const char * type_name(const long long & a_arg)
252 { return("long long"); }
253 
254 // template<>
255 const char * type_name(const float & a_arg)
256 { return("float"); }
257 
258 // template<>
259 const char * type_name(const double & a_arg)
260 { return("double"); }
261 
262 // template<>
263 const char * type_name(const bool & a_arg)
264 { return("bool"); }
265 
266 // ----------------------------------------------------------------------------
267 
Basic types definitions and templates.
bool is_signed_short(const short &a_arg)
Return true for any variable that is either a signed or unsigned char.
Definition: types.cc:43
bool is_float(const float &a_arg)
Return true for any variable that is either a signed or unsigned long long.
Definition: types.cc:151
const char * type_name(const unsigned char &a_arg)
Return true for any variable that is a signed type.
Definition: types.cc:215
bool is_unsigned_long_long(const unsigned long long &a_arg)
Return false for any variable that is not an unsigned long long.
Definition: types.cc:134
bool is_bool(const bool &a_arg)
Return false for any variable that is not a bool.
Definition: types.cc:175
bool is_unsigned_int(const unsigned int &a_arg)
Return false for any variable that is not an unsigned int.
Definition: types.cc:80
bool is_signed_char(const char &a_arg)
Return false for any variable that is not a char.
Definition: types.cc:16
bool is_signed_long(const long &a_arg)
Return true for any variable that is either a signed or unsigned int.
Definition: types.cc:97
bool is_unsigned_short(const unsigned short &a_arg)
Return false for any variable that is not an unsigned short.
Definition: types.cc:53
bool is_signed_int(const int &a_arg)
Return true for any variable that is either a signed or unsigned short.
Definition: types.cc:70
bool is_signed_long_long(const long long &a_arg)
Return true for any variable that is either a signed or unsigned long.
Definition: types.cc:124
bool is_double(const double &a_arg)
Return false for any variable that is not a double.
Definition: types.cc:163
bool is_unsigned_char(const unsigned char &a_arg)
Return false for any variable that is not an unsigned char.
Definition: types.cc:26
bool is_unsigned_long(const unsigned long &a_arg)
Return false for any variable that is not an unsigned long.
Definition: types.cc:107