7#include "binary_data_p.h"
10#include <KLocalizedString>
14namespace KUnitConversion
16class BinaryPowerOfTwoUnitPrivate :
public UnitPrivate
19 BinaryPowerOfTwoUnitPrivate(CategoryId categoryId,
28 : UnitPrivate(categoryId, id, multiplier, symbol, description, matchString, symbolString, realString, integerString)
32 qreal toDefault(qreal value)
const override
34 return value * pow(2.0, m_multiplier);
36 qreal fromDefault(qreal value)
const override
38 return value / pow(2.0, m_multiplier);
42UnitCategory BinaryData::makeCategory()
44 auto c = UnitCategoryPrivate::makeCategory(BinaryDataCategory,
i18n(
"Binary Data"),
i18n(
"Binary Data Size"));
45 auto d = UnitCategoryPrivate::get(c);
48 d->addUnit(UnitPrivate::makeUnit(
new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
51 i18nc(
"binary data unit symbol",
"YiB"),
52 i18nc(
"unit description in lists",
"yobibytes"),
53 i18nc(
"unit synonyms for matching user input",
"YiB;yobibyte;yobibytes"),
55 ki18nc(
"amount in units (real)",
"%1 yobibytes"),
56 ki18ncp(
"amount in units (integer)",
"%1 yobibyte",
"%1 yobibytes"))));
58 d->addUnit(UnitPrivate::makeUnit(
new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
61 i18nc(
"binary data unit symbol",
"Yib"),
62 i18nc(
"unit description in lists",
"yobibits"),
63 i18nc(
"unit synonyms for matching user input",
"Yib;yobibit;yobibits"),
65 ki18nc(
"amount in units (real)",
"%1 yobibits"),
66 ki18ncp(
"amount in units (integer)",
"%1 yobibit",
"%1 yobibits"))));
68 d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
71 i18nc(
"binary data unit symbol",
"YB"),
72 i18nc(
"unit description in lists",
"yottabytes"),
73 i18nc(
"unit synonyms for matching user input",
"YB;yottabyte;yottabytes"),
75 ki18nc(
"amount in units (real)",
"%1 yottabytes"),
76 ki18ncp(
"amount in units (integer)",
"%1 yottabyte",
"%1 yottabytes")));
78 d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
81 i18nc(
"binary data unit symbol",
"Yb"),
82 i18nc(
"unit description in lists",
"yottabits"),
83 i18nc(
"unit synonyms for matching user input",
"Yb;yottabit;yottabits"),
85 ki18nc(
"amount in units (real)",
"%1 yottabits"),
86 ki18ncp(
"amount in units (integer)",
"%1 yottabit",
"%1 yottabits")));
88 d->addUnit(UnitPrivate::makeUnit(
new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
91 i18nc(
"binary data unit symbol",
"ZiB"),
92 i18nc(
"unit description in lists",
"zebibytes"),
93 i18nc(
"unit synonyms for matching user input",
"ZiB;zebibyte;zebibytes"),
95 ki18nc(
"amount in units (real)",
"%1 zebibytes"),
96 ki18ncp(
"amount in units (integer)",
"%1 zebibyte",
"%1 zebibytes"))));
98 d->addUnit(UnitPrivate::makeUnit(
new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
101 i18nc(
"binary data unit symbol",
"Zib"),
102 i18nc(
"unit description in lists",
"zebibits"),
103 i18nc(
"unit synonyms for matching user input",
"Zib;zebibit;zebibits"),
105 ki18nc(
"amount in units (real)",
"%1 zebibits"),
106 ki18ncp(
"amount in units (integer)",
"%1 zebibit",
"%1 zebibits"))));
108 d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
111 i18nc(
"binary data unit symbol",
"ZB"),
112 i18nc(
"unit description in lists",
"zettabytes"),
113 i18nc(
"unit synonyms for matching user input",
"ZB;zettabyte;zettabytes"),
115 ki18nc(
"amount in units (real)",
"%1 zettabytes"),
116 ki18ncp(
"amount in units (integer)",
"%1 zettabyte",
"%1 zettabytes")));
118 d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
121 i18nc(
"binary data unit symbol",
"Zb"),
122 i18nc(
"unit description in lists",
"zettabits"),
123 i18nc(
"unit synonyms for matching user input",
"Zb;zettabit;zettabits"),
125 ki18nc(
"amount in units (real)",
"%1 zettabits"),
126 ki18ncp(
"amount in units (integer)",
"%1 zettabit",
"%1 zettabits")));
128 d->addUnit(UnitPrivate::makeUnit(
new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
131 i18nc(
"binary data unit symbol",
"EiB"),
132 i18nc(
"unit description in lists",
"exbibytes"),
133 i18nc(
"unit synonyms for matching user input",
"EiB;exbibyte;exbibytes"),
135 ki18nc(
"amount in units (real)",
"%1 exbibytes"),
136 ki18ncp(
"amount in units (integer)",
"%1 exbibyte",
"%1 exbibytes"))));
138 d->addUnit(UnitPrivate::makeUnit(
new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
141 i18nc(
"binary data unit symbol",
"Eib"),
142 i18nc(
"unit description in lists",
"exbibits"),
143 i18nc(
"unit synonyms for matching user input",
"Eib;exbibit;exbibits"),
145 ki18nc(
"amount in units (real)",
"%1 exbibits"),
146 ki18ncp(
"amount in units (integer)",
"%1 exbibit",
"%1 exbibits"))));
148 d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
151 i18nc(
"binary data unit symbol",
"EB"),
152 i18nc(
"unit description in lists",
"exabytes"),
153 i18nc(
"unit synonyms for matching user input",
"EB;exabyte;exabytes"),
155 ki18nc(
"amount in units (real)",
"%1 exabytes"),
156 ki18ncp(
"amount in units (integer)",
"%1 exabyte",
"%1 exabytes")));
158 d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
161 i18nc(
"binary data unit symbol",
"Eb"),
162 i18nc(
"unit description in lists",
"exabits"),
163 i18nc(
"unit synonyms for matching user input",
"Eb;exabit;exabits"),
165 ki18nc(
"amount in units (real)",
"%1 exabits"),
166 ki18ncp(
"amount in units (integer)",
"%1 exabit",
"%1 exabits")));
168 d->addUnit(UnitPrivate::makeUnit(
new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
171 i18nc(
"binary data unit symbol",
"PiB"),
172 i18nc(
"unit description in lists",
"pebibytes"),
173 i18nc(
"unit synonyms for matching user input",
"PiB;pebibyte;pebibytes"),
175 ki18nc(
"amount in units (real)",
"%1 pebibytes"),
176 ki18ncp(
"amount in units (integer)",
"%1 pebibyte",
"%1 pebibytes"))));
178 d->addUnit(UnitPrivate::makeUnit(
new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
181 i18nc(
"binary data unit symbol",
"Pib"),
182 i18nc(
"unit description in lists",
"pebibits"),
183 i18nc(
"unit synonyms for matching user input",
"Pib;pebibit;pebibits"),
185 ki18nc(
"amount in units (real)",
"%1 pebibits"),
186 ki18ncp(
"amount in units (integer)",
"%1 pebibit",
"%1 pebibits"))));
188 d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
191 i18nc(
"binary data unit symbol",
"PB"),
192 i18nc(
"unit description in lists",
"petabytes"),
193 i18nc(
"unit synonyms for matching user input",
"PB;petabyte;petabytes"),
195 ki18nc(
"amount in units (real)",
"%1 petabytes"),
196 ki18ncp(
"amount in units (integer)",
"%1 petabyte",
"%1 petabytes")));
198 d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
201 i18nc(
"binary data unit symbol",
"Pb"),
202 i18nc(
"unit description in lists",
"petabits"),
203 i18nc(
"unit synonyms for matching user input",
"Pb;petabit;petabits"),
205 ki18nc(
"amount in units (real)",
"%1 petabits"),
206 ki18ncp(
"amount in units (integer)",
"%1 petabit",
"%1 petabits")));
208 d->addCommonUnit(UnitPrivate::makeUnit(
new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
211 i18nc(
"binary data unit symbol",
"TiB"),
212 i18nc(
"unit description in lists",
"tebibytes"),
213 i18nc(
"unit synonyms for matching user input",
"TiB;tebibyte;tebibytes"),
215 ki18nc(
"amount in units (real)",
"%1 tebibytes"),
216 ki18ncp(
"amount in units (integer)",
"%1 tebibyte",
"%1 tebibytes"))));
218 d->addUnit(UnitPrivate::makeUnit(
new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
221 i18nc(
"binary data unit symbol",
"Tib"),
222 i18nc(
"unit description in lists",
"tebibits"),
223 i18nc(
"unit synonyms for matching user input",
"Tib;tebibit;tebibits"),
225 ki18nc(
"amount in units (real)",
"%1 tebibits"),
226 ki18ncp(
"amount in units (integer)",
"%1 tebibit",
"%1 tebibits"))));
228 d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
231 i18nc(
"binary data unit symbol",
"TB"),
232 i18nc(
"unit description in lists",
"terabytes"),
233 i18nc(
"unit synonyms for matching user input",
"TB;terabyte;terabytes"),
235 ki18nc(
"amount in units (real)",
"%1 terabytes"),
236 ki18ncp(
"amount in units (integer)",
"%1 terabyte",
"%1 terabytes")));
238 d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
241 i18nc(
"binary data unit symbol",
"Tb"),
242 i18nc(
"unit description in lists",
"terabits"),
243 i18nc(
"unit synonyms for matching user input",
"Tb;terabit;terabits"),
245 ki18nc(
"amount in units (real)",
"%1 terabits"),
246 ki18ncp(
"amount in units (integer)",
"%1 terabit",
"%1 terabits")));
248 d->addCommonUnit(UnitPrivate::makeUnit(
new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
251 i18nc(
"binary data unit symbol",
"GiB"),
252 i18nc(
"unit description in lists",
"gibibytes"),
253 i18nc(
"unit synonyms for matching user input",
"GiB;gibibyte;gibibytes"),
255 ki18nc(
"amount in units (real)",
"%1 gibibytes"),
256 ki18ncp(
"amount in units (integer)",
"%1 gibibyte",
"%1 gibibytes"))));
258 d->addUnit(UnitPrivate::makeUnit(
new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
261 i18nc(
"binary data unit symbol",
"Gib"),
262 i18nc(
"unit description in lists",
"gibibits"),
263 i18nc(
"unit synonyms for matching user input",
"Gib;gibibit;gibibits"),
265 ki18nc(
"amount in units (real)",
"%1 gibibits"),
266 ki18ncp(
"amount in units (integer)",
"%1 gibibit",
"%1 gibibits"))));
268 d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
271 i18nc(
"binary data unit symbol",
"GB"),
272 i18nc(
"unit description in lists",
"gigabytes"),
273 i18nc(
"unit synonyms for matching user input",
"GB;gigabyte;gigabytes"),
275 ki18nc(
"amount in units (real)",
"%1 gigabytes"),
276 ki18ncp(
"amount in units (integer)",
"%1 gigabyte",
"%1 gigabytes")));
278 d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
281 i18nc(
"binary data unit symbol",
"Gb"),
282 i18nc(
"unit description in lists",
"gigabits"),
283 i18nc(
"unit synonyms for matching user input",
"Gb;gigabit;gigabits"),
285 ki18nc(
"amount in units (real)",
"%1 gigabits"),
286 ki18ncp(
"amount in units (integer)",
"%1 gigabit",
"%1 gigabits")));
288 d->addCommonUnit(UnitPrivate::makeUnit(
new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
291 i18nc(
"binary data unit symbol",
"MiB"),
292 i18nc(
"unit description in lists",
"mebibytes"),
293 i18nc(
"unit synonyms for matching user input",
"MiB;mebibyte;mebibytes"),
295 ki18nc(
"amount in units (real)",
"%1 mebibytes"),
296 ki18ncp(
"amount in units (integer)",
"%1 mebibyte",
"%1 mebibytes"))));
298 d->addUnit(UnitPrivate::makeUnit(
new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
301 i18nc(
"binary data unit symbol",
"Mib"),
302 i18nc(
"unit description in lists",
"mebibits"),
303 i18nc(
"unit synonyms for matching user input",
"Mib;mebibit;mebibits"),
305 ki18nc(
"amount in units (real)",
"%1 mebibits"),
306 ki18ncp(
"amount in units (integer)",
"%1 mebibit",
"%1 mebibits"))));
308 d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
311 i18nc(
"binary data unit symbol",
"MB"),
312 i18nc(
"unit description in lists",
"megabytes"),
313 i18nc(
"unit synonyms for matching user input",
"MB;megabyte;megabytes"),
315 ki18nc(
"amount in units (real)",
"%1 megabytes"),
316 ki18ncp(
"amount in units (integer)",
"%1 megabyte",
"%1 megabytes")));
318 d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
321 i18nc(
"binary data unit symbol",
"Mb"),
322 i18nc(
"unit description in lists",
"megabits"),
323 i18nc(
"unit synonyms for matching user input",
"Mb;megabit;megabits"),
325 ki18nc(
"amount in units (real)",
"%1 megabits"),
326 ki18ncp(
"amount in units (integer)",
"%1 megabit",
"%1 megabits")));
328 d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
331 i18nc(
"binary data unit symbol",
"KiB"),
332 i18nc(
"unit description in lists",
"kibibytes"),
333 i18nc(
"unit synonyms for matching user input",
"KiB;kiB;kibibyte;kibibytes"),
335 ki18nc(
"amount in units (real)",
"%1 kibibytes"),
336 ki18ncp(
"amount in units (integer)",
"%1 kibibyte",
"%1 kibibytes")));
338 d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
341 i18nc(
"binary data unit symbol",
"Kib"),
342 i18nc(
"unit description in lists",
"kibibits"),
343 i18nc(
"unit synonyms for matching user input",
"Kib;kib;kibibit;kibibits"),
345 ki18nc(
"amount in units (real)",
"%1 kibibits"),
346 ki18ncp(
"amount in units (integer)",
"%1 kibibit",
"%1 kibibits")));
348 d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
351 i18nc(
"binary data unit symbol",
"kB"),
352 i18nc(
"unit description in lists",
"kilobytes"),
353 i18nc(
"unit synonyms for matching user input",
"kB;KB;kilobyte;kilobytes"),
355 ki18nc(
"amount in units (real)",
"%1 kilobytes"),
356 ki18ncp(
"amount in units (integer)",
"%1 kilobyte",
"%1 kilobytes")));
358 d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
361 i18nc(
"binary data unit symbol",
"kb"),
362 i18nc(
"unit description in lists",
"kilobits"),
363 i18nc(
"unit synonyms for matching user input",
"kb;Kb;kilobit;kilobits"),
365 ki18nc(
"amount in units (real)",
"%1 kilobits"),
366 ki18ncp(
"amount in units (integer)",
"%1 kilobit",
"%1 kilobits")));
368 d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
371 i18nc(
"binary data unit symbol",
"B"),
372 i18nc(
"unit description in lists",
"bytes"),
373 i18nc(
"unit synonyms for matching user input",
"B;byte;bytes"),
375 ki18nc(
"amount in units (real)",
"%1 bytes"),
376 ki18ncp(
"amount in units (integer)",
"%1 byte",
"%1 bytes")));
378 d->addDefaultUnit(UnitPrivate::makeUnit(BinaryDataCategory,
381 i18nc(
"binary data unit symbol",
"b"),
382 i18nc(
"unit description in lists",
"bits"),
383 i18nc(
"unit synonyms for matching user input",
"b;bit;bits"),
385 ki18nc(
"amount in units (real)",
"%1 bits"),
386 ki18ncp(
"amount in units (integer)",
"%1 bit",
"%1 bits")));
QString i18nc(const char *context, const char *text, const TYPE &arg...)
KLocalizedString KI18N_EXPORT ki18ncp(const char *context, const char *singular, const char *plural)
KLocalizedString KI18N_EXPORT ki18nc(const char *context, const char *text)
QString i18n(const char *text, const TYPE &arg...)