Replaced std::auto_ptr<> with std::unique_ptr<>
[supertux.git] / external / tinygettext / tinygettext / iconv.hpp
1 //  tinygettext - A gettext replacement that works directly on .po files
2 //  Copyright (C) 2006 Ingo Ruhnke <grumbel@gmx.de>
3 //
4 //  This program is free software: you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation, either version 3 of the License, or
7 //  (at your option) any later version.
8 //  
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU General Public License for more details.
13 //  
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 #ifndef HEADER_TINYGETTEXT_ICONV_HPP
18 #define HEADER_TINYGETTEXT_ICONV_HPP
19
20 #include <string>
21
22 #ifdef HAVE_SDL
23 #  include "SDL.h"
24
25 #  define tinygettext_ICONV_CONST const
26 #  define tinygettext_iconv_t     SDL_iconv_t
27 #  define tinygettext_iconv       SDL_iconv
28 #  define tinygettext_iconv_open  SDL_iconv_open
29 #  define tinygettext_iconv_close SDL_iconv_close 
30 #else
31 #  include <iconv.h>
32
33 #  ifdef HAVE_ICONV_CONST
34 #    define tinygettext_ICONV_CONST ICONV_CONST
35 #  else
36 #    define tinygettext_ICONV_CONST 
37 #  endif
38
39 #  define tinygettext_iconv_t     iconv_t
40 #  define tinygettext_iconv       iconv
41 #  define tinygettext_iconv_open  iconv_open
42 #  define tinygettext_iconv_close iconv_close 
43 #endif
44
45 namespace tinygettext {
46
47 class IConv
48 {
49 private:
50   std::string to_charset;
51   std::string from_charset;
52   tinygettext_iconv_t cd;
53
54 public:
55   IConv();
56   IConv(const std::string& fromcode, const std::string& tocode);
57   ~IConv();
58
59   void set_charsets(const std::string& fromcode, const std::string& tocode);
60   std::string convert(const std::string& text);
61
62 private:
63   IConv (const IConv&);
64   IConv& operator= (const IConv&);
65 };
66
67 } // namespace tinygettext
68
69 #endif
70
71 /* EOF */