os/ossrv/genericopenlibs/cppstdlib/stl/src/codecvt.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
 * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
sl@0
     3
 *
sl@0
     4
 * Copyright (c) 1999
sl@0
     5
 * Silicon Graphics Computer Systems, Inc.
sl@0
     6
 *
sl@0
     7
 * Copyright (c) 1999
sl@0
     8
 * Boris Fomitchev
sl@0
     9
 *
sl@0
    10
 * This material is provided "as is", with absolutely no warranty expressed
sl@0
    11
 * or implied. Any use is at your own risk.
sl@0
    12
 *
sl@0
    13
 * Permission to use or copy this software for any purpose is hereby granted
sl@0
    14
 * without fee, provided the above notices are retained on all copies.
sl@0
    15
 * Permission to modify the code and to distribute modified code is granted,
sl@0
    16
 * provided the above notices are retained, and a notice that the code was
sl@0
    17
 * modified is included with the above copyright notice.
sl@0
    18
 *
sl@0
    19
 */
sl@0
    20
#include "stlport_prefix.h"
sl@0
    21
sl@0
    22
#ifndef _STLP_NO_MBSTATE_T
sl@0
    23
sl@0
    24
#include <locale>
sl@0
    25
#include <algorithm>
sl@0
    26
sl@0
    27
_STLP_BEGIN_NAMESPACE
sl@0
    28
sl@0
    29
//----------------------------------------------------------------------
sl@0
    30
// codecvt<char, char, mbstate_t>
sl@0
    31
sl@0
    32
_STLP_DECLSPEC codecvt<char, char, mbstate_t>::~codecvt() {}
sl@0
    33
sl@0
    34
_STLP_DECLSPEC int codecvt<char, char, mbstate_t>::do_length(const mbstate_t&,
sl@0
    35
                                              const  char* from,
sl@0
    36
                                              const  char* end,
sl@0
    37
                                              size_t mx) const
sl@0
    38
{ return (int)(min) ( __STATIC_CAST(size_t, (end - from)), mx); }
sl@0
    39
sl@0
    40
_STLP_DECLSPEC int codecvt<char, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
sl@0
    41
{ return 1; }
sl@0
    42
sl@0
    43
_STLP_DECLSPEC bool
sl@0
    44
codecvt<char, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
sl@0
    45
{ return true; }
sl@0
    46
sl@0
    47
_STLP_DECLSPEC int
sl@0
    48
codecvt<char, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
sl@0
    49
{ return 1; }
sl@0
    50
sl@0
    51
_STLP_DECLSPEC codecvt_base::result
sl@0
    52
codecvt<char, char, mbstate_t>::do_unshift(mbstate_t& /* __state */,
sl@0
    53
                                           char*      __to,
sl@0
    54
                                           char*      /* __to_limit */,
sl@0
    55
                                           char*&     __to_next) const
sl@0
    56
{ __to_next = __to; return noconv; }
sl@0
    57
sl@0
    58
_STLP_DECLSPEC codecvt_base::result
sl@0
    59
codecvt<char, char, mbstate_t>::do_in (mbstate_t&   /* __state */ ,
sl@0
    60
                                       const char*  __from,
sl@0
    61
                                       const char*  /* __from_end */,
sl@0
    62
                                       const char*& __from_next,
sl@0
    63
                                       char*        __to,
sl@0
    64
                                       char*        /* __to_end */,
sl@0
    65
                                       char*&       __to_next) const
sl@0
    66
{ __from_next = __from; __to_next   = __to; return noconv; }
sl@0
    67
sl@0
    68
_STLP_DECLSPEC codecvt_base::result
sl@0
    69
codecvt<char, char, mbstate_t>::do_out(mbstate_t&   /* __state */,
sl@0
    70
                                       const char*  __from,
sl@0
    71
                                       const char*  /* __from_end */,
sl@0
    72
                                       const char*& __from_next,
sl@0
    73
                                       char*        __to,
sl@0
    74
                                       char*        /* __to_limit */,
sl@0
    75
                                       char*&       __to_next) const
sl@0
    76
{ __from_next = __from; __to_next   = __to; return noconv; }
sl@0
    77
