Exemplo n.º 1
0
    int CompareNocase(const CTempXStr<_TChar>& pattern) const
    {
#if defined(NCBI_COMPILER_GCC) && (NCBI_COMPILER_VERSION <= 295)
#  define CT_TOLOWER(x) tolower((unsigned)(x))
#else
        const ctype<_TChar>& ct =

#if defined(NCBI_COMPILER_WORKSHOP)
//#if !defined(_RWSTD_NOTEMPLATE_ON_RETURN_TYPE)
// Old style; on newer compilers this is deprecated
            use_facet( locale(), (ctype<_TChar>*)0);
#else
            use_facet< ctype<_TChar> >(locale());
#endif
#  define CT_TOLOWER(x) ct.tolower(x)
#endif

        size_t n = length();
        if (pattern.length() < n) {
            n = pattern.length();
        }
        const _TChar *s = data();
        const _TChar *p = pattern.data();
        size_t c = 0;
        for ( ; n-- && (CT_TOLOWER( *s ) == CT_TOLOWER( *p )); ++s,++p,++c )
            ;
        _TChar se = CT_TOLOWER( operator[](c) );
        _TChar pe = CT_TOLOWER( pattern[c] );
        if ( se == pe) {
            return 0;
        }
        return se < pe ? -1 : 1;
#undef CT_TOLOWER
    }
Exemplo n.º 2
0
basic_istream<_CharT, _Traits>& _STLP_CALL 
operator>>(basic_istream<_CharT, _Traits>& __is,
           basic_string<_CharT,_Traits, _Alloc>& __s)
{
  _STLP_USING_IO
  typedef basic_istream<_CharT, _Traits> __istream;
  typename __istream::sentry __sentry(__is);

  if (__sentry) {
    basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf();
    typedef ctype<_CharT> _C_type;

#ifdef _STLP_OWN_IOSTREAMS
    //    const _C_type& _Ctype = use_facet<_C_type>(__loc);
    const _C_type& _Ctype = *(const _C_type*)__is._M_ctype_facet();
#else
# if defined (_STLP_MSVC) && (_STLP_MSVC <= 1200 ) || defined (__ICL)
    const locale& __loc = __is.getloc();
    const _C_type& _Ctype = use_facet(__loc , ( _C_type * ) 0, true);
# elif defined (__SUNPRO_CC)
    const locale& __loc = __is.getloc();
    const _C_type& _Ctype = use_facet(__loc , ( _C_type * ) 0);
# else
    const locale& __loc = __is.getloc();
    const _C_type& _Ctype = use_facet<_C_type>(__loc);
# endif
#endif
    __s.clear();
    size_t __n = __is.width(0);
    if (__n == 0)
      __n = __STATIC_CAST(size_t,-1);
    else
      __s.reserve(__n);
    

    while (__n-- > 0) {
      typename _Traits::int_type __c1 = __buf->sbumpc();
      if (_Traits::eq_int_type(__c1, _Traits::eof())) {
        __is.setstate(__istream::eofbit);
        break;
      }
      else {
        _CharT __c = _Traits::to_char_type(__c1);

        if (_Ctype.is(_C_type::space, __c)) {
          if (_Traits::eq_int_type(__buf->sputbackc(__c), _Traits::eof()))
            __is.setstate(__istream::failbit);
          break;
        }
        else
          __s.push_back(__c);
      }
    }
    
    // If we have read no characters, then set failbit.
    if (__s.size() == 0)
      __is.setstate(__istream::failbit);
  }
  else
    __is.setstate(__istream::failbit);

  return __is;
}