MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CharsetMap.hpp
1 /*
2  Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
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; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 /*
18  * CharsetMap.hpp
19  */
20 
21 #ifndef CharsetMap_hpp
22 #define CharsetMap_hpp
23 
24 /*
25  * This API uses the C99 exact-width type aliases as defined in <stdint.h>.
26  * Unfortunately, some C/C++ compiler still lack a stdint.h header file.
27  * (For instance, MS Visual Studio until VS2010.)
28  *
29  * Since this API has no dependency upon NDBAPI, we do not want to use
30  * the exact-width type aliases from there but delegate to a generic helper
31  * file that handles the absence of the <stdint.h>.
32  */
33 #include "mystdint.h"
34 
39 class CharsetMap {
40 public:
41 
42  CharsetMap();
43  /* The compiler-generated destructor is OK. */
44  /* The compiler-generated copy constructor is OK. */
45  /* The compiler-generated assignment operator is OK. */
46 
52  static void init();
53 
58  static void unload();
59 
73  const char * getName(int cs_number) const;
74 
78  const char * getMysqlName(int cs_number) const;
79 
84  int getCharsetNumber(const char *mysql_name) const;
85 
89  int getUTF8CharsetNumber() const;
90 
94  int getUTF16CharsetNumber() const;
95 
99  enum RecodeStatus {
100  RECODE_OK ,
101  RECODE_BAD_CHARSET ,
102  RECODE_BAD_SRC ,
103  RECODE_BUFF_TOO_SMALL
104  };
105 
110  const bool * isMultibyte(int cs_number) const;
111 
128  RecodeStatus recode(int32_t *lengths /* IN/OUT */,
129  int cs_from, int cs_to, const void *src,
130  void *dest) const;
131 
132 };
133 
134 #endif // CharsetMap_hpp