IConv.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2005 Novell, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Novell, Inc., nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Novell, Inc., OR THE 
00022 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00023 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00024 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
00025 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
00026 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
00027 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
00028 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 *******************************************************************************/
00034 #ifndef  BLOCXX_ICONV_HPP_INCLUDE_GUARD_HPP_
00035 #define  BLOCXX_ICONV_HPP_INCLUDE_GUARD_HPP_
00036 #include "blocxx/BLOCXX_config.h"
00037 
00038 #ifdef   BLOCXX_HAVE_ICONV_H
00039 #include "blocxx/String.hpp"
00040 #include "blocxx/Array.hpp"
00041 #include <string>
00042 #include <iconv.h>
00043 
00044 namespace BLOCXX_NAMESPACE
00045 {
00046 
00051 class BLOCXX_COMMON_API IConv_t
00052 {
00053 public:
00057    IConv_t();
00058 
00071    IConv_t(const String &fromEncoding, const String &toEncoding);
00072 
00076    ~IConv_t();
00077 
00088    bool         open(const String &fromEncoding, const String &toEncoding);
00089 
00104    size_t       convert(char **istr, size_t *ibytesleft,
00105                         char **ostr, size_t *obytesleft);
00106 
00114    bool         close();
00115 
00116 private:
00117    iconv_t m_iconv;
00118 };
00119 
00124 namespace IConv
00125 {
00138    BLOCXX_COMMON_API String
00139    fromByteString(const String &enc, const char *str, size_t len);
00140 
00152    BLOCXX_COMMON_API String
00153    fromByteString(const String &enc, const std::string  &str);
00154 
00166    BLOCXX_COMMON_API String
00167    fromWideString(const String &enc, const std::wstring &str);
00168 
00180    BLOCXX_COMMON_API std::string
00181    toByteString(const String &enc, const String &utf8);
00182 
00194    BLOCXX_COMMON_API std::wstring
00195    toWideString(const String &enc, const String &utf8);
00196 
00197 #if 0
00198    /*
00199     * Retrieve an array of supported encoding names.
00200     *
00201     * @return   array with supported encoding names.
00202     */
00203    BLOCXX_COMMON_API StringArray
00204    encodings();
00205 #endif
00206 
00207 }  // End of IConv namespace
00208 }  // End of BLOCXX_NAMESPACE
00209 
00210 #endif  // BLOCXX_HAVE_ICONV_H
00211 #endif   // INCLUDE_GUARD_HPP_
00212 
00213 /* vim: set ts=8 sts=8 sw=8 ai noet: */
00214 

Generated on Fri Jun 16 15:39:08 2006 for blocxx by  doxygen 1.4.6