Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

scim_iconv.h

Go to the documentation of this file.
00001 /** @file scim_iconv.h
00002  *  @brief definition of IConvert related classes.
00003  */
00004 
00005 /* 
00006  * Smart Common Input Method
00007  * 
00008  * Copyright (c) 2004 James Su <suzhe@turbolinux.com.cn>
00009  * Copyright (c) 2003 James Su <suzhe@turbolinux.com.cn>
00010  * Copyright (c) 2002 James Su <suzhe@turbolinux.com.cn>
00011  *
00012  *
00013  * This library is free software; you can redistribute it and/or
00014  * modify it under the terms of the GNU Lesser General Public
00015  * License as published by the Free Software Foundation; either
00016  * version 2 of the License, or (at your option) any later version.
00017  *
00018  * This library is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU Lesser General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public
00024  * License along with this program; if not, write to the
00025  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00026  * Boston, MA  02111-1307  USA
00027  *
00028  * $Id: scim_iconv.h,v 1.14 2004/02/16 05:15:00 suzhe Exp $
00029  */
00030 
00031 #ifndef __SCIM_ICONVERT_H
00032 #define __SCIM_ICONVERT_H
00033 
00034 namespace scim {
00035 
00036 /**
00037  * @addtogroup Helper
00038  * @{
00039  */
00040 
00041 #define SCIM_MAX_BUFSIZE    4096
00042 
00043 /**
00044  * @brief A class to convert strings between UCS-4 and local encodings.
00045  */
00046 class IConvert
00047 {
00048     class IConvertImpl;
00049 
00050     IConvertImpl * m_impl;
00051 
00052 public:
00053     /**
00054      * @brief Constructor
00055      * @param encoding the local encoding to be used.
00056      */
00057     IConvert (const String& encoding = String ());
00058 
00059     /**
00060      * @brief Copy constructor
00061      */
00062     IConvert (const IConvert & iconvert);
00063 
00064     ~IConvert ();
00065 
00066     /**
00067      * @brief Assign operator
00068      */
00069     const IConvert & operator = (const IConvert & iconvert);
00070 
00071     /**
00072      * @brief Set the working local encoding.
00073      * @param encoding the local encoding to be used.
00074      */
00075     bool set_encoding (const String& encoding);
00076 
00077     /**
00078      * @brief Convert a UCS-4 encoded WideString into a local encoded String.
00079      * @param dest the result string will be stored here.
00080      * @param src the WideString to be converted.
00081      * @return true if success.
00082      */
00083     bool convert (String &dest, const WideString &src) const;
00084 
00085     /**
00086      * @brief Convert a UCS-4 encoded WideString into a local encoded String.
00087      * @param dest the result string will be stored here.
00088      * @param src the ucs-4 encoded string to be converted.
00089      * @param src_len the length of source string.
00090      * @return true if success.
00091      */
00092     bool convert (String &dest, const ucs4_t *src, int src_len) const;
00093 
00094     /**
00095      * @brief Convert a local encoded String into a UCS-4 encoded WideString.
00096      * @param dest the result string will be stored here.
00097      * @param src the local encoded string to be converted.
00098      * @return ture if success.
00099      */
00100     bool convert (WideString &dest, const String &src) const;
00101 
00102     /**
00103      * @brief Convert a local encoded String into a UCS-4 encoded WideString.
00104      * @param dest the result string will be stored here.
00105      * @param src the local encoded string to be converted.
00106      * @param src_len the length of source string.
00107      * @return ture if success.
00108      */
00109     bool convert (WideString &dest, const char *src, int src_len) const;
00110 
00111     /**
00112      * @brief Test if a UCS-4 encoded WideString can be converted to a local encoded String.
00113      * @param src the ucs-4 encoded string to be test.
00114      * @return true if it can be converted without any problem.
00115      */
00116     bool test_convert (const WideString &src) const;
00117 
00118     /**
00119      * @brief Test if a ucs-4 encoded string can be converted to a local encoded String.
00120      * @param src the ucs-4 encoded string to be test.
00121      * @param src_len the length of source string.
00122      * @return true if it can be converted without any problem.
00123      */
00124     bool test_convert (const ucs4_t *src, int src_len) const;
00125 
00126     /**
00127      * @brief Test if a local encoded string can be converted to a UCS-4 encoded WideString.
00128      * @param src the local encoded string to be test.
00129      * @return true if it can be converted without any problem.
00130      */
00131     bool test_convert (const String &src) const;
00132 
00133     /**
00134      * @brief Test if a local encoded string can be converted to a UCS-4 encoded WideString.
00135      * @param src the local encoded string to be test.
00136      * @param src_len the length of source string.
00137      * @return true if it can be converted without any problem.
00138      */
00139     bool test_convert (const char *src, int src_len) const;
00140 };
00141 
00142 /** @} */
00143 
00144 } // namespace scim
00145 
00146 #endif //__SCIM_ICONVERT_H
00147 
00148 /*
00149 vi:ts=4:nowrap:ai:expandtab
00150 */

Generated on Fri May 7 17:27:25 2004 for scim by doxygen 1.3.6