windows-nt/Source/XPSP1/NT/base/crts/crtw32/stdhpp/string
2020-09-26 16:20:57 +08:00

745 lines
25 KiB
Plaintext

// string standard header
#pragma once
#ifndef _STRING_
#define _STRING_
#include <istream>
#pragma pack(push,8)
#pragma warning(push,3)
#pragma warning(disable: 4189)
_STD_BEGIN
// basic_string TEMPLATE OPERATORS
template<class _Elem,
class _Traits,
class _Alloc> inline
basic_string<_Elem, _Traits, _Alloc> __cdecl operator+(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
{ // return string + string
return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
basic_string<_Elem, _Traits, _Alloc> __cdecl operator+(
const _Elem *_Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
{ // return NTCS + string
return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
basic_string<_Elem, _Traits, _Alloc> __cdecl operator+(
const _Elem _Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
{ // return character + string
return (basic_string<_Elem, _Traits, _Alloc>(1, _Left) += _Right);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
basic_string<_Elem, _Traits, _Alloc> __cdecl operator+(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const _Elem *_Right)
{ // return string + NTCS
return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
basic_string<_Elem, _Traits, _Alloc> __cdecl operator+(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const _Elem _Right)
{ // return string + character
return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator==(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
{ // test for string equality
return (_Left.compare(_Right) == 0);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator==(
const _Elem * _Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
{ // test for NTCS vs. string equality
return (_Right.compare(_Left) == 0);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator==(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const _Elem *_Right)
{ // test for string vs. NTCS equality
return (_Left.compare(_Right) == 0);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator!=(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
{ // test for string inequality
return (!(_Left == _Right));
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator!=(
const _Elem *_Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
{ // test for NTCS vs. string inequality
return (!(_Left == _Right));
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator!=(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const _Elem *_Right)
{ // test for string vs. NTCS inequality
return (!(_Left == _Right));
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator<(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
{ // test if string < string
return (_Left.compare(_Right) < 0);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator<(
const _Elem * _Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
{ // test if NTCS < string
return (_Right.compare(_Left) > 0);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator<(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const _Elem *_Right)
{ // test if string < NTCS
return (_Left.compare(_Right) < 0);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator>(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
{ // test if string > string
return (_Right < _Left);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator>(
const _Elem * _Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
{ // test if NTCS > string
return (_Right < _Left);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator>(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const _Elem *_Right)
{ // test if string > NTCS
return (_Right < _Left);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator<=(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
{ // test if string <= string
return (!(_Right < _Left));
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator<=(
const _Elem * _Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
{ // test if NTCS <= string
return (!(_Right < _Left));
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator<=(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const _Elem *_Right)
{ // test if string <= NTCS
return (!(_Right < _Left));
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator>=(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
{ // test if string >= string
return (!(_Left < _Right));
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator>=(
const _Elem * _Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
{ // test if NTCS >= string
return (!(_Left < _Right));
}
template<class _Elem,
class _Traits,
class _Alloc> inline
bool __cdecl operator>=(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const _Elem *_Right)
{ // test if string >= NTCS
return (!(_Left < _Right));
}
#ifdef _DLL_CPPLIB
#ifndef CRTDLL2
template class _CRTIMP2 basic_string<char,
char_traits<char>, allocator<char> > __cdecl operator+(
const basic_string<char, char_traits<char>, allocator<char> >&,
const basic_string<char, char_traits<char>, allocator<char> >&);
template class _CRTIMP2 basic_string<char,
char_traits<char>, allocator<char> > __cdecl operator+(
const char *,
const basic_string<char, char_traits<char>, allocator<char> >&);
template class _CRTIMP2 basic_string<char,
char_traits<char>, allocator<char> > __cdecl operator+(
const char,
const basic_string<char, char_traits<char>, allocator<char> >&);
template class _CRTIMP2 basic_string<char,
char_traits<char>, allocator<char> > __cdecl operator+(
const basic_string<char, char_traits<char>, allocator<char> >&,
const char *);
template class _CRTIMP2 basic_string<char,
char_traits<char>, allocator<char> > __cdecl operator+(
const basic_string<char, char_traits<char>, allocator<char> >&,
const char);
template _CRTIMP2 bool __cdecl operator==(
const basic_string<char, char_traits<char>, allocator<char> >&,
const basic_string<char, char_traits<char>, allocator<char> >&);
template _CRTIMP2 bool __cdecl operator==(
const char *,
const basic_string<char, char_traits<char>, allocator<char> >&);
template _CRTIMP2 bool __cdecl operator==(
const basic_string<char, char_traits<char>, allocator<char> >&,
const char *);
template _CRTIMP2 bool __cdecl operator!=(
const basic_string<char, char_traits<char>, allocator<char> >&,
const basic_string<char, char_traits<char>, allocator<char> >&);
template _CRTIMP2 bool __cdecl operator!=(
const char *,
const basic_string<char, char_traits<char>, allocator<char> >&);
template _CRTIMP2 bool __cdecl operator!=(
const basic_string<char, char_traits<char>, allocator<char> >&,
const char *);
template _CRTIMP2 bool __cdecl operator<(
const basic_string<char, char_traits<char>, allocator<char> >&,
const basic_string<char, char_traits<char>, allocator<char> >&);
template _CRTIMP2 bool __cdecl operator<(
const char *,
const basic_string<char, char_traits<char>, allocator<char> >&);
template _CRTIMP2 bool __cdecl operator<(
const basic_string<char, char_traits<char>, allocator<char> >&,
const char *);
template _CRTIMP2 bool __cdecl operator>(
const basic_string<char, char_traits<char>, allocator<char> >&,
const basic_string<char, char_traits<char>, allocator<char> >&);
template _CRTIMP2 bool __cdecl operator>(
const char *,
const basic_string<char, char_traits<char>, allocator<char> >&);
template _CRTIMP2 bool __cdecl operator>(
const basic_string<char, char_traits<char>, allocator<char> >&,
const char *);
template _CRTIMP2 bool __cdecl operator<=(
const basic_string<char, char_traits<char>, allocator<char> >&,
const basic_string<char, char_traits<char>, allocator<char> >&);
template _CRTIMP2 bool __cdecl operator<=(
const char *,
const basic_string<char, char_traits<char>, allocator<char> >&);
template _CRTIMP2 bool __cdecl operator<=(
const basic_string<char, char_traits<char>, allocator<char> >&,
const char *);
template _CRTIMP2 bool __cdecl operator>=(
const basic_string<char, char_traits<char>, allocator<char> >&,
const basic_string<char, char_traits<char>, allocator<char> >&);
template _CRTIMP2 bool __cdecl operator>=(
const char *,
const basic_string<char, char_traits<char>, allocator<char> >&);
template _CRTIMP2 bool __cdecl operator>=(
const basic_string<char, char_traits<char>, allocator<char> >&,
const char *);
template class _CRTIMP2 basic_string<wchar_t,
char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
const basic_string<wchar_t, char_traits<wchar_t>,
allocator<wchar_t> >&,
const basic_string<wchar_t, char_traits<wchar_t>,
allocator<wchar_t> >&);
template class _CRTIMP2 basic_string<wchar_t,
char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
const wchar_t *,
const basic_string<wchar_t, char_traits<wchar_t>,
allocator<wchar_t> >&);
template class _CRTIMP2 basic_string<wchar_t,
char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
const wchar_t,
const basic_string<wchar_t, char_traits<wchar_t>,
allocator<wchar_t> >&);
template class _CRTIMP2 basic_string<wchar_t,
char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
const basic_string<wchar_t, char_traits<wchar_t>,
allocator<wchar_t> >&,
const wchar_t *);
template class _CRTIMP2 basic_string<wchar_t,
char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
const basic_string<wchar_t, char_traits<wchar_t>,
allocator<wchar_t> >&,
const wchar_t);
template _CRTIMP2 bool __cdecl operator==(
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
template _CRTIMP2 bool __cdecl operator==(
const wchar_t *,
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
template _CRTIMP2 bool __cdecl operator==(
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
const wchar_t *);
template _CRTIMP2 bool __cdecl operator!=(
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
template _CRTIMP2 bool __cdecl operator!=(
const wchar_t *,
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
template _CRTIMP2 bool __cdecl operator!=(
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
const wchar_t *);
template _CRTIMP2 bool __cdecl operator<(
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
template _CRTIMP2 bool __cdecl operator<(
const wchar_t *,
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
template _CRTIMP2 bool __cdecl operator<(
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
const wchar_t *);
template _CRTIMP2 bool __cdecl operator>(
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
template _CRTIMP2 bool __cdecl operator>(
const wchar_t *,
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
template _CRTIMP2 bool __cdecl operator>(
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
const wchar_t *);
template _CRTIMP2 bool __cdecl operator<=(
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
template _CRTIMP2 bool __cdecl operator<=(
const wchar_t *,
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
template _CRTIMP2 bool __cdecl operator<=(
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
const wchar_t *);
template _CRTIMP2 bool __cdecl operator>=(
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
template _CRTIMP2 bool __cdecl operator>=(
const wchar_t *,
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
template _CRTIMP2 bool __cdecl operator>=(
const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
const wchar_t *);
#ifdef _CRTBLD_NATIVE_WCHAR_T
template class _CRTIMP2 basic_string<unsigned short,
char_traits<unsigned short>, allocator<unsigned short> > __cdecl operator+(
const basic_string<unsigned short, char_traits<unsigned short>,
allocator<unsigned short> >&,
const basic_string<unsigned short, char_traits<unsigned short>,
allocator<unsigned short> >&);
template class _CRTIMP2 basic_string<unsigned short,
char_traits<unsigned short>, allocator<unsigned short> > __cdecl operator+(
const unsigned short *,
const basic_string<unsigned short, char_traits<unsigned short>,
allocator<unsigned short> >&);
template class _CRTIMP2 basic_string<unsigned short,
char_traits<unsigned short>, allocator<unsigned short> > __cdecl operator+(
const unsigned short,
const basic_string<unsigned short, char_traits<unsigned short>,
allocator<unsigned short> >&);
template class _CRTIMP2 basic_string<unsigned short,
char_traits<unsigned short>, allocator<unsigned short> > __cdecl operator+(
const basic_string<unsigned short, char_traits<unsigned short>,
allocator<unsigned short> >&,
const unsigned short *);
template class _CRTIMP2 basic_string<unsigned short,
char_traits<unsigned short>, allocator<unsigned short> > __cdecl operator+(
const basic_string<unsigned short, char_traits<unsigned short>,
allocator<unsigned short> >&,
const unsigned short);
template _CRTIMP2 bool __cdecl operator==(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template _CRTIMP2 bool __cdecl operator==(
const unsigned short *,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template _CRTIMP2 bool __cdecl operator==(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const unsigned short *);
template _CRTIMP2 bool __cdecl operator!=(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template _CRTIMP2 bool __cdecl operator!=(
const unsigned short *,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template _CRTIMP2 bool __cdecl operator!=(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const unsigned short *);
template _CRTIMP2 bool __cdecl operator<(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template _CRTIMP2 bool __cdecl operator<(
const unsigned short *,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template _CRTIMP2 bool __cdecl operator<(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const unsigned short *);
template _CRTIMP2 bool __cdecl operator>(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template _CRTIMP2 bool __cdecl operator>(
const unsigned short *,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template _CRTIMP2 bool __cdecl operator>(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const unsigned short *);
template _CRTIMP2 bool __cdecl operator<=(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template _CRTIMP2 bool __cdecl operator<=(
const unsigned short *,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template _CRTIMP2 bool __cdecl operator<=(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const unsigned short *);
template _CRTIMP2 bool __cdecl operator>=(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template _CRTIMP2 bool __cdecl operator>=(
const unsigned short *,
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template _CRTIMP2 bool __cdecl operator>=(
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const unsigned short *);
#endif
#endif // CRTDLL2
#endif // _DLL_CPPLIB
// basic_string INSERTERS AND EXTRACTORS
template<class _Elem,
class _Traits,
class _Alloc> inline
basic_istream<_Elem, _Traits>& __cdecl operator>>(
basic_istream<_Elem, _Traits>& _Istr,
basic_string<_Elem, _Traits, _Alloc>& _Str)
{ // extract a string
typedef ctype<_Elem> _Ctype;
typedef basic_istream<_Elem, _Traits> _Myis;
typedef basic_string<_Elem, _Traits, _Alloc> _Mystr;
typedef typename _Mystr::size_type _Mysizt;
ios_base::iostate _State = ios_base::goodbit;
bool _Changed = false;
const typename _Myis::sentry _Ok(_Istr);
if (_Ok)
{ // state okay, extract characters
const _Ctype& _Fac = _USE(_Istr.getloc(), _Ctype);
_Str.erase();
_TRY_IO_BEGIN
_Mysizt _Size = 0 < _Istr.width()
&& (_Mysizt)_Istr.width() < _Str.max_size()
? (_Mysizt)_Istr.width() : _Str.max_size();
typename _Traits::int_type _Meta = _Istr.rdbuf()->sgetc();
for (; 0 < _Size; --_Size, _Meta = _Istr.rdbuf()->snextc())
if(_Traits::eq_int_type(_Traits::eof(), _Meta))
{ // end of file, quit
_State |= ios_base::eofbit;
break;
}
else if (_Fac.is(_Ctype::space, _Traits::to_char_type(_Meta)))
break; // whitespace, quit
else
{ // add character to string
_Str.append(1, _Traits::to_char_type(_Meta));
_Changed = true;
}
_CATCH_IO_(_Istr)
}
_Istr.width(0);
if (!_Changed)
_State |= ios_base::failbit;
_Istr.setstate(_State);
return (_Istr);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
basic_istream<_Elem, _Traits>& __cdecl getline(
basic_istream<_Elem, _Traits>& _Istr,
basic_string<_Elem, _Traits, _Alloc>& _Str)
{ // get characters into string, discard newline
return (getline(_Istr, _Str, _Istr.widen('\n')));
}
template<class _Elem,
class _Traits,
class _Alloc> inline
basic_istream<_Elem, _Traits>& __cdecl getline(
basic_istream<_Elem, _Traits>& _Istr,
basic_string<_Elem, _Traits, _Alloc>& _Str, const _Elem _Delim)
{ // get characters into string, discard delimiter
typedef basic_istream<_Elem, _Traits> _Myis;
ios_base::iostate _State = ios_base::goodbit;
bool _Changed = false;
const typename _Myis::sentry _Ok(_Istr, true);
if (_Ok)
{ // state okay, extract characters
_TRY_IO_BEGIN
_Str.erase();
const typename _Traits::int_type _Metadelim =
_Traits::to_int_type(_Delim);
typename _Traits::int_type _Meta = _Istr.rdbuf()->sgetc();
for (; ; _Meta = _Istr.rdbuf()->snextc())
if (_Traits::eq_int_type(_Traits::eof(), _Meta))
{ // end of file, quit
_State |= ios_base::eofbit;
break;
}
else if (_Traits::eq_int_type(_Meta, _Metadelim))
{ // got a delimiter, discard it and quit
_Changed = true;
_Istr.rdbuf()->sbumpc();
break;
}
else if (_Str.max_size() <= _Str.size())
{ // string too large, quit
_State |= ios_base::failbit;
break;
}
else
{ // got a character, add it to string
_Str += _Traits::to_char_type(_Meta);
_Changed = true;
}
_CATCH_IO_(_Istr)
}
if (!_Changed)
_State |= ios_base::failbit;
_Istr.setstate(_State);
return (_Istr);
}
template<class _Elem,
class _Traits,
class _Alloc> inline
basic_ostream<_Elem, _Traits>& __cdecl operator<<(
basic_ostream<_Elem, _Traits>& _Ostr,
const basic_string<_Elem, _Traits, _Alloc>& _Str)
{ // insert a string
typedef basic_ostream<_Elem, _Traits> _Myos;
typedef basic_string<_Elem, _Traits, _Alloc> _Mystr;
typedef typename _Mystr::size_type _Mysizt;
ios_base::iostate _State = ios_base::goodbit;
_Mysizt _Size = _Str.size();
_Mysizt _Pad = _Ostr.width() <= 0 || (_Mysizt)_Ostr.width() <= _Size
? 0 : (_Mysizt)_Ostr.width() - _Size;
const typename _Myos::sentry _Ok(_Ostr);
if (!_Ok)
_State |= ios_base::badbit;
else
{ // state okay, insert characters
_TRY_IO_BEGIN
if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left)
for (; 0 < _Pad; --_Pad) // pad on left
if (_Traits::eq_int_type(_Traits::eof(),
_Ostr.rdbuf()->sputc(_Ostr.fill())))
{ // insertion failed, quit
_State |= ios_base::badbit;
break;
}
if (_State == ios_base::goodbit)
for (_Mysizt _Count = 0; _Count < _Size; ++_Count)
if (_Traits::eq_int_type(_Traits::eof(),
_Ostr.rdbuf()->sputc(_Str[_Count])))
{ // insertion failed, quit
_State |= ios_base::badbit;
break;
}
if (_State == ios_base::goodbit)
for (; 0 < _Pad; --_Pad) // pad on right
if (_Traits::eq_int_type(_Traits::eof(),
_Ostr.rdbuf()->sputc(_Ostr.fill())))
{ // insertion failed, quit
_State |= ios_base::badbit;
break;
}
_Ostr.width(0);
_CATCH_IO_(_Ostr)
}
_Ostr.setstate(_State);
return (_Ostr);
}
#ifdef _DLL_CPPLIB
#ifndef CRTDLL2
template class _CRTIMP2 basic_istream<char,
char_traits<char> >& __cdecl operator>>(
basic_istream<char, char_traits<char> >&,
basic_string<char, char_traits<char>, allocator<char> >&);
template class _CRTIMP2 basic_istream<char,
char_traits<char> >& __cdecl getline(
basic_istream<char, char_traits<char> >&,
basic_string<char, char_traits<char>, allocator<char> >&);
template class _CRTIMP2 basic_istream<char,
char_traits<char> >& __cdecl getline(
basic_istream<char, char_traits<char> >&,
basic_string<char, char_traits<char>, allocator<char> >&,
const char);
template class _CRTIMP2 basic_ostream<char,
char_traits<char> >& __cdecl operator<<(
basic_ostream<char, char_traits<char> >&,
const basic_string<char, char_traits<char>, allocator<char> >&);
template class _CRTIMP2 basic_istream<wchar_t,
char_traits<wchar_t> >& __cdecl operator>>(
basic_istream<wchar_t, char_traits<wchar_t> >&,
basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
template class _CRTIMP2 basic_istream<wchar_t,
char_traits<wchar_t> >& __cdecl getline(
basic_istream<wchar_t, char_traits<wchar_t> >&,
basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
template class _CRTIMP2 basic_istream<wchar_t,
char_traits<wchar_t> >& __cdecl getline(
basic_istream<wchar_t, char_traits<wchar_t> >&,
basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
const wchar_t);
template class _CRTIMP2 basic_ostream<wchar_t,
char_traits<wchar_t> >& __cdecl operator<<(
basic_ostream<wchar_t, char_traits<wchar_t> >&,
const basic_string<wchar_t, char_traits<wchar_t>,
allocator<wchar_t> >&);
#ifdef _CRTBLD_NATIVE_WCHAR_T
template class _CRTIMP2 basic_istream<unsigned short,
char_traits<unsigned short> >& __cdecl operator>>(
basic_istream<unsigned short, char_traits<unsigned short> >&,
basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template class _CRTIMP2 basic_istream<unsigned short,
char_traits<unsigned short> >& __cdecl getline(
basic_istream<unsigned short, char_traits<unsigned short> >&,
basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
template class _CRTIMP2 basic_istream<unsigned short,
char_traits<unsigned short> >& __cdecl getline(
basic_istream<unsigned short, char_traits<unsigned short> >&,
basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
const unsigned short);
template class _CRTIMP2 basic_ostream<unsigned short,
char_traits<unsigned short> >& __cdecl operator<<(
basic_ostream<unsigned short, char_traits<unsigned short> >&,
const basic_string<unsigned short, char_traits<unsigned short>,
allocator<unsigned short> >&);
#endif
#endif // CRTDLL2
#endif // _DLL_CPPLIB
_STD_END
#pragma warning(default: 4189)
#pragma warning(pop)
#pragma pack(pop)
#endif /* _STRING */
/*
* Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
V3.10:0009 */