sl@0: /*
sl@0:  * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
sl@0:  *
sl@0:  * Copyright (c) 1999
sl@0:  * Silicon Graphics Computer Systems, Inc.
sl@0:  *
sl@0:  * Copyright (c) 1999
sl@0:  * Boris Fomitchev
sl@0:  *
sl@0:  * This material is provided "as is", with absolutely no warranty expressed
sl@0:  * or implied. Any use is at your own risk.
sl@0:  *
sl@0:  * Permission to use or copy this software for any purpose is hereby granted
sl@0:  * without fee, provided the above notices are retained on all copies.
sl@0:  * Permission to modify the code and to distribute modified code is granted,
sl@0:  * provided the above notices are retained, and a notice that the code was
sl@0:  * modified is included with the above copyright notice.
sl@0:  *
sl@0:  */
sl@0: #include "stlport_prefix.h"
sl@0: 
sl@0: #ifndef _STLP_NO_MBSTATE_T
sl@0: 
sl@0: #include <locale>
sl@0: #include <algorithm>
sl@0: 
sl@0: _STLP_BEGIN_NAMESPACE
sl@0: 
sl@0: //----------------------------------------------------------------------
sl@0: // codecvt<char, char, mbstate_t>
sl@0: 
sl@0: _STLP_DECLSPEC codecvt<char, char, mbstate_t>::~codecvt() {}
sl@0: 
sl@0: _STLP_DECLSPEC int codecvt<char, char, mbstate_t>::do_length(const mbstate_t&,
sl@0:                                               const  char* from,
sl@0:                                               const  char* end,
sl@0:                                               size_t mx) const
sl@0: { return (int)(min) ( __STATIC_CAST(size_t, (end - from)), mx); }
sl@0: 
sl@0: _STLP_DECLSPEC int codecvt<char, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
sl@0: { return 1; }
sl@0: 
sl@0: _STLP_DECLSPEC bool
sl@0: codecvt<char, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
sl@0: { return true; }
sl@0: 
sl@0: _STLP_DECLSPEC int
sl@0: codecvt<char, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
sl@0: { return 1; }
sl@0: 
sl@0: _STLP_DECLSPEC codecvt_base::result
sl@0: codecvt<char, char, mbstate_t>::do_unshift(mbstate_t& /* __state */,
sl@0:                                            char*      __to,
sl@0:                                            char*      /* __to_limit */,
sl@0:                                            char*&     __to_next) const
sl@0: { __to_next = __to; return noconv; }
sl@0: 
sl@0: _STLP_DECLSPEC codecvt_base::result
sl@0: codecvt<char, char, mbstate_t>::do_in (mbstate_t&   /* __state */ ,
sl@0:                                        const char*  __from,
sl@0:                                        const char*  /* __from_end */,
sl@0:                                        const char*& __from_next,
sl@0:                                        char*        __to,
sl@0:                                        char*        /* __to_end */,
sl@0:                                        char*&       __to_next) const
sl@0: { __from_next = __from; __to_next   = __to; return noconv; }
sl@0: 
sl@0: _STLP_DECLSPEC codecvt_base::result
sl@0: codecvt<char, char, mbstate_t>::do_out(mbstate_t&   /* __state */,
sl@0:                                        const char*  __from,
sl@0:                                        const char*  /* __from_end */,
sl@0:                                        const char*& __from_next,
sl@0:                                        char*        __to,
sl@0:                                        char*        /* __to_limit */,
sl@0:                                        char*&       __to_next) const
sl@0: { __from_next = __from; __to_next   = __to; return noconv; }
sl@0: 
sl@0: 
sl@0: #if !defined (_STLP_NO_WCHAR_T)
sl@0: //----------------------------------------------------------------------
sl@0: // codecvt<wchar_t, char, mbstate_t>
sl@0: 
sl@0: _STLP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::~codecvt() {}
sl@0: 
sl@0: 
sl@0: _STLP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::result
sl@0: codecvt<wchar_t, char, mbstate_t>::do_out(state_type&         /* state */,
sl@0:                                           const intern_type*  from,
sl@0:                                           const intern_type*  from_end,
sl@0:                                           const intern_type*& from_next,
sl@0:                                           extern_type*        to,
sl@0:                                           extern_type*        to_limit,
sl@0:                                           extern_type*&       to_next) const {
sl@0:   ptrdiff_t len = (min) (from_end - from, to_limit - to);
sl@0:   copy(from, from + len, to);
sl@0:   from_next = from + len;
sl@0:   to_next   = to   + len;
sl@0:   return ok;
sl@0: }
sl@0: 
sl@0: _STLP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::result
sl@0: codecvt<wchar_t, char, mbstate_t>::do_in (state_type&       /* state */,
sl@0:                                           const extern_type*  from,
sl@0:                                           const extern_type*  from_end,
sl@0:                                           const extern_type*& from_next,
sl@0:                                           intern_type*        to,
sl@0:                                           intern_type*        to_limit,
sl@0:                                           intern_type*&       to_next) const {
sl@0:   ptrdiff_t len = (min) (from_end - from, to_limit - to);
sl@0:   copy(__REINTERPRET_CAST(const unsigned char*, from),
sl@0:        __REINTERPRET_CAST(const unsigned char*, from) + len, to);
sl@0:   from_next = from + len;
sl@0:   to_next   = to   + len;
sl@0:   return ok;
sl@0: }
sl@0: 
sl@0: _STLP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::result
sl@0: codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type&   /* state */,
sl@0:                                               extern_type*  to,
sl@0:                                               extern_type*  ,
sl@0:                                               extern_type*& to_next) const {
sl@0:   to_next = to;
sl@0:   return noconv;
sl@0: }
sl@0: 
sl@0: _STLP_DECLSPEC int codecvt<wchar_t, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
sl@0: #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
sl@0: {
sl@0: 	int __ret = 0;
sl@0:     if (MB_CUR_MAX == 1)
sl@0:       __ret = 1;
sl@0:     return __ret;
sl@0:  }
sl@0: #else
sl@0: { return 1; }
sl@0: #endif
sl@0: 
sl@0: _STLP_DECLSPEC bool codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
sl@0: { return true; }
sl@0: 
sl@0: _STLP_DECLSPEC int codecvt<wchar_t, char, mbstate_t>::do_length(const  state_type&,
sl@0:                                                  const  extern_type* from,
sl@0:                                                  const  extern_type* end,
sl@0:                                                  size_t mx) const
sl@0: { return (int)(min) ((size_t) (end - from), mx); }
sl@0: 
sl@0: _STLP_DECLSPEC int codecvt<wchar_t, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
sl@0: { return 1; }
sl@0: #endif /* wchar_t */
sl@0: 
sl@0: _STLP_END_NAMESPACE
sl@0: 
sl@0: #endif /* _STLP_NO_MBSTATE_T */
sl@0: 
sl@0: // Local Variables:
sl@0: // mode:C++
sl@0: // End:
sl@0: