Browse Source

Fix typography

Neal Wilson 11 years ago
parent
commit
04936905d8
1 changed files with 128 additions and 136 deletions
  1. 128
    136
      src/units.w

+ 128
- 136
src/units.w View File

11
 #ifndef TypicaUnitsIncluded
11
 #ifndef TypicaUnitsIncluded
12
 #define TypicaUnitsIncluded
12
 #define TypicaUnitsIncluded
13
 
13
 
14
-class Units: public QObject
15
-{
16
-	Q_OBJECT
17
-	Q_ENUMS(Unit)
18
-	public:
19
-		enum Unit
20
-		{
14
+class Units: public QObject@/
15
+{@/
16
+	@[Q_OBJECT@]@;
17
+	@[Q_ENUMS(Unit)@]@;
18
+	public:@/
19
+		enum Unit@/
20
+		{@/
21
 			Unitless = 0,
21
 			Unitless = 0,
22
 			Fahrenheit = 10144,
22
 			Fahrenheit = 10144,
23
 			Celsius = 10143,
23
 			Celsius = 10143,
27
 			Kilogram = 15877,
27
 			Kilogram = 15877,
28
 			Ounce = 1,
28
 			Ounce = 1,
29
 			Gram = 2
29
 			Gram = 2
30
-		};
30
+		};@/
31
 		static double convertTemperature(double value, Unit fromUnit, Unit toUnit);
31
 		static double convertTemperature(double value, Unit fromUnit, Unit toUnit);
32
 		static double convertRelativeTemperature(double value, Unit fromUnit, Unit toUnit);
32
 		static double convertRelativeTemperature(double value, Unit fromUnit, Unit toUnit);
33
 		static bool isTemperatureUnit(Unit unit);
33
 		static bool isTemperatureUnit(Unit unit);
34
 		static double convertWeight(double value, Unit fromUnit, Unit toUnit);
34
 		static double convertWeight(double value, Unit fromUnit, Unit toUnit);
35
-		static bool isWeightUnit(Unit unit);
35
+		static bool isWeightUnit(Unit unit);@/
36
 };
36
 };
37
 
37
 
38
 #endif
38
 #endif
