iconv.h

Go to the documentation of this file.
00001 ///
00002 /// \file       iconv.h
00003 ///             iconv wrapper class, and pluggable interface for records
00004 ///
00005 
00006 /*
00007     Copyright (C) 2008-2009, 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 #ifndef __BARRY_ICONV_H__
00023 #define __BARRY_ICONV_H__
00024 
00025 #include "dll.h"
00026 #include "data.h"
00027 #include <iconv.h>
00028 #include <string>
00029 
00030 namespace Barry {
00031 
00032 class BXEXPORT IConverter
00033 {
00034         iconv_t m_from;
00035         iconv_t m_to;
00036 
00037         // internal buffer for fast conversions
00038         mutable Data m_buffer;
00039 
00040         bool m_throw_on_conv_err;
00041 
00042 private:
00043         std::string Convert(iconv_t cd, const std::string &str) const;
00044 
00045 public:
00046         /// Always throws ErrnoError if unable to open iconv.
00047         /// If throw_on_conv_err is true, then string conversion operations
00048         /// that fail will also throw ErrnoError.
00049         explicit IConverter(const char *tocode = "UTF-8", bool throw_on_conv_err = false);
00050         ~IConverter();
00051 
00052         std::string FromBB(const std::string &str) const;
00053         std::string ToBB(const std::string &str) const;
00054 };
00055 
00056 } // namespace Barry
00057 
00058 #endif
00059 

Generated on Mon Jan 12 10:51:12 2009 for Barry by  doxygen 1.5.7.1