• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ut_mbtowc.h

Go to the documentation of this file.
00001 #ifndef UT_MBTOWC_H
00002 #define UT_MBTOWC_H
00003 
00004 #include "ut_misc.h"
00005 #include <limits.h>
00006 
00007 /* pre-emptive dismissal; ut_types.h is needed by just about everything,
00008  * so even if it's commented out in-file that's still a lot of work for
00009  * the preprocessor to do...
00010  */
00011 #ifndef UT_TYPES_H
00012 #include "ut_types.h"
00013 #endif
00014 #include "ut_iconv.h"
00015 
00016 // UTF-8 can use up to 6 bytes
00017 #define MY_MB_LEN_MAX 6
00018 
00019 // DO NOT USE MB_LEN_MAX -- on win32 it is only 2 bytes!
00020 const size_t iMbLenMax = UT_MAX(MY_MB_LEN_MAX, MB_LEN_MAX);
00021 
00022 class ABI_EXPORT UT_UCS2_mbtowc
00023 {
00024  private:
00025   class ABI_EXPORT Converter
00026     {
00027     public:
00028       Converter (const char * from_charset);
00029       ~Converter ();
00030 
00031       void initialize ();
00032 
00033       inline UT_iconv_t cd () const { return m_cd; }
00034 
00035     private:
00036       UT_iconv_t m_cd;
00037     };
00038   Converter * m_converter;
00039 
00040  public:
00041   void initialize (bool clear = true);
00042 
00043   UT_UCS2_mbtowc (const char * from_charset);
00044   ~UT_UCS2_mbtowc();
00045 
00046   void setInCharset (const char * from_charset);
00047 
00048   int mbtowc (UT_UCS2Char & wc, char mb);
00049 
00050   // TODO: make me private
00051   UT_UCS2_mbtowc ();
00052 
00053  private:
00054   // no impls
00055   UT_UCS2_mbtowc (const UT_UCS2_mbtowc & v);
00056   UT_UCS2_mbtowc& operator=(const UT_UCS2_mbtowc &rhs);
00057 
00058   size_t m_bufLen;
00059   char m_buf[iMbLenMax];
00060 };
00061 
00062 class ABI_EXPORT UT_UCS4_mbtowc
00063 {
00064  private:
00065   class ABI_EXPORT Converter
00066     {
00067     public:
00068       Converter (const char * from_charset);
00069 
00070       ~Converter ();
00071 
00072       void initialize ();
00073 
00074       inline UT_iconv_t cd () const { return m_cd; }
00075 
00076     private:
00077       UT_iconv_t m_cd;
00078     };
00079   Converter * m_converter;
00080 
00081  public:
00082   void initialize (bool clear = true);
00083 
00084   UT_UCS4_mbtowc (const char * from_charset);
00085   ~UT_UCS4_mbtowc();
00086 
00087   void setInCharset (const char * from_charset);
00088 
00089   int mbtowc (UT_UCS4Char & wc, char mb);
00090 
00091   // TODO: make me private
00092   UT_UCS4_mbtowc ();
00093 
00094  private:
00095   // no impls
00096   UT_UCS4_mbtowc (const UT_UCS4_mbtowc & v);
00097   UT_UCS4_mbtowc& operator=(const UT_UCS4_mbtowc &rhs);
00098 
00099   size_t m_bufLen;
00100   char m_buf[iMbLenMax];
00101 };
00102 
00103 #endif // UT_MBTOWC_H

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1