/home/ntakagi/work/STLport-5.1.5/src/codecvt.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1999
00003  * Silicon Graphics Computer Systems, Inc.
00004  *
00005  * Copyright (c) 1999
00006  * Boris Fomitchev
00007  *
00008  * This material is provided "as is", with absolutely no warranty expressed
00009  * or implied. Any use is at your own risk.
00010  *
00011  * Permission to use or copy this software for any purpose is hereby granted
00012  * without fee, provided the above notices are retained on all copies.
00013  * Permission to modify the code and to distribute modified code is granted,
00014  * provided the above notices are retained, and a notice that the code was
00015  * modified is included with the above copyright notice.
00016  *
00017  */
00018 #include "stlport_prefix.h"
00019 
00020 #ifndef _STLP_NO_MBSTATE_T
00021 
00022 #include <locale>
00023 #include <algorithm>
00024 
00025 _STLP_BEGIN_NAMESPACE
00026 
00027 //----------------------------------------------------------------------
00028 // codecvt<char, char, mbstate_t>
00029 
00030 codecvt<char, char, mbstate_t>::~codecvt() {}
00031 
00032 int codecvt<char, char, mbstate_t>::do_length(const mbstate_t&,
00033                                               const  char* from,
00034                                               const  char* end,
00035                                               size_t mx) const
00036 { return (int)(min) ( __STATIC_CAST(size_t, (end - from)), mx); }
00037 
00038 int codecvt<char, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
00039 { return 1; }
00040 
00041 bool
00042 codecvt<char, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
00043 { return true; }
00044 
00045 int
00046 codecvt<char, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
00047 { return 1; }
00048 
00049 codecvt_base::result
00050 codecvt<char, char, mbstate_t>::do_unshift(mbstate_t& /* __state */,
00051                                            char*      __to,
00052                                            char*      /* __to_limit */,
00053                                            char*&     __to_next) const
00054 { __to_next = __to; return noconv; }
00055 
00056 codecvt_base::result
00057 codecvt<char, char, mbstate_t>::do_in (mbstate_t&   /* __state */ ,
00058                                        const char*  __from,
00059                                        const char*  /* __from_end */,
00060                                        const char*& __from_next,
00061                                        char*        __to,
00062                                        char*        /* __to_end */,
00063                                        char*&       __to_next) const
00064 { __from_next = __from; __to_next   = __to; return noconv; }
00065 
00066 codecvt_base::result
00067 codecvt<char, char, mbstate_t>::do_out(mbstate_t&   /* __state */,
00068                                        const char*  __from,
00069                                        const char*  /* __from_end */,
00070                                        const char*& __from_next,
00071                                        char*        __to,
00072                                        char*        /* __to_limit */,
00073                                        char*&       __to_next) const
00074 { __from_next = __from; __to_next   = __to; return noconv; }
00075 
00076 
00077 #if !defined (_STLP_NO_WCHAR_T)
00078 //----------------------------------------------------------------------
00079 // codecvt<wchar_t, char, mbstate_t>
00080 
00081 codecvt<wchar_t, char, mbstate_t>::~codecvt() {}
00082 
00083 
00084 codecvt<wchar_t, char, mbstate_t>::result
00085 codecvt<wchar_t, char, mbstate_t>::do_out(state_type&         /* state */,
00086                                           const intern_type*  from,
00087                                           const intern_type*  from_end,
00088                                           const intern_type*& from_next,
00089                                           extern_type*        to,
00090                                           extern_type*        to_limit,
00091                                           extern_type*&       to_next) const {
00092   ptrdiff_t len = (min) (from_end - from, to_limit - to);
00093   copy(from, from + len, to);
00094   from_next = from + len;
00095   to_next   = to   + len;
00096   return ok;
00097 }
00098 
00099 codecvt<wchar_t, char, mbstate_t>::result
00100 codecvt<wchar_t, char, mbstate_t>::do_in (state_type&       /* state */,
00101                                           const extern_type*  from,
00102                                           const extern_type*  from_end,
00103                                           const extern_type*& from_next,
00104                                           intern_type*        to,
00105                                           intern_type*        to_limit,
00106                                           intern_type*&       to_next) const {
00107   ptrdiff_t len = (min) (from_end - from, to_limit - to);
00108   copy(__REINTERPRET_CAST(const unsigned char*, from),
00109        __REINTERPRET_CAST(const unsigned char*, from) + len, to);
00110   from_next = from + len;
00111   to_next   = to   + len;
00112   return ok;
00113 }
00114 
00115 codecvt<wchar_t, char, mbstate_t>::result
00116 codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type&   /* state */,
00117                                               extern_type*  to,
00118                                               extern_type*  ,
00119                                               extern_type*& to_next) const {
00120   to_next = to;
00121   return noconv;
00122 }
00123 
00124 int codecvt<wchar_t, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
00125 { return 1; }
00126 
00127 bool codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
00128 { return true; }
00129 
00130 int codecvt<wchar_t, char, mbstate_t>::do_length(const  state_type&,
00131                                                  const  extern_type* from,
00132                                                  const  extern_type* end,
00133                                                  size_t mx) const
00134 { return (int)(min) ((size_t) (end - from), mx); }
00135 
00136 int codecvt<wchar_t, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
00137 { return 1; }
00138 #endif /* wchar_t */
00139 
00140 _STLP_END_NAMESPACE
00141 
00142 #endif /* _STLP_NO_MBSTATE_T */
00143 
00144 // Local Variables:
00145 // mode:C++
00146 // End:
00147 



Generated on Mon Mar 10 15:32:16 2008 by  doxygen 1.5.1