File indexing completed on 2025-01-18 09:51:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_RATIO_RATIO_IO_HPP
0013 #define BOOST_RATIO_RATIO_IO_HPP
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #include <boost/ratio/ratio.hpp>
0037 #include <string>
0038 #include <sstream>
0039
0040 namespace boost {
0041
0042 template <class Ratio, class CharT>
0043 struct ratio_string
0044 {
0045 static std::basic_string<CharT> symbol() {return prefix();}
0046 static std::basic_string<CharT> prefix();
0047 };
0048
0049 template <class Ratio, class CharT>
0050 std::basic_string<CharT>
0051 ratio_string<Ratio, CharT>::prefix()
0052 {
0053 std::basic_ostringstream<CharT> os;
0054 os << CharT('[') << Ratio::num << CharT('/')
0055 << Ratio::den << CharT(']');
0056 return os.str();
0057 }
0058
0059
0060
0061 template <>
0062 struct ratio_string<atto, char>
0063 {
0064 static std::string symbol() {return std::string(1, 'a');}
0065 static std::string prefix() {return std::string("atto");}
0066 };
0067
0068 template <>
0069 struct ratio_string<atto, char16_t>
0070 {
0071 static std::u16string symbol() {return std::u16string(1, u'a');}
0072 static std::u16string prefix() {return std::u16string(u"atto");}
0073 };
0074
0075 template <>
0076 struct ratio_string<atto, char32_t>
0077 {
0078 static std::u32string symbol() {return std::u32string(1, U'a');}
0079 static std::u32string prefix() {return std::u32string(U"atto");}
0080 };
0081
0082 template <>
0083 struct ratio_string<atto, wchar_t>
0084 {
0085 static std::wstring symbol() {return std::wstring(1, L'a');}
0086 static std::wstring prefix() {return std::wstring(L"atto");}
0087 };
0088
0089
0090
0091 template <>
0092 struct ratio_string<femto, char>
0093 {
0094 static std::string symbol() {return std::string(1, 'f');}
0095 static std::string prefix() {return std::string("femto");}
0096 };
0097
0098 template <>
0099 struct ratio_string<femto, char16_t>
0100 {
0101 static std::u16string symbol() {return std::u16string(1, u'f');}
0102 static std::u16string prefix() {return std::u16string(u"femto");}
0103 };
0104
0105 template <>
0106 struct ratio_string<femto, char32_t>
0107 {
0108 static std::u32string symbol() {return std::u32string(1, U'f');}
0109 static std::u32string prefix() {return std::u32string(U"femto");}
0110 };
0111
0112 template <>
0113 struct ratio_string<femto, wchar_t>
0114 {
0115 static std::wstring symbol() {return std::wstring(1, L'f');}
0116 static std::wstring prefix() {return std::wstring(L"femto");}
0117 };
0118
0119
0120
0121 template <>
0122 struct ratio_string<pico, char>
0123 {
0124 static std::string symbol() {return std::string(1, 'p');}
0125 static std::string prefix() {return std::string("pico");}
0126 };
0127
0128 template <>
0129 struct ratio_string<pico, char16_t>
0130 {
0131 static std::u16string symbol() {return std::u16string(1, u'p');}
0132 static std::u16string prefix() {return std::u16string(u"pico");}
0133 };
0134
0135 template <>
0136 struct ratio_string<pico, char32_t>
0137 {
0138 static std::u32string symbol() {return std::u32string(1, U'p');}
0139 static std::u32string prefix() {return std::u32string(U"pico");}
0140 };
0141
0142 template <>
0143 struct ratio_string<pico, wchar_t>
0144 {
0145 static std::wstring symbol() {return std::wstring(1, L'p');}
0146 static std::wstring prefix() {return std::wstring(L"pico");}
0147 };
0148
0149
0150
0151 template <>
0152 struct ratio_string<nano, char>
0153 {
0154 static std::string symbol() {return std::string(1, 'n');}
0155 static std::string prefix() {return std::string("nano");}
0156 };
0157
0158 template <>
0159 struct ratio_string<nano, char16_t>
0160 {
0161 static std::u16string symbol() {return std::u16string(1, u'n');}
0162 static std::u16string prefix() {return std::u16string(u"nano");}
0163 };
0164
0165 template <>
0166 struct ratio_string<nano, char32_t>
0167 {
0168 static std::u32string symbol() {return std::u32string(1, U'n');}
0169 static std::u32string prefix() {return std::u32string(U"nano");}
0170 };
0171
0172 template <>
0173 struct ratio_string<nano, wchar_t>
0174 {
0175 static std::wstring symbol() {return std::wstring(1, L'n');}
0176 static std::wstring prefix() {return std::wstring(L"nano");}
0177 };
0178
0179
0180
0181 template <>
0182 struct ratio_string<micro, char>
0183 {
0184 static std::string symbol() {return std::string("\xC2\xB5");}
0185 static std::string prefix() {return std::string("micro");}
0186 };
0187
0188 template <>
0189 struct ratio_string<micro, char16_t>
0190 {
0191 static std::u16string symbol() {return std::u16string(1, u'\xB5');}
0192 static std::u16string prefix() {return std::u16string(u"micro");}
0193 };
0194
0195 template <>
0196 struct ratio_string<micro, char32_t>
0197 {
0198 static std::u32string symbol() {return std::u32string(1, U'\xB5');}
0199 static std::u32string prefix() {return std::u32string(U"micro");}
0200 };
0201
0202 template <>
0203 struct ratio_string<micro, wchar_t>
0204 {
0205 static std::wstring symbol() {return std::wstring(1, L'\xB5');}
0206 static std::wstring prefix() {return std::wstring(L"micro");}
0207 };
0208
0209
0210
0211 template <>
0212 struct ratio_string<milli, char>
0213 {
0214 static std::string symbol() {return std::string(1, 'm');}
0215 static std::string prefix() {return std::string("milli");}
0216 };
0217
0218 template <>
0219 struct ratio_string<milli, char16_t>
0220 {
0221 static std::u16string symbol() {return std::u16string(1, u'm');}
0222 static std::u16string prefix() {return std::u16string(u"milli");}
0223 };
0224
0225 template <>
0226 struct ratio_string<milli, char32_t>
0227 {
0228 static std::u32string symbol() {return std::u32string(1, U'm');}
0229 static std::u32string prefix() {return std::u32string(U"milli");}
0230 };
0231
0232 template <>
0233 struct ratio_string<milli, wchar_t>
0234 {
0235 static std::wstring symbol() {return std::wstring(1, L'm');}
0236 static std::wstring prefix() {return std::wstring(L"milli");}
0237 };
0238
0239
0240
0241 template <>
0242 struct ratio_string<centi, char>
0243 {
0244 static std::string symbol() {return std::string(1, 'c');}
0245 static std::string prefix() {return std::string("centi");}
0246 };
0247
0248 template <>
0249 struct ratio_string<centi, char16_t>
0250 {
0251 static std::u16string symbol() {return std::u16string(1, u'c');}
0252 static std::u16string prefix() {return std::u16string(u"centi");}
0253 };
0254
0255 template <>
0256 struct ratio_string<centi, char32_t>
0257 {
0258 static std::u32string symbol() {return std::u32string(1, U'c');}
0259 static std::u32string prefix() {return std::u32string(U"centi");}
0260 };
0261
0262 template <>
0263 struct ratio_string<centi, wchar_t>
0264 {
0265 static std::wstring symbol() {return std::wstring(1, L'c');}
0266 static std::wstring prefix() {return std::wstring(L"centi");}
0267 };
0268
0269
0270
0271 template <>
0272 struct ratio_string<deci, char>
0273 {
0274 static std::string symbol() {return std::string(1, 'd');}
0275 static std::string prefix() {return std::string("deci");}
0276 };
0277
0278 template <>
0279 struct ratio_string<deci, char16_t>
0280 {
0281 static std::u16string symbol() {return std::u16string(1, u'd');}
0282 static std::u16string prefix() {return std::u16string(u"deci");}
0283 };
0284
0285 template <>
0286 struct ratio_string<deci, char32_t>
0287 {
0288 static std::u32string symbol() {return std::u32string(1, U'd');}
0289 static std::u32string prefix() {return std::u32string(U"deci");}
0290 };
0291
0292 template <>
0293 struct ratio_string<deci, wchar_t>
0294 {
0295 static std::wstring symbol() {return std::wstring(1, L'd');}
0296 static std::wstring prefix() {return std::wstring(L"deci");}
0297 };
0298
0299
0300
0301
0302
0303 template <>
0304 struct ratio_string<deca, char>
0305 {
0306 static std::string symbol() {return std::string("da");}
0307 static std::string prefix() {return std::string("deca");}
0308 };
0309
0310 template <>
0311 struct ratio_string<deca, char16_t>
0312 {
0313 static std::u16string symbol() {return std::u16string(u"da");}
0314 static std::u16string prefix() {return std::u16string(u"deca");}
0315 };
0316
0317 template <>
0318 struct ratio_string<deca, char32_t>
0319 {
0320 static std::u32string symbol() {return std::u32string(U"da");}
0321 static std::u32string prefix() {return std::u32string(U"deca");}
0322 };
0323
0324 template <>
0325 struct ratio_string<deca, wchar_t>
0326 {
0327 static std::wstring symbol() {return std::wstring(L"da");}
0328 static std::wstring prefix() {return std::wstring(L"deca");}
0329 };
0330
0331
0332
0333 template <>
0334 struct ratio_string<hecto, char>
0335 {
0336 static std::string symbol() {return std::string(1, 'h');}
0337 static std::string prefix() {return std::string("hecto");}
0338 };
0339
0340 template <>
0341 struct ratio_string<hecto, char16_t>
0342 {
0343 static std::u16string symbol() {return std::u16string(1, u'h');}
0344 static std::u16string prefix() {return std::u16string(u"hecto");}
0345 };
0346
0347 template <>
0348 struct ratio_string<hecto, char32_t>
0349 {
0350 static std::u32string symbol() {return std::u32string(1, U'h');}
0351 static std::u32string prefix() {return std::u32string(U"hecto");}
0352 };
0353
0354 template <>
0355 struct ratio_string<hecto, wchar_t>
0356 {
0357 static std::wstring symbol() {return std::wstring(1, L'h');}
0358 static std::wstring prefix() {return std::wstring(L"hecto");}
0359 };
0360
0361
0362
0363 template <>
0364 struct ratio_string<kilo, char>
0365 {
0366 static std::string symbol() {return std::string(1, 'k');}
0367 static std::string prefix() {return std::string("kilo");}
0368 };
0369
0370 template <>
0371 struct ratio_string<kilo, char16_t>
0372 {
0373 static std::u16string symbol() {return std::u16string(1, u'k');}
0374 static std::u16string prefix() {return std::u16string(u"kilo");}
0375 };
0376
0377 template <>
0378 struct ratio_string<kilo, char32_t>
0379 {
0380 static std::u32string symbol() {return std::u32string(1, U'k');}
0381 static std::u32string prefix() {return std::u32string(U"kilo");}
0382 };
0383
0384 template <>
0385 struct ratio_string<kilo, wchar_t>
0386 {
0387 static std::wstring symbol() {return std::wstring(1, L'k');}
0388 static std::wstring prefix() {return std::wstring(L"kilo");}
0389 };
0390
0391
0392
0393 template <>
0394 struct ratio_string<mega, char>
0395 {
0396 static std::string symbol() {return std::string(1, 'M');}
0397 static std::string prefix() {return std::string("mega");}
0398 };
0399
0400 template <>
0401 struct ratio_string<mega, char16_t>
0402 {
0403 static std::u16string symbol() {return std::u16string(1, u'M');}
0404 static std::u16string prefix() {return std::u16string(u"mega");}
0405 };
0406
0407 template <>
0408 struct ratio_string<mega, char32_t>
0409 {
0410 static std::u32string symbol() {return std::u32string(1, U'M');}
0411 static std::u32string prefix() {return std::u32string(U"mega");}
0412 };
0413
0414 template <>
0415 struct ratio_string<mega, wchar_t>
0416 {
0417 static std::wstring symbol() {return std::wstring(1, L'M');}
0418 static std::wstring prefix() {return std::wstring(L"mega");}
0419 };
0420
0421
0422
0423 template <>
0424 struct ratio_string<giga, char>
0425 {
0426 static std::string symbol() {return std::string(1, 'G');}
0427 static std::string prefix() {return std::string("giga");}
0428 };
0429
0430 template <>
0431 struct ratio_string<giga, char16_t>
0432 {
0433 static std::u16string symbol() {return std::u16string(1, u'G');}
0434 static std::u16string prefix() {return std::u16string(u"giga");}
0435 };
0436
0437 template <>
0438 struct ratio_string<giga, char32_t>
0439 {
0440 static std::u32string symbol() {return std::u32string(1, U'G');}
0441 static std::u32string prefix() {return std::u32string(U"giga");}
0442 };
0443
0444 template <>
0445 struct ratio_string<giga, wchar_t>
0446 {
0447 static std::wstring symbol() {return std::wstring(1, L'G');}
0448 static std::wstring prefix() {return std::wstring(L"giga");}
0449 };
0450
0451
0452
0453 template <>
0454 struct ratio_string<tera, char>
0455 {
0456 static std::string symbol() {return std::string(1, 'T');}
0457 static std::string prefix() {return std::string("tera");}
0458 };
0459
0460 template <>
0461 struct ratio_string<tera, char16_t>
0462 {
0463 static std::u16string symbol() {return std::u16string(1, u'T');}
0464 static std::u16string prefix() {return std::u16string(u"tera");}
0465 };
0466
0467 template <>
0468 struct ratio_string<tera, char32_t>
0469 {
0470 static std::u32string symbol() {return std::u32string(1, U'T');}
0471 static std::u32string prefix() {return std::u32string(U"tera");}
0472 };
0473
0474 template <>
0475 struct ratio_string<tera, wchar_t>
0476 {
0477 static std::wstring symbol() {return std::wstring(1, L'T');}
0478 static std::wstring prefix() {return std::wstring(L"tera");}
0479 };
0480
0481
0482
0483 template <>
0484 struct ratio_string<peta, char>
0485 {
0486 static std::string symbol() {return std::string(1, 'P');}
0487 static std::string prefix() {return std::string("peta");}
0488 };
0489
0490 template <>
0491 struct ratio_string<peta, char16_t>
0492 {
0493 static std::u16string symbol() {return std::u16string(1, u'P');}
0494 static std::u16string prefix() {return std::u16string(u"peta");}
0495 };
0496
0497 template <>
0498 struct ratio_string<peta, char32_t>
0499 {
0500 static std::u32string symbol() {return std::u32string(1, U'P');}
0501 static std::u32string prefix() {return std::u32string(U"peta");}
0502 };
0503
0504 template <>
0505 struct ratio_string<peta, wchar_t>
0506 {
0507 static std::wstring symbol() {return std::wstring(1, L'P');}
0508 static std::wstring prefix() {return std::wstring(L"peta");}
0509 };
0510
0511
0512
0513 template <>
0514 struct ratio_string<exa, char>
0515 {
0516 static std::string symbol() {return std::string(1, 'E');}
0517 static std::string prefix() {return std::string("exa");}
0518 };
0519
0520 template <>
0521 struct ratio_string<exa, char16_t>
0522 {
0523 static std::u16string symbol() {return std::u16string(1, u'E');}
0524 static std::u16string prefix() {return std::u16string(u"exa");}
0525 };
0526
0527 template <>
0528 struct ratio_string<exa, char32_t>
0529 {
0530 static std::u32string symbol() {return std::u32string(1, U'E');}
0531 static std::u32string prefix() {return std::u32string(U"exa");}
0532 };
0533
0534 template <>
0535 struct ratio_string<exa, wchar_t>
0536 {
0537 static std::wstring symbol() {return std::wstring(1, L'E');}
0538 static std::wstring prefix() {return std::wstring(L"exa");}
0539 };
0540
0541 }
0542
0543 #endif