Git init
[framework/uifw/isf.git] / ism / src / scim_iconv.h
1 /** @file scim_iconv.h
2  *  @brief definition of IConvert related classes.
3  */
4
5 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
6
7 /*
8  * Smart Common Input Method
9  *
10  * Copyright (c) 2002-2005 James Su <suzhe@tsinghua.org.cn>
11  *
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public
15  * License as published by the Free Software Foundation; either
16  * version 2 of the License, or (at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this program; if not, write to the
25  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
26  * Boston, MA  02111-1307  USA
27  *
28  * $Id: scim_iconv.h,v 1.18 2005/08/15 12:45:46 suzhe Exp $
29  */
30
31 #ifndef __SCIM_ICONVERT_H
32 #define __SCIM_ICONVERT_H
33
34 namespace scim {
35
36 /**
37  * @addtogroup Accessories
38  * @ingroup InputServiceFramework
39  * @{
40  */
41
42 #define SCIM_MAX_BUFSIZE    4096
43
44 /**
45  * @brief A class to convert strings between UCS-4 and local encodings.
46  */
47 class IConvert
48 {
49     class IConvertImpl;
50
51     IConvertImpl * m_impl;
52
53 public:
54     /**
55      * @brief Constructor
56      * @param encoding the local encoding to be used.
57      */
58     IConvert (const String& encoding = String ());
59
60     /**
61      * @brief Copy constructor
62      */
63     IConvert (const IConvert & iconvert);
64
65     ~IConvert ();
66
67     /**
68      * @brief Assign operator
69      */
70     const IConvert & operator = (const IConvert & iconvert);
71
72     /**
73      * @brief Set the working local encoding.
74      * @param encoding the local encoding to be used.
75      * @return whether the encoding is ok or not.
76      */
77     bool set_encoding (const String& encoding);
78
79     /**
80      * @brief Get the current working local encoding.
81      * @return The name of the local encoding, like "UTF-8", "GB2312" etc.
82      */
83     String get_encoding () const;
84
85     /**
86      * @brief Convert a UCS-4 encoded WideString into a local encoded String.
87      * @param dest the result string will be stored here.
88      * @param src the WideString to be converted.
89      * @return true if success.
90      */
91     bool convert (String &dest, const WideString &src) const;
92
93     /**
94      * @brief Convert a UCS-4 encoded WideString into a local encoded String.
95      * @param dest the result string will be stored here.
96      * @param src the ucs-4 encoded string to be converted.
97      * @param src_len the length of source string.
98      * @return true if success.
99      */
100     bool convert (String &dest, const ucs4_t *src, int src_len) const;
101
102     /**
103      * @brief Convert a local encoded String into a UCS-4 encoded WideString.
104      * @param dest the result string will be stored here.
105      * @param src the local encoded string to be converted.
106      * @return ture if success.
107      */
108     bool convert (WideString &dest, const String &src) const;
109
110     /**
111      * @brief Convert a local encoded String into a UCS-4 encoded WideString.
112      * @param dest the result string will be stored here.
113      * @param src the local encoded string to be converted.
114      * @param src_len the length of source string.
115      * @return ture if success.
116      */
117     bool convert (WideString &dest, const char *src, int src_len) const;
118
119     /**
120      * @brief Test if a UCS-4 encoded WideString can be converted to a local encoded String.
121      * @param src the ucs-4 encoded string to be test.
122      * @return true if it can be converted without any problem.
123      */
124     bool test_convert (const WideString &src) const;
125
126     /**
127      * @brief Test if a ucs-4 encoded string can be converted to a local encoded String.
128      * @param src the ucs-4 encoded string to be test.
129      * @param src_len the length of source string.
130      * @return true if it can be converted without any problem.
131      */
132     bool test_convert (const ucs4_t *src, int src_len) const;
133
134     /**
135      * @brief Test if a local encoded string can be converted to a UCS-4 encoded WideString.
136      * @param src the local encoded string to be test.
137      * @return true if it can be converted without any problem.
138      */
139     bool test_convert (const String &src) const;
140
141     /**
142      * @brief Test if a local encoded string can be converted to a UCS-4 encoded WideString.
143      * @param src the local encoded string to be test.
144      * @param src_len the length of source string.
145      * @return true if it can be converted without any problem.
146      */
147     bool test_convert (const char *src, int src_len) const;
148 };
149
150 /** @} */
151
152 } // namespace scim
153
154 #endif //__SCIM_ICONVERT_H
155
156 /*
157 vi:ts=4:nowrap:ai:expandtab
158 */