sl@0
    78
sl@0
    79
#if !defined (_STLP_NO_WCHAR_T)
sl@0
    80
//----------------------------------------------------------------------
sl@0
    81
// codecvt<wchar_t, char, mbstate_t>
sl@0
    82
sl@0
    83
_STLP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::~codecvt() {}
sl@0
    84
sl@0
    85
sl@0
    86
_STLP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::result
sl@0
    87
codecvt<wchar_t, char, mbstate_t>::do_out(state_type&         /* state */,
sl@0
    88
                                          const intern_type*  from,
sl@0
    89
                                          const intern_type*  from_end,
sl@0
    90
                                          const intern_type*& from_next,
sl@0
    91
                                          extern_type*        to,
sl@0
    92
                                          extern_type*        to_limit,
sl@0
    93
                                          extern_type*&       to_next) const {
sl@0
    94
  ptrdiff_t len = (min) (from_end - from, to_limit - to);
sl@0
    95
  copy(from, from + len, to);
sl@0
    96
  from_next = from + len;
sl@0
    97
  to_next   = to   + len;
sl@0
    98
  return ok;
sl@0
    99
}
sl@0
   100
sl@0
   101
_STLP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::result
sl@0
   102
codecvt<wchar_t, char, mbstate_t>::do_in (state_type&       /* state */,
sl@0
   103
                                          const extern_type*  from,
sl@0
   104
                                          const extern_type*  from_end,
sl@0
   105
                                          const extern_type*& from_next,
sl@0
   106
                                          intern_type*        to,
sl@0
   107
                                          intern_type*        to_limit,
sl@0
   108
                                          intern_type*&       to_next) const {
sl@0
   109
  ptrdiff_t len = (min) (from_end - from, to_limit - to);
sl@0
   110
  copy(__REINTERPRET_CAST(const unsigned char*, from),
sl@0
   111
       __REINTERPRET_CAST(const unsigned char*, from) + len, to);
sl@0
   112
  from_next = from + len;
sl@0
   113
  to_next   = to   + len;
sl@0
   114
  return ok;
sl@0
   115
}
sl@0
   116
sl@0
   117
_STLP_DECLSPEC codecvt<wchar_t, char, mbstate_t>::result
sl@0
   118
codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type&   /* state */,
sl@0
   119
                                              extern_type*  to,
sl@0
   120
                                              extern_type*  ,
sl@0
   121
                                              extern_type*& to_next) const {
sl@0
   122
  to_next = to;
sl@0
   123
  return noconv;
sl@0
   124
}
sl@0
   125
sl@0
   126
_STLP_DECLSPEC int codecvt<wchar_t, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
sl@0
   127
#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
sl@0
   128
{
sl@0
   129
	int __ret = 0;
sl@0
   130
    if (MB_CUR_MAX == 1)
sl@0
   131
      __ret = 1;
sl@0
   132
    return __ret;
sl@0
   133
 }
sl@0
   134
#else
sl@0
   135
{ return 1; }
sl@0
   136
#endif
sl@0
   137
sl@0
   138
_STLP_DECLSPEC bool codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
sl@0
   139
{ return true; }
sl@0
   140
sl@0
   141
_STLP_DECLSPEC int codecvt<wchar_t, char, mbstate_t>::do_length(const  state_type&,
sl@0
   142
                                                 const  extern_type* from,
sl@0
   143
                                                 const  extern_type* end,
sl@0
   144
                                                 size_t mx) const
sl@0
   145
{ return (int)(min) ((size_t) (end - from), mx); }
sl@0
   146
sl@0
   147
_STLP_DECLSPEC int codecvt<wchar_t, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
sl@0
   148
{ return 1; }
sl@0
   149
#endif /* wchar_t */
sl@0
   150
sl@0
   151
_STLP_END_NAMESPACE
sl@0
   152
sl@0
   153
#endif /* _STLP_NO_MBSTATE_T */
sl@0
   154
sl@0
   155
// Local Variables:
sl@0
   156
// mode:C++
sl@0
   157
// End:
sl@0
   158