home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / src / codecvt.cpp < prev    next >
C/C++ Source or Header  |  2001-01-26  |  6KB  |  166 lines

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