iconvwin.cc

Go to the documentation of this file.
00001 ///
00002 /// \file       iconvwin.cc
00003 ///             iconv wrapper class for Windows
00004 ///
00005 
00006 /*
00007     Copyright (C) 2008-2012, Net Direct Inc. (http://www.netdirect.ca/)
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00017 
00018     See the GNU General Public License in the COPYING file at the
00019     root directory of this project for more details.
00020 */
00021 
00022 #include "iconv.h"
00023 #include "common.h"
00024 #include "error.h"
00025 #include <errno.h>
00026 #include <string>
00027 
00028 using namespace std;
00029 
00030 namespace Barry {
00031 
00032 //////////////////////////////////////////////////////////////////////////////
00033 // IConvHandlePrivate class
00034 class IConvHandlePrivate
00035 {
00036 public:
00037 };
00038 
00039 //////////////////////////////////////////////////////////////////////////////
00040 // IConvHandle class
00041 
00042 IConvHandle::IConvHandle(const char *fromcode,
00043                          const char *tocode,
00044                          bool throw_on_conv_err)
00045         : m_priv( new IConvHandlePrivate )
00046         , m_throw_on_conv_err(throw_on_conv_err)
00047 {
00048 }
00049 
00050 IConvHandle::IConvHandle(const char *fromcode,
00051                          const IConverter &ic,
00052                          bool throw_on_conv_err)
00053         : m_priv( new IConvHandlePrivate )
00054         , m_throw_on_conv_err(throw_on_conv_err)
00055 {
00056 }
00057 
00058 IConvHandle::IConvHandle(const IConverter &ic,
00059                          const char *tocode,
00060                          bool throw_on_conv_err)
00061         : m_priv( new IConvHandlePrivate )
00062         , m_throw_on_conv_err(throw_on_conv_err)
00063 {
00064 }
00065 
00066 IConvHandle::~IConvHandle()
00067 {
00068 }
00069 
00070 std::string IConvHandle::Convert(Data &tmp, const std::string &str) const
00071 {
00072         // FIXME - need to add Windows support
00073         return str;
00074 }
00075 
00076 
00077 //////////////////////////////////////////////////////////////////////////////
00078 // IConvHandle class
00079 
00080 IConverter::IConverter(const char *tocode, bool throw_on_conv_err)
00081         : m_from(BLACKBERRY_CHARSET, tocode, throw_on_conv_err)
00082         , m_to(tocode, BLACKBERRY_CHARSET, throw_on_conv_err)
00083         , m_tocode(tocode)
00084 {
00085 }
00086 
00087 IConverter::~IConverter()
00088 {
00089 }
00090 
00091 std::string IConverter::FromBB(const std::string &str) const
00092 {
00093         return m_from.Convert(m_buffer, str);
00094 }
00095 
00096 std::string IConverter::ToBB(const std::string &str) const
00097 {
00098         return m_to.Convert(m_buffer, str);
00099 }
00100 
00101 std::string IConverter::Convert(const IConvHandle &custom, const std::string &str) const
00102 {
00103         return custom.Convert(m_buffer, str);
00104 }
00105 
00106 } // namespace Barry
00107