lean cpp library
A lean C++ library providing efficient utility classes for high-performance C++ applications.
|
00001 /*****************************************************/ 00002 /* lean Logging (c) Tobias Zirr 2011 */ 00003 /*****************************************************/ 00004 00005 #ifndef LEAN_LOGGING_STREAMCONV 00006 #define LEAN_LOGGING_STREAMCONV 00007 00008 #include "../lean.h" 00009 #include "../strings/types.h" 00010 #include "../strings/conversions.h" 00011 #include <iosfwd> 00012 #include <ostream> 00013 00014 // Drop-in replacements for missing utf8 streaming operators 00015 template <class Traits, class StringTraits, class StringAlloc> 00016 inline std::basic_ostream<lean::utf8_t, Traits>& operator <<( 00017 std::basic_ostream<lean::utf8_t, Traits>& stream, 00018 const std::basic_string<lean::utf16_t, StringTraits, StringAlloc> &string) 00019 { 00020 return (stream << lean::utf_to_utf8(string)); 00021 } 00022 template <class Traits, class StringTraits, class StringAlloc> 00023 inline std::basic_ostream<lean::utf8_t, Traits>& operator <<( 00024 std::basic_ostream<lean::utf8_t, Traits>& stream, 00025 const std::basic_string<lean::utf32_t, StringTraits, StringAlloc> &string) 00026 { 00027 return (stream << lean::utf_to_utf8(string)); 00028 } 00029 template <class Traits> 00030 inline std::basic_ostream<lean::utf8_t, Traits>& operator <<(std::basic_ostream<lean::utf8_t, Traits>& stream, const lean::utf16_t *str) 00031 { 00032 return (stream << lean::utf_to_utf8(str)); 00033 } 00034 template <class Traits> 00035 inline std::basic_ostream<lean::utf8_t, Traits>& operator <<(std::basic_ostream<lean::utf8_t, Traits>& stream, const lean::utf32_t *str) 00036 { 00037 return (stream << lean::utf_to_utf8(str)); 00038 } 00039 00040 // Drop-in replacements for missing utf16 streaming operators 00041 template <class Traits, class StringTraits, class StringAlloc> 00042 inline std::basic_ostream<lean::utf16_t, Traits>& operator <<( 00043 std::basic_ostream<lean::utf16_t, Traits>& stream, 00044 const std::basic_string<lean::utf32_t, StringTraits, StringAlloc> &string) 00045 { 00046 return (stream << lean::utf_to_utf16(string)); 00047 } 00048 template <class Traits> 00049 inline std::basic_ostream<lean::utf16_t, Traits>& operator <<(std::basic_ostream<lean::utf16_t, Traits>& stream, const lean::utf32_t *str) 00050 { 00051 return (stream << lean::utf_to_utf16(str)); 00052 } 00053 00054 // Drop-in replacements for missing utf32 streaming operators 00055 template <class Traits, class StringTraits, class StringAlloc> 00056 inline std::basic_ostream<lean::utf32_t, Traits>& operator <<( 00057 std::basic_ostream<lean::utf32_t, Traits>& stream, 00058 const std::basic_string<lean::utf16_t, StringTraits, StringAlloc> &string) 00059 { 00060 return (stream << lean::utf_to_utf32(string)); 00061 } 00062 template <class Traits> 00063 inline std::basic_ostream<lean::utf32_t, Traits>& operator <<(std::basic_ostream<lean::utf32_t, Traits>& stream, const lean::utf16_t *str) 00064 { 00065 return (stream << lean::utf_to_utf32(str)); 00066 } 00067 00068 #endif