Kaynağa Gözat

Fix typography

Neal Wilson 11 yıl önce
ebeveyn
işleme
04936905d8
1 değiştirilmiş dosya ile 128 ekleme ve 136 silme
  1. 128
    136
      src/units.w

+ 128
- 136
src/units.w Dosyayı Görüntüle

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

Loading…
İptal
Kaydet