3 /// iconv wrapper class for Windows
7 Copyright (C) 2008-2012, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
34 //////////////////////////////////////////////////////////////////////////////
35 // IConvHandlePrivate class
36 class IConvHandlePrivate
41 //////////////////////////////////////////////////////////////////////////////
44 IConvHandle::IConvHandle(const char *fromcode
,
46 bool throw_on_conv_err
)
47 : m_priv( new IConvHandlePrivate
)
48 , m_throw_on_conv_err(throw_on_conv_err
)
52 IConvHandle::IConvHandle(const char *fromcode
,
54 bool throw_on_conv_err
)
55 : m_priv( new IConvHandlePrivate
)
56 , m_throw_on_conv_err(throw_on_conv_err
)
60 IConvHandle::IConvHandle(const IConverter
&ic
,
62 bool throw_on_conv_err
)
63 : m_priv( new IConvHandlePrivate
)
64 , m_throw_on_conv_err(throw_on_conv_err
)
68 IConvHandle::IConvHandle(const IConvHandle
&other
)
70 /* This is private to prevent copying, so shouldn't ever be called.
71 * However MSCL still generates refernces to it, so it needs to be provided. */
72 throw std::logic_error("IConvHandle copy constructor: should never be called.");
75 IConvHandle::~IConvHandle()
80 IConvHandle
& IConvHandle::operator=(const IConvHandle
&other
)
82 /* This is private to prevent copying, so shouldn't ever be called.
83 * However MSCL still generates refernces to it, so it needs to be provided. */
84 throw std::logic_error("IConvHandle operator=(): should never be called.");
87 std::string
IConvHandle::Convert(Data
&tmp
, const std::string
&str
) const
89 // FIXME - need to add Windows support
94 //////////////////////////////////////////////////////////////////////////////
97 IConverter::IConverter(const char *tocode
, bool throw_on_conv_err
)
98 : m_from(BLACKBERRY_CHARSET
, tocode
, throw_on_conv_err
)
99 , m_to(tocode
, BLACKBERRY_CHARSET
, throw_on_conv_err
)
104 IConverter::~IConverter()
108 std::string
IConverter::FromBB(const std::string
&str
) const
110 return m_from
.Convert(m_buffer
, str
);
113 std::string
IConverter::ToBB(const std::string
&str
) const
115 return m_to
.Convert(m_buffer
, str
);
118 std::string
IConverter::Convert(const IConvHandle
&custom
, const std::string
&str
) const
120 return custom
.Convert(m_buffer
, str
);