123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631 |
- // ratio_io
- //
- // (C) Copyright 2010 Vicente J. Botet Escriba
- // Use, modification and distribution are subject to the Boost Software License,
- // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- // http://www.boost.org/LICENSE_1_0.txt).
- //
- // This code was adapted by Vicente from Howard Hinnant's experimental work
- // on chrono i/o under lvm/libc++ to Boost
- #ifndef BOOST_RATIO_RATIO_STATIC_STRING_HPP
- #define BOOST_RATIO_RATIO_STATIC_STRING_HPP
- /*
- ratio_static_string synopsis
- #include <ratio>
- #include <string>
- namespace boost
- {
- template <class Ratio, class CharT>
- struct ratio_static_string
- {
- typedef basic_str<CharT, ...> short_name;
- typedef basic_str<CharT, ...> long_name;
- };
- } // boost
- */
- #include <boost/config.hpp>
- #include <boost/ratio/ratio.hpp>
- #include <boost/static_string/basic_str.hpp>
- //#include <sstream>
- #if defined(BOOST_NO_CXX11_UNICODE_LITERALS) || defined(BOOST_NO_CXX11_CHAR16_T) || defined(BOOST_NO_CXX11_CHAR32_T)
- //~ #define BOOST_RATIO_HAS_UNICODE_SUPPORT
- #else
- #define BOOST_RATIO_HAS_UNICODE_SUPPORT 1
- #endif
- namespace boost {
- template <class Ratio, class CharT>
- struct ratio_static_string;
- // atto
- template <>
- struct ratio_static_string<atto, char>
- {
- typedef static_string::str_1<'a'>::type short_name;
- typedef static_string::str_4<'a','t','t','o'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<atto, char16_t>
- {
- typedef static_string::u16str_1<u'a'>::type short_name;
- typedef static_string::u16str_4<u'a',u't',u't',u'o'>::type long_name;
- };
- template <>
- struct ratio_static_string<atto, char32_t>
- {
- typedef static_string::u32str_1<U'a'>::type short_name;
- typedef static_string::u32str_4<U'a',U't',U't',U'o'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<atto, wchar_t>
- {
- typedef static_string::wstr_1<L'a'>::type short_name;
- typedef static_string::wstr_4<L'a',L't',L't',L'o'>::type long_name;
- };
- #endif
- // femto
- template <>
- struct ratio_static_string<femto, char>
- {
- typedef static_string::str_1<'f'>::type short_name;
- typedef static_string::str_5<'f','e','m','t','o'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<femto, char16_t>
- {
- typedef static_string::u16str_1<u'f'>::type short_name;
- typedef static_string::u16str_5<u'f',u'e',u'm',u't',u'o'>::type long_name;
- };
- template <>
- struct ratio_static_string<femto, char32_t>
- {
- typedef static_string::u32str_1<U'f'>::type short_name;
- typedef static_string::u32str_5<U'f',U'e',U'm',U't',U'o'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<femto, wchar_t>
- {
- typedef static_string::wstr_1<L'f'>::type short_name;
- typedef static_string::wstr_5<L'f',L'e',L'm',L't',L'o'>::type long_name;
- };
- #endif
- // pico
- template <>
- struct ratio_static_string<pico, char>
- {
- typedef static_string::str_1<'p'>::type short_name;
- typedef static_string::str_4<'p','i','c','o'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<pico, char16_t>
- {
- typedef static_string::u16str_1<u'p'>::type short_name;
- typedef static_string::u16str_4<u'p',u'i',u'c',u'o'>::type long_name;
- };
- template <>
- struct ratio_static_string<pico, char32_t>
- {
- typedef static_string::u32str_1<U'p'>::type short_name;
- typedef static_string::u32str_4<U'p',U'i',U'c',U'o'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<pico, wchar_t>
- {
- typedef static_string::wstr_1<L'p'>::type short_name;
- typedef static_string::wstr_4<L'p',L'i',L'c',L'o'>::type long_name;
- };
- #endif
- // nano
- template <>
- struct ratio_static_string<nano, char>
- {
- typedef static_string::str_1<'n'>::type short_name;
- typedef static_string::str_4<'n','a','n','o'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<nano, char16_t>
- {
- typedef static_string::u16str_1<u'n'>::type short_name;
- typedef static_string::u16str_4<u'n',u'a',u'n',u'o'>::type long_name;
- };
- template <>
- struct ratio_static_string<nano, char32_t>
- {
- typedef static_string::u32str_1<U'n'>::type short_name;
- typedef static_string::u32str_4<U'n',U'a',U'n',U'o'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<nano, wchar_t>
- {
- typedef static_string::wstr_1<L'n'>::type short_name;
- typedef static_string::wstr_4<L'n',L'a',L'n',L'o'>::type long_name;
- };
- #endif
- // micro
- template <>
- struct ratio_static_string<micro, char>
- {
- typedef static_string::str_2<'\xC2','\xB5'>::type short_name;
- typedef static_string::str_5<'m','i','c','r','o'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<micro, char16_t>
- {
- typedef static_string::u16str_1<u'\xB5'>::type short_name;
- typedef static_string::u16str_5<u'm',u'i',u'c',u'r',u'o'>::type long_name;
- };
- template <>
- struct ratio_static_string<micro, char32_t>
- {
- typedef static_string::u32str_1<U'\xB5'>::type short_name;
- typedef static_string::u32str_5<U'm',U'i',U'c',U'r',U'o'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<micro, wchar_t>
- {
- typedef static_string::wstr_1<L'\xB5'>::type short_name;
- typedef static_string::wstr_5<L'm',L'i',L'c',L'r',L'o'>::type long_name;
- };
- #endif
- // milli
- template <>
- struct ratio_static_string<milli, char>
- {
- typedef static_string::str_1<'m'>::type short_name;
- typedef static_string::str_5<'m','i','l','l','i'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<milli, char16_t>
- {
- typedef static_string::u16str_1<u'm'>::type short_name;
- typedef static_string::u16str_5<u'm',u'i',u'l',u'l',u'i'>::type long_name;
- };
- template <>
- struct ratio_static_string<milli, char32_t>
- {
- typedef static_string::u32str_1<U'm'>::type short_name;
- typedef static_string::u32str_5<U'm',U'i',U'l',U'l',U'i'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<milli, wchar_t>
- {
- typedef static_string::wstr_1<L'm'>::type short_name;
- typedef static_string::wstr_5<L'm',L'i',L'l',L'l',L'i'>::type long_name;
- };
- #endif
- // centi
- template <>
- struct ratio_static_string<centi, char>
- {
- typedef static_string::str_1<'c'>::type short_name;
- typedef static_string::str_5<'c','e','n','t','i'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<centi, char16_t>
- {
- typedef static_string::u16str_1<u'c'>::type short_name;
- typedef static_string::u16str_5<u'c',u'e',u'n',u't',u'i'>::type long_name;
- };
- template <>
- struct ratio_static_string<centi, char32_t>
- {
- typedef static_string::u32str_1<U'c'>::type short_name;
- typedef static_string::u32str_5<U'c',U'e',U'n',U't',U'i'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<centi, wchar_t>
- {
- typedef static_string::wstr_1<L'c'>::type short_name;
- typedef static_string::wstr_5<L'c',L'e',L'n',L't',L'i'>::type long_name;
- };
- #endif
- // deci
- template <>
- struct ratio_static_string<deci, char>
- {
- typedef static_string::str_1<'d'>::type short_name;
- typedef static_string::str_4<'d','e','c','i'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<deci, char16_t>
- {
- typedef static_string::u16str_1<u'd'>::type short_name;
- typedef static_string::u16str_4<u'd',u'e',u'c',u'i'>::type long_name;
- };
- template <>
- struct ratio_static_string<deci, char32_t>
- {
- typedef static_string::u32str_1<U'd'>::type short_name;
- typedef static_string::u32str_4<U'd',U'e',U'c',U'i'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<deci, wchar_t>
- {
- typedef static_string::wstr_1<L'd'>::type short_name;
- typedef static_string::wstr_4<L'd',L'e',L'c',L'i'>::type long_name;
- };
- #endif
- // deca
- template <>
- struct ratio_static_string<deca, char>
- {
- typedef static_string::str_2<'d','a'>::type short_name;
- typedef static_string::str_4<'d','e','c','a'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<deca, char16_t>
- {
- typedef static_string::u16str_2<u'd',u'a'>::type short_name;
- typedef static_string::u16str_4<u'd',u'e',u'c',u'a'>::type long_name;
- };
- template <>
- struct ratio_static_string<deca, char32_t>
- {
- typedef static_string::u32str_2<U'd',U'a'>::type short_name;
- typedef static_string::u32str_4<U'd',U'e',U'c',U'a'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<deca, wchar_t>
- {
- typedef static_string::wstr_2<L'd',L'a'>::type short_name;
- typedef static_string::wstr_4<L'd',L'e',L'c',L'a'>::type long_name;
- };
- #endif
- // hecto
- template <>
- struct ratio_static_string<hecto, char>
- {
- typedef static_string::str_1<'h'>::type short_name;
- typedef static_string::str_5<'h','e','c','t','o'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<hecto, char16_t>
- {
- typedef static_string::u16str_1<u'h'>::type short_name;
- typedef static_string::u16str_5<u'h',u'e',u'c',u't',u'o'>::type long_name;
- };
- template <>
- struct ratio_static_string<hecto, char32_t>
- {
- typedef static_string::u32str_1<U'h'>::type short_name;
- typedef static_string::u32str_5<U'h',U'e',U'c',U't',U'o'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<hecto, wchar_t>
- {
- typedef static_string::wstr_1<L'h'>::type short_name;
- typedef static_string::wstr_5<L'h',L'e',L'c',L't',L'o'>::type long_name;
- };
- #endif
- // kilo
- template <>
- struct ratio_static_string<kilo, char>
- {
- typedef static_string::str_1<'k'>::type short_name;
- typedef static_string::str_4<'k','i','l','o'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<kilo, char16_t>
- {
- typedef static_string::u16str_1<u'k'>::type short_name;
- typedef static_string::u16str_4<u'k',u'i',u'l',u'o'>::type long_name;
- };
- template <>
- struct ratio_static_string<kilo, char32_t>
- {
- typedef static_string::u32str_1<U'k'>::type short_name;
- typedef static_string::u32str_4<U'k',U'i',U'l',U'o'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<kilo, wchar_t>
- {
- typedef static_string::wstr_1<L'k'>::type short_name;
- typedef static_string::wstr_4<L'k',L'i',L'l',L'o'>::type long_name;
- };
- #endif
- // mega
- template <>
- struct ratio_static_string<mega, char>
- {
- typedef static_string::str_1<'M'>::type short_name;
- typedef static_string::str_4<'m','e','g','a'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<mega, char16_t>
- {
- typedef static_string::u16str_1<u'M'>::type short_name;
- typedef static_string::u16str_4<u'm',u'e',u'g',u'a'>::type long_name;
- };
- template <>
- struct ratio_static_string<mega, char32_t>
- {
- typedef static_string::u32str_1<U'M'>::type short_name;
- typedef static_string::u32str_4<U'm',U'e',U'g',U'a'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<mega, wchar_t>
- {
- typedef static_string::wstr_1<L'M'>::type short_name;
- typedef static_string::wstr_4<L'm',L'e',L'g',L'a'>::type long_name;
- };
- #endif
- // giga
- template <>
- struct ratio_static_string<giga, char>
- {
- typedef static_string::str_1<'G'>::type short_name;
- typedef static_string::str_4<'g','i','g','a'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<giga, char16_t>
- {
- typedef static_string::u16str_1<u'G'>::type short_name;
- typedef static_string::u16str_4<u'g',u'i',u'g',u'a'>::type long_name;
- };
- template <>
- struct ratio_static_string<giga, char32_t>
- {
- typedef static_string::u32str_1<U'G'>::type short_name;
- typedef static_string::u32str_4<U'g',U'i',U'g',U'a'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<giga, wchar_t>
- {
- typedef static_string::wstr_1<L'G'>::type short_name;
- typedef static_string::wstr_4<L'g',L'i',L'g',L'a'>::type long_name;
- };
- #endif
- // tera
- template <>
- struct ratio_static_string<tera, char>
- {
- typedef static_string::str_1<'T'>::type short_name;
- typedef static_string::str_4<'t','e','r','a'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<tera, char16_t>
- {
- typedef static_string::u16str_1<u'T'>::type short_name;
- typedef static_string::u16str_4<u't',u'e',u'r',u'a'>::type long_name;
- };
- template <>
- struct ratio_static_string<tera, char32_t>
- {
- typedef static_string::u32str_1<U'T'>::type short_name;
- typedef static_string::u32str_4<U't',U'e',U'r',U'a'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<tera, wchar_t>
- {
- typedef static_string::wstr_1<L'T'>::type short_name;
- typedef static_string::wstr_4<L'r',L'e',L'r',L'a'>::type long_name;
- };
- #endif
- // peta
- template <>
- struct ratio_static_string<peta, char>
- {
- typedef static_string::str_1<'P'>::type short_name;
- typedef static_string::str_4<'p','e','t','a'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<peta, char16_t>
- {
- typedef static_string::u16str_1<u'P'>::type short_name;
- typedef static_string::u16str_4<u'p',u'e',u't',u'a'>::type long_name;
- };
- template <>
- struct ratio_static_string<peta, char32_t>
- {
- typedef static_string::u32str_1<U'P'>::type short_name;
- typedef static_string::u32str_4<U'p',U'e',U't',U'a'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<peta, wchar_t>
- {
- typedef static_string::wstr_1<L'P'>::type short_name;
- typedef static_string::wstr_4<L'p',L'e',L't',L'a'>::type long_name;
- };
- #endif
- // exa
- template <>
- struct ratio_static_string<exa, char>
- {
- typedef static_string::str_1<'E'>::type short_name;
- typedef static_string::str_3<'e','x','a'>::type long_name;
- };
- #ifdef BOOST_RATIO_HAS_UNICODE_SUPPORT
- template <>
- struct ratio_static_string<exa, char16_t>
- {
- typedef static_string::u16str_1<u'E'>::type short_name;
- typedef static_string::u16str_3<u'e',u'x',u'a'>::type long_name;
- };
- template <>
- struct ratio_static_string<exa, char32_t>
- {
- typedef static_string::u32str_1<U'E'>::type short_name;
- typedef static_string::u32str_3<U'e',U'x',U'a'>::type long_name;
- };
- #endif
- #ifndef BOOST_NO_STD_WSTRING
- template <>
- struct ratio_static_string<exa, wchar_t>
- {
- typedef static_string::wstr_1<L'E'>::type short_name;
- typedef static_string::wstr_3<L'e',L'x',L'a'>::type long_name;
- };
- #endif
- }
- #endif // BOOST_RATIO_RATIO_STATIC_STRING_HPP
|