SFML logo
  • Main Page
  • Namespaces
  • Classes
  • Files
  • File List

Utf.hpp

00001 
00002 //
00003 // SFML - Simple and Fast Multimedia Library
00004 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
00005 //
00006 // This software is provided 'as-is', without any express or implied warranty.
00007 // In no event will the authors be held liable for any damages arising from the use of this software.
00008 //
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it freely,
00011 // subject to the following restrictions:
00012 //
00013 // 1. The origin of this software must not be misrepresented;
00014 //    you must not claim that you wrote the original software.
00015 //    If you use this software in a product, an acknowledgment
00016 //    in the product documentation would be appreciated but is not required.
00017 //
00018 // 2. Altered source versions must be plainly marked as such,
00019 //    and must not be misrepresented as being the original software.
00020 //
00021 // 3. This notice may not be removed or altered from any source distribution.
00022 //
00024 
00025 #ifndef SFML_UTF_HPP
00026 #define SFML_UTF_HPP
00027 
00029 // Headers
00031 #include <SFML/Config.hpp>
00032 #include <algorithm>
00033 #include <locale>
00034 #include <string>
00035 #include <stdlib.h>
00036 
00037 
00038 namespace sf
00039 {
00046 SFML_API const std::locale& GetDefaultLocale();
00047 
00048 template <unsigned int N>
00049 class Utf;
00050 
00055 template <>
00056 class Utf<8>
00057 {
00058 public :
00059 
00074     template <typename In>
00075     static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
00076 
00090     template <typename Out>
00091     static Out Encode(Uint32 input, Out output, Uint8 replacement = 0);
00092 
00105     template <typename In>
00106     static In Next(In begin, In end);
00107 
00121     template <typename In>
00122     static std::size_t Count(In begin, In end);
00123 
00138     template <typename In, typename Out>
00139     static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = GetDefaultLocale());
00140 
00151     template <typename In, typename Out>
00152     static Out FromWide(In begin, In end, Out output);
00153 
00169     template <typename In, typename Out>
00170     static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = GetDefaultLocale());
00171 
00183     template <typename In, typename Out>
00184     static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0);
00185 
00201     template <typename In, typename Out>
00202     static Out ToUtf8(In begin, In end, Out output);
00203 
00214     template <typename In, typename Out>
00215     static Out ToUtf16(In begin, In end, Out output);
00216 
00227     template <typename In, typename Out>
00228     static Out ToUtf32(In begin, In end, Out output);
00229 };
00230 
00235 template <>
00236 class Utf<16>
00237 {
00238 public :
00239 
00254     template <typename In>
00255     static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
00256 
00270     template <typename Out>
00271     static Out Encode(Uint32 input, Out output, Uint16 replacement = 0);
00272 
00285     template <typename In>
00286     static In Next(In begin, In end);
00287 
00301     template <typename In>
00302     static std::size_t Count(In begin, In end);
00303 
00318     template <typename In, typename Out>
00319     static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = GetDefaultLocale());
00320 
00331     template <typename In, typename Out>
00332     static Out FromWide(In begin, In end, Out output);
00333 
00349     template <typename In, typename Out>
00350     static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = GetDefaultLocale());
00351 
00363     template <typename In, typename Out>
00364     static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0);
00365 
00376     template <typename In, typename Out>
00377     static Out ToUtf8(In begin, In end, Out output);
00378 
00394     template <typename In, typename Out>
00395     static Out ToUtf16(In begin, In end, Out output);
00396 
00407     template <typename In, typename Out>
00408     static Out ToUtf32(In begin, In end, Out output);
00409 };
00410 
00415 template <>
00416 class Utf<32>
00417 {
00418 public :
00419 
00435     template <typename In>
00436     static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
00437 
00452     template <typename Out>
00453     static Out Encode(Uint32 input, Out output, Uint32 replacement = 0);
00454 
00467     template <typename In>
00468     static In Next(In begin, In end);
00469 
00482     template <typename In>
00483     static std::size_t Count(In begin, In end);
00484 
00499     template <typename In, typename Out>
00500     static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = GetDefaultLocale());
00501 
00512     template <typename In, typename Out>
00513     static Out FromWide(In begin, In end, Out output);
00514 
00530     template <typename In, typename Out>
00531     static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = GetDefaultLocale());
00532 
00544     template <typename In, typename Out>
00545     static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0);
00546 
00557     template <typename In, typename Out>
00558     static Out ToUtf8(In begin, In end, Out output);
00559 
00570     template <typename In, typename Out>
00571     static Out ToUtf16(In begin, In end, Out output);
00572 
00588     template <typename In, typename Out>
00589     static Out ToUtf32(In begin, In end, Out output);
00590 
00604     template <typename In>
00605     static Uint32 DecodeAnsi(In input, const std::locale& locale = GetDefaultLocale());
00606 
00619     template <typename In>
00620     static Uint32 DecodeWide(In input);
00621 
00637     template <typename Out>
00638     static Out EncodeAnsi(Uint32 codepoint, Out output, char replacement = 0, const std::locale& locale = GetDefaultLocale());
00639 
00654     template <typename Out>
00655     static Out EncodeWide(Uint32 codepoint, Out output, wchar_t replacement = 0);
00656 };
00657 
00658 #include <SFML/System/Utf.inl>
00659 
00660 // Make typedefs to get rid of the template syntax
00661 typedef Utf<8>  Utf8;
00662 typedef Utf<16> Utf16;
00663 typedef Utf<32> Utf32;
00664 
00665 } // namespace sf
00666 
00667 
00668 #endif // SFML_UTF_HPP
00669 
00670 

 ::  Copyright © 2007-2008 Laurent Gomila, all rights reserved  ::  Documentation generated by doxygen 1.5.2  ::