52
 @(units.cpp@>=
52
 @(units.cpp@>=
53
 bool Units::isTemperatureUnit(Unit unit)
53
 bool Units::isTemperatureUnit(Unit unit)
54
 {
54
 {
55
-	if(unit == Fahrenheit ||
56
-	   unit == Celsius ||
57
-	   unit == Kelvin ||
58
-	   unit == Rankine)
59
-	{
60
-		return true;
61
-	}
62
-	return false;
55
+	return (unit == Fahrenheit ||
56
+	        unit == Celsius ||
57
+	        unit == Kelvin ||
58
+	        unit == Rankind);
63
 }
59
 }
64
 
60
 
65
 @ Temperature conversions can be performed by the |Units| class and should
61
 @ Temperature conversions can be performed by the |Units| class and should
72
 be considered flawed.
68
 be considered flawed.
73
 
69
 
74
 @(units.cpp@>=
70
 @(units.cpp@>=
75
-double Units::convertTemperature(double value, Unit fromUnit, Unit toUnit)
71
+double Units::convertTemperature(double value, Unit fromUnit, Unit toUnit)@/
76
 {
72
 {
77
-	if(isTemperatureUnit(fromUnit) && isTemperatureUnit(toUnit) == false)
73
+	if(!(isTemperatureUnit(fromUnit) && isTemperatureUnit(toUnit)))
78
 	{
74
 	{
79
 		return 0;
75
 		return 0;
80
 	}
76
 	}
81
-	switch(fromUnit)
82
-	{
83
-		case Fahrenheit:
84
-			switch(toUnit)
85
-			{
86
-				case Fahrenheit:
77
+	switch(fromUnit)@/
78
+	{@t\1@>@/
79
+		case Fahrenheit:@/
80
+			switch(toUnit)@/
81
+			{@t\1@>@/
82
+				case Fahrenheit:@/
87
 					return value;
83
 					return value;
88
 					break;
84
 					break;
89
-				case Celsius:
85
+				case Celsius:@/
90
 					return (value - 32.0) * 5.0 / 9.0;
86
 					return (value - 32.0) * 5.0 / 9.0;
91
 					break;
87
 					break;
92
-				case Kelvin:
88
+				case Kelvin:@/
93
 					return (value + 459.67) * 5.0 / 9.0;
89
 					return (value + 459.67) * 5.0 / 9.0;
94
 					break;
90
 					break;
95
-				case Rankine:
91
+				case Rankine:@/
96
 					return value + 459.67;
92
 					return value + 459.67;
97
-					break;
98
-			}
93
+					break;@t\2@>@/
94
+			}@/
99
 			break;
95
 			break;
100
 		case Celsius:
96
 		case Celsius:
101
-			switch(toUnit)
102
-			{
103
-				case Fahrenheit:
97
+			switch(toUnit)@/
98
+			{@t\1@>@/
99
+				case Fahrenheit:@/
104
 					return value * 9.0 / 5.0 + 32.0;
100
 					return value * 9.0 / 5.0 + 32.0;
105
 					break;
101
 					break;
106
-				case Celsius:
102
+				case Celsius:@/
107
 					return value;
103
 					return value;
108
 					break;
104
 					break;
109
-				case Kelvin:
105
+				case Kelvin:@/
110
 					return value + 273.15;
106
 					return value + 273.15;
111
 					break;
107
 					break;
112
-				case Rankine:
108
+				case Rankine:@/
113
 					return (value + 273.15) * 9.0 / 5.0;
109
 					return (value + 273.15) * 9.0 / 5.0;
114
-					break;
115
-			}
110
+					break;@t\2@>@/
111
+			}@/
116
 			break;
112
 			break;
117
 		case Kelvin:
113
 		case Kelvin:
118
-			switch(toUnit)
119
-			{
120
-				case Fahrenheit:
114
+			switch(toUnit)@/
115
+			{@t\1@>@/
116
+				case Fahrenheit:@/
121
 					return value * 5.0 / 9.0 - 459.67;
117
 					return value * 5.0 / 9.0 - 459.67;
122
 					break;
118
 					break;
123
-				case Celsius:
119
+				case Celsius:@/
124
 					return value - 273.15;
120
 					return value - 273.15;
125
 					break;
121
 					break;
126
-				case Kelvin:
122
+				case Kelvin:@/
127
 					return value;
123
 					return value;
128
 					break;
124
 					break;
129
-				case Rankine:
125
+				case Rankine:@/
130
 					return value * 9.0 / 5.0;
126
 					return value * 9.0 / 5.0;
131
-					break;
132
-			}
127
+					break;@t\2@>@/
128
+			}@/
133
 			break;
129
 			break;
134
 		case Rankine:
130
 		case Rankine:
135
-			switch(toUnit)
136
-			{
137
-				case Fahrenheit:
131
+			switch(toUnit)@/
132
+			{@t\1@>@/
133
+				case Fahrenheit:@/
138
 					return value - 457.67;
134
 					return value - 457.67;
139
 					break;
135
 					break;
140
-				case Celsius:
136
+				case Celsius:@/
141
 					return (value - 491.67) * 5.0 / 9.0;
137
 					return (value - 491.67) * 5.0 / 9.0;
142
 					break;
138
 					break;
143
-				case Kelvin:
139
+				case Kelvin:@/
144
 					return value * 5.0 / 9.0;
140
 					return value * 5.0 / 9.0;
145
 					break;
141
 					break;
146
-				case Rankine:
142
+				case Rankine:@/
147
 					return value;
143
 					return value;
148
-					break;
149
-			}
144
+					break;@t\2@>@/
145
+			}@/
150
 			break;
146
 			break;
151
-		default:
147
+		default:@/
152
 			return 0;
148
 			return 0;
153
-			break;
149
+			break;@t\2@>@/
154
 	}
150
 	}
155
 	return 0;
151
 	return 0;
156
 }
152
 }
160
 @(units.cpp@>=
156
 @(units.cpp@>=
161
 double Units::convertRelativeTemperature(double value, Unit fromUnit, Unit toUnit)
157
 double Units::convertRelativeTemperature(double value, Unit fromUnit, Unit toUnit)
162
 {
158
 {
163
-	if(isTemperatureUnit(fromUnit) && isTemperatureUnit(toUnit) == false)
159
+	if(!(isTemperatureUnit(fromUnit) && isTemperatureUnit(toUnit)))@/
164
 	{
160
 	{
165
 		return 0;
161
 		return 0;
166
 	}
162
 	}
167
-	switch(fromUnit)
168
-	{
163
+	switch(fromUnit)@/
164
+	{@t\1@>@/
169
 		case Fahrenheit:
165
 		case Fahrenheit:
170
-			switch(toUnit)
171
-			{
172
-				case Fahrenheit:
166
+			switch(toUnit)@/
167
+			{@t\1@>@/
168
+				case Fahrenheit:@/
173
 					return value;
169
 					return value;
174
 					break;
170
 					break;
175
-				case Celsius:
171
+				case Celsius:@/
176
 					return value * (5.0 / 9.0);
172
 					return value * (5.0 / 9.0);
177
 					break;
173
 					break;
178
-				case Kelvin:
174
+				case Kelvin:@/
179
 					return value * (5.0 / 9.0);
175
 					return value * (5.0 / 9.0);
180
 					break;
176
 					break;
181
-				case Rankine:
177
+				case Rankine:@/
182
 					return value;
178
 					return value;
183
 					break;
179
 					break;
184
-				default:
180
+				default:@/
185
 					return 0;
181
 					return 0;
186
-					break;
182
+					break;@t\2@>@/
187
 			}
183
 			}
188
 			break;
184
 			break;
189
 		case Celsius:
185
 		case Celsius:
190
-			switch(toUnit)
191
-			{
192
-				case Fahrenheit:
186
+			switch(toUnit)@/
187
+			{@t\1@>@/
188
+				case Fahrenheit:@/
193
 					return value * (9.0 / 5.0);
189
 					return value * (9.0 / 5.0);
194
 					break;
190
 					break;
195
-				case Celsius:
191
+				case Celsius:@/
196
 					return value;
192
 					return value;
197
 					break;
193
 					break;
198
-				case Kelvin:
194
+				case Kelvin:@/
199
 					return value;
195
 					return value;
200
 					break;
196
 					break;
201
-				case Rankine:
197
+				case Rankine:@/
202
 					return value * (9.0 / 5.0);
198
 					return value * (9.0 / 5.0);
203
 					break;
199
 					break;
204
-				default:
200
+				default:@/
205
 					return 0;
201
 					return 0;
206
-					break;
202
+					break;@t\2@>@/
207
 			}
203
 			}
208
 			break;
204
 			break;
209
 		case Kelvin:
205
 		case Kelvin:
210
-			switch(toUnit)
211
-			{
212
-				case Fahrenheit:
206
+			switch(toUnit)@/
207
+			{@t\1@>@/
208
+				case Fahrenheit:@/
213
 					return value * (5.0 / 9.0);
209
 					return value * (5.0 / 9.0);
214
 					break;
210
 					break;
215
-				case Celsius:
211
+				case Celsius:@/
216
 					return value;
212
 					return value;
217
 					break;
213
 					break;
218
-				case Kelvin:
214
+				case Kelvin:@/
219
 					return value;
215
 					return value;
220
 					break;
216
 					break;
221
-				case Rankine:
217
+				case Rankine:@/
222
 					return value * (9.0 / 5.0);
218
 					return value * (9.0 / 5.0);
223
 					break;
219
 					break;
224
-				default:
220
+				default:@/
225
 					return 0;
221
 					return 0;
226
-					break;
222
+					break;@t\2@>@/
227
 			}
223
 			}
228
 			break;
224
 			break;
229
 		case Rankine:
225
 		case Rankine:
230
-			switch(toUnit)
231
-			{
232
-				case Fahrenheit:
226
+			switch(toUnit)@/
227
+			{@t\1@>@/
228
+				case Fahrenheit:@/
233
 					return value;
229
 					return value;
234
 					break;
230
 					break;
235
-				case Celsius:
231
+				case Celsius:@/
236
 					return value * (5.0 / 9.0);
232
 					return value * (5.0 / 9.0);
237
 					break;
233
 					break;
238
-				case Kelvin:
234
+				case Kelvin:@/
239
 					return value * (5.0 / 9.0);
235
 					return value * (5.0 / 9.0);
240
 					break;
236
 					break;
241
-				case Rankine:
237
+				case Rankine:@/
242
 					return value;
238
 					return value;
243
 					break;
239
 					break;
244
 				default:
240
 				default:
245
 					return 0;
241
 					return 0;
246
-					break;
242
+					break;@t\2@>@/
247
 			}
243
 			}
248
 			break;
244
 			break;
249
-		default:
245
+		default:@/
250
 			return 0;
246
 			return 0;
251
 			break;
247
 			break;
252
 	}
248
 	}
258
 @(units.cpp@>=
254
 @(units.cpp@>=
259
 double Units::convertWeight(double value, Unit fromUnit, Unit toUnit)
255
 double Units::convertWeight(double value, Unit fromUnit, Unit toUnit)
260
 {
256
 {
261
-	if(isWeightUnit(fromUnit) && isWeightUnit(toUnit))
257
+	if(isWeightUnit(fromUnit) && isWeightUnit(toUnit))@/
262
 	{
258
 	{
263
-		switch(fromUnit)
264
-		{
259
+		switch(fromUnit)@/
260
+		{@t\1@>@/
265
 			case Pound:
261
 			case Pound:
266
-				switch(toUnit)
267
-				{
268
-					case Pound:
262
+				switch(toUnit)@/
263
+				{@t\1@>@/
264
+					case Pound:@/
269
 						return value;
265
 						return value;
270
 						break;
266
 						break;
271
-					case Kilogram:
267
+					case Kilogram:@/
272
 						return value / 2.2;
268
 						return value / 2.2;
273
 						break;
269
 						break;
274
-					case Ounce:
270
+					case Ounce:@/
275
 						return value * 16.0;
271
 						return value * 16.0;
276
 						break;
272
 						break;
277
-					case Gram:
273
+					case Gram:@/
278
 						return value / 0.0022;
274
 						return value / 0.0022;
279
 						break;
275
 						break;
280
-					default:
276
+					default:@/
281
 						return 0;
277
 						return 0;
282
-						break;
278
+						break;@t\2@>@/
283
 				}
279
 				}
284
 				break;
280
 				break;
285
 			case Kilogram:
281
 			case Kilogram:
286
-				switch(toUnit)
287
-				{
288
-					case Pound:
282
+				switch(toUnit)@/
283
+				{@t\1@>@/
284
+					case Pound:@/
289
 						return value * 2.2;
285
 						return value * 2.2;
290
 						break;
286
 						break;
291
-					case Kilogram:
287
+					case Kilogram:@/
292
 						return value;
288
 						return value;
293
 						break;
289
 						break;
294
-					case Ounce:
290
+					case Ounce:@/
295
 						return value * 35.2;
291
 						return value * 35.2;
296
 						break;
292
 						break;
297
-					case Gram:
293
+					case Gram:@/
298
 						return value * 1000.0;
294
 						return value * 1000.0;
299
 						break;
295
 						break;
300
-					default:
296
+					default:@/
301
 						return 0;
297
 						return 0;
302
-						break;
298
+						break;@t\2@>@/
303
 				}
299
 				}
304
 				break;
300
 				break;
305
 			case Ounce:
301
 			case Ounce:
306
-				switch(toUnit)
307
-				{
308
-					case Pound:
302
+				switch(toUnit)@/
303
+				{@t\1@>@/
304
+					case Pound:@/
309
 						return value / 16.0;
305
 						return value / 16.0;
310
 						break;
306
 						break;
311
-					case Kilogram:
307
+					case Kilogram:@/
312
 						return value / 35.2;
308
 						return value / 35.2;
313
 						break;
309
 						break;
314
-					case Ounce:
310
+					case Ounce:@/
315
 						return value;
311
 						return value;
316
 						break;
312
 						break;
317
-					case Gram:
313
+					case Gram:@/
318
 						return value / 0.0352;
314
 						return value / 0.0352;
319
 						break;
315
 						break;
320
-					default:
316
+					default:@/
321
 						return 0;
317
 						return 0;
322
-						break;
318
+						break;@t\2@>@/
323
 				}
319
 				}
324
 				break;
320
 				break;
325
 			case Gram:
321
 			case Gram:
326
-				switch(toUnit)
327
-				{
328
-					case Pound:
322
+				switch(toUnit)@/
323
+				{@t\1@>@/
324
+					case Pound:@/
329
 						return value * 0.0022;
325
 						return value * 0.0022;
330
 						break;
326
 						break;
331
-					case Kilogram:
327
+					case Kilogram:@/
332
 						return value / 1000.0;
328
 						return value / 1000.0;
333
 						break;
329
 						break;
334
-					case Ounce:
330
+					case Ounce:@/
335
 						return value * 0.0352;
331
 						return value * 0.0352;
336
 						break;
332
 						break;
337
-					case Gram:
333
+					case Gram:@/
338
 						return value;
334
 						return value;
339
 						break;
335
 						break;
340
-					default:
336
+					default:@/
341
 						return 0;
337
 						return 0;
342
-						break;
338
+						break;@t\2@>@/
343
 				}
339
 				}
344
 				break;
340
 				break;
345
-			default:
341
+			default:@/
346
 				return 0;
342
 				return 0;
347
-				break;
343
+				break;@t\2@>@/
348
 		}
344
 		}
349
 	}
345
 	}
350
 	return 0;
346
 	return 0;
352
 
348
 
353
 bool Units::isWeightUnit(Unit unit)
349
 bool Units::isWeightUnit(Unit unit)
354
 {
350
 {
355
-	if(unit == Pound ||
356
-	   unit == Kilogram ||
357
-	   unit == Ounce ||
358
-	   unit == Gram)
359
-	{
360
-		return true;
361
-	}
362
-	return false;
351
+	return (unit == Pound ||
352
+	        unit == Kilogram ||
353
+	        unit == Ounce ||
354
+	        unit == gram);
363
 }
355
 }
364
 
356
 
365
 @ This class is exposed to the host environment. Note the lack of constructor.
357
 @ This class is exposed to the host environment. Note the lack of constructor.

Loading…
Cancel
Save