Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

350 lines
17 KiB

  1. // string standard header
  2. #ifndef _STRING_
  3. #define _STRING_
  4. #include <istream>
  5. #ifdef _MSC_VER
  6. #pragma pack(push,8)
  7. #endif /* _MSC_VER */
  8. _STD_BEGIN
  9. // basic_string TEMPLATE OPERATORS
  10. template<class _E, class _Tr, class _A> inline
  11. basic_string<_E, _Tr, _A> __cdecl operator+(
  12. const basic_string<_E, _Tr, _A>& _L,
  13. const basic_string<_E, _Tr, _A>& _R)
  14. {return (basic_string<_E, _Tr, _A>(_L) += _R); }
  15. template<class _E, class _Tr, class _A> inline
  16. basic_string<_E, _Tr, _A> __cdecl operator+(const _E *_L,
  17. const basic_string<_E, _Tr, _A>& _R)
  18. {return (basic_string<_E, _Tr, _A>(_L) += _R); }
  19. template<class _E, class _Tr, class _A> inline
  20. basic_string<_E, _Tr, _A> __cdecl operator+(
  21. const _E _L, const basic_string<_E, _Tr, _A>& _R)
  22. {return (basic_string<_E, _Tr, _A>(1, _L) += _R); }
  23. template<class _E, class _Tr, class _A> inline
  24. basic_string<_E, _Tr, _A> __cdecl operator+(
  25. const basic_string<_E, _Tr, _A>& _L,
  26. const _E *_R)
  27. {return (basic_string<_E, _Tr, _A>(_L) += _R); }
  28. template<class _E, class _Tr, class _A> inline
  29. basic_string<_E, _Tr, _A> __cdecl operator+(
  30. const basic_string<_E, _Tr, _A>& _L, const _E _R)
  31. {return (basic_string<_E, _Tr, _A>(_L) += _R); }
  32. template<class _E, class _Tr, class _A> inline
  33. bool __cdecl operator==(const basic_string<_E, _Tr, _A>& _L,
  34. const basic_string<_E, _Tr, _A>& _R)
  35. {return (_L.compare(_R) == 0); }
  36. template<class _E, class _Tr, class _A> inline
  37. bool __cdecl operator==(const _E * _L,
  38. const basic_string<_E, _Tr, _A>& _R)
  39. {return (_R.compare(_L) == 0); }
  40. template<class _E, class _Tr, class _A> inline
  41. bool __cdecl operator==(const basic_string<_E, _Tr, _A>& _L,
  42. const _E *_R)
  43. {return (_L.compare(_R) == 0); }
  44. template<class _E, class _Tr, class _A> inline
  45. bool __cdecl operator!=(const basic_string<_E, _Tr, _A>& _L,
  46. const basic_string<_E, _Tr, _A>& _R)
  47. {return (!(_L == _R)); }
  48. template<class _E, class _Tr, class _A> inline
  49. bool __cdecl operator!=(const _E *_L,
  50. const basic_string<_E, _Tr, _A>& _R)
  51. {return (!(_L == _R)); }
  52. template<class _E, class _Tr, class _A> inline
  53. bool __cdecl operator!=(const basic_string<_E, _Tr, _A>& _L,
  54. const _E *_R)
  55. {return (!(_L == _R)); }
  56. template<class _E, class _Tr, class _A> inline
  57. bool __cdecl operator<(const basic_string<_E, _Tr, _A>& _L,
  58. const basic_string<_E, _Tr, _A>& _R)
  59. {return (_L.compare(_R) < 0); }
  60. template<class _E, class _Tr, class _A> inline
  61. bool __cdecl operator<(const _E * _L,
  62. const basic_string<_E, _Tr, _A>& _R)
  63. {return (_R.compare(_L) > 0); }
  64. template<class _E, class _Tr, class _A> inline
  65. bool __cdecl operator<(const basic_string<_E, _Tr, _A>& _L,
  66. const _E *_R)
  67. {return (_L.compare(_R) < 0); }
  68. template<class _E, class _Tr, class _A> inline
  69. bool __cdecl operator>(const basic_string<_E, _Tr, _A>& _L,
  70. const basic_string<_E, _Tr, _A>& _R)
  71. {return (_R < _L); }
  72. template<class _E, class _Tr, class _A> inline
  73. bool __cdecl operator>(const _E * _L,
  74. const basic_string<_E, _Tr, _A>& _R)
  75. {return (_R < _L); }
  76. template<class _E, class _Tr, class _A> inline
  77. bool __cdecl operator>(const basic_string<_E, _Tr, _A>& _L,
  78. const _E *_R)
  79. {return (_R < _L); }
  80. template<class _E, class _Tr, class _A> inline
  81. bool __cdecl operator<=(const basic_string<_E, _Tr, _A>& _L,
  82. const basic_string<_E, _Tr, _A>& _R)
  83. {return (!(_R < _L)); }
  84. template<class _E, class _Tr, class _A> inline
  85. bool __cdecl operator<=(const _E * _L,
  86. const basic_string<_E, _Tr, _A>& _R)
  87. {return (!(_R < _L)); }
  88. template<class _E, class _Tr, class _A> inline
  89. bool __cdecl operator<=(const basic_string<_E, _Tr, _A>& _L,
  90. const _E *_R)
  91. {return (!(_R < _L)); }
  92. template<class _E, class _Tr, class _A> inline
  93. bool __cdecl operator>=(const basic_string<_E, _Tr, _A>& _L,
  94. const basic_string<_E, _Tr, _A>& _R)
  95. {return (!(_L < _R)); }
  96. template<class _E, class _Tr, class _A> inline
  97. bool __cdecl operator>=(const _E * _L,
  98. const basic_string<_E, _Tr, _A>& _R)
  99. {return (!(_L < _R)); }
  100. template<class _E, class _Tr, class _A> inline
  101. bool __cdecl operator>=(const basic_string<_E, _Tr, _A>& _L,
  102. const _E *_R)
  103. {return (!(_L < _R)); }
  104. // basic_string INSERTERS AND EXTRACTORS
  105. template<class _E, class _Tr, class _A> inline
  106. basic_istream<_E, _Tr>& __cdecl operator>>(
  107. basic_istream<_E, _Tr>& _I,
  108. basic_string<_E, _Tr, _A>& _X)
  109. {typedef ctype<_E> _Ctype;
  110. typedef basic_istream<_E, _Tr> _Myis;
  111. ios_base::iostate _St = ios_base::goodbit;
  112. bool _Chg = false;
  113. _X.erase();
  114. const _Myis::sentry _Ok(_I);
  115. if (_Ok)
  116. {const _Ctype& _Fac = _USE(_I.getloc(), _Ctype);
  117. _TRY_IO_BEGIN
  118. _A::size_type _N = 0 < _I.width()
  119. && _I.width() < _X.max_size()
  120. ? _I.width() : _X.max_size();
  121. _Tr::int_type _C = _I.rdbuf()->sgetc();
  122. for (; 0 < --_N; _C = _I.rdbuf()->snextc())
  123. if(_Tr::eq_int_type(_Tr::eof(), _C))
  124. {_St |= ios_base::eofbit;
  125. break; }
  126. else if (_Fac.is(_Ctype::space,
  127. _Tr::to_char_type(_C)))
  128. break;
  129. else
  130. {_X.append(1, _Tr::to_char_type(_C));
  131. _Chg = true; }
  132. _CATCH_IO_(_I); }
  133. _I.width(0);
  134. if (!_Chg)
  135. _St |= ios_base::failbit;
  136. _I.setstate(_St);
  137. return (_I); }
  138. template<class _E, class _Tr, class _A> inline
  139. basic_istream<_E, _Tr>& __cdecl getline(basic_istream<_E, _Tr>& _I,
  140. basic_string<_E, _Tr, _A>& _X)
  141. {return (getline(_I, _X, _I.widen('\n'))); }
  142. template<class _E, class _Tr, class _A> inline
  143. basic_istream<_E, _Tr>& __cdecl getline(basic_istream<_E, _Tr>& _I,
  144. basic_string<_E, _Tr, _A>& _X, const _E _D)
  145. {typedef basic_istream<_E, _Tr> _Myis;
  146. ios_base::iostate _St = ios_base::goodbit;
  147. bool _Chg = false;
  148. _X.erase();
  149. const _Myis::sentry _Ok(_I, true);
  150. if (_Ok)
  151. {_TRY_IO_BEGIN
  152. _Tr::int_type _C = _I.rdbuf()->sgetc();
  153. for (; ; _C = _I.rdbuf()->snextc())
  154. if (_Tr::eq_int_type(_Tr::eof(), _C))
  155. {_St |= ios_base::eofbit;
  156. break; }
  157. else if (_Tr::eq((_E)_C, _D))
  158. {_Chg = true;
  159. _I.rdbuf()->snextc();
  160. break; }
  161. else if (_X.max_size() <= _X.size())
  162. {_St |= ios_base::failbit;
  163. break; }
  164. else
  165. _X += _Tr::to_char_type(_C), _Chg = true;
  166. _CATCH_IO_(_I); }
  167. if (!_Chg)
  168. _St |= ios_base::failbit;
  169. _I.setstate(_St);
  170. return (_I); }
  171. template<class _E, class _Tr, class _A> inline
  172. basic_ostream<_E, _Tr>& __cdecl operator<<(
  173. basic_ostream<_E, _Tr>& _O,
  174. const basic_string<_E, _Tr, _A>& _X)
  175. {
  176. for (_A::size_type _N = 0; _N < _X.size(); ++_N)
  177. if (_Tr::eq_int_type(_Tr::eof(),
  178. _O.rdbuf()->sputc(_X[_N])))
  179. break;
  180. return (_O); }
  181. #ifdef _DLL
  182. #pragma warning(disable:4231) /* the extern before template is a non-standard extension */
  183. extern template class _CRTIMP
  184. basic_string<char, char_traits<char>, allocator<char> > __cdecl operator+(
  185. const basic_string<char, char_traits<char>, allocator<char> >&,
  186. const basic_string<char, char_traits<char>, allocator<char> >&);
  187. extern template class _CRTIMP
  188. basic_string<char, char_traits<char>, allocator<char> > __cdecl operator+(
  189. const char *, const basic_string<char, char_traits<char>, allocator<char> >&);
  190. extern template class _CRTIMP
  191. basic_string<char, char_traits<char>, allocator<char> > __cdecl operator+(
  192. const char, const basic_string<char, char_traits<char>, allocator<char> >&);
  193. extern template class _CRTIMP
  194. basic_string<char, char_traits<char>, allocator<char> > __cdecl operator+(
  195. const basic_string<char, char_traits<char>, allocator<char> >&, const char *);
  196. extern template class _CRTIMP
  197. basic_string<char, char_traits<char>, allocator<char> > __cdecl operator+(
  198. const basic_string<char, char_traits<char>, allocator<char> >&, const char);
  199. extern template _CRTIMP bool __cdecl operator==(
  200. const basic_string<char, char_traits<char>, allocator<char> >&,
  201. const basic_string<char, char_traits<char>, allocator<char> >&);
  202. extern template _CRTIMP bool __cdecl operator==(
  203. const char *, const basic_string<char, char_traits<char>, allocator<char> >&);
  204. extern template _CRTIMP bool __cdecl operator==(
  205. const basic_string<char, char_traits<char>, allocator<char> >&, const char *);
  206. extern template _CRTIMP bool __cdecl operator!=(
  207. const basic_string<char, char_traits<char>, allocator<char> >&,
  208. const basic_string<char, char_traits<char>, allocator<char> >&);
  209. extern template _CRTIMP bool __cdecl operator!=(
  210. const char *, const basic_string<char, char_traits<char>, allocator<char> >&);
  211. extern template _CRTIMP bool __cdecl operator!=(
  212. const basic_string<char, char_traits<char>, allocator<char> >&, const char *);
  213. extern template _CRTIMP bool __cdecl operator<(
  214. const basic_string<char, char_traits<char>, allocator<char> >&,
  215. const basic_string<char, char_traits<char>, allocator<char> >&);
  216. extern template _CRTIMP bool __cdecl operator<(
  217. const char *, const basic_string<char, char_traits<char>, allocator<char> >&);
  218. extern template _CRTIMP bool __cdecl operator<(
  219. const basic_string<char, char_traits<char>, allocator<char> >&, const char *);
  220. extern template _CRTIMP bool __cdecl operator>(
  221. const basic_string<char, char_traits<char>, allocator<char> >&,
  222. const basic_string<char, char_traits<char>, allocator<char> >&);
  223. extern template _CRTIMP bool __cdecl operator>(
  224. const char *, const basic_string<char, char_traits<char>, allocator<char> >&);
  225. extern template _CRTIMP bool __cdecl operator>(
  226. const basic_string<char, char_traits<char>, allocator<char> >&, const char *);
  227. extern template _CRTIMP bool __cdecl operator<=(
  228. const basic_string<char, char_traits<char>, allocator<char> >&,
  229. const basic_string<char, char_traits<char>, allocator<char> >&);
  230. extern template _CRTIMP bool __cdecl operator<=(
  231. const char *, const basic_string<char, char_traits<char>, allocator<char> >&);
  232. extern template _CRTIMP bool __cdecl operator<=(
  233. const basic_string<char, char_traits<char>, allocator<char> >&, const char *);
  234. extern template _CRTIMP bool __cdecl operator>=(
  235. const basic_string<char, char_traits<char>, allocator<char> >&,
  236. const basic_string<char, char_traits<char>, allocator<char> >&);
  237. extern template _CRTIMP bool __cdecl operator>=(
  238. const char *, const basic_string<char, char_traits<char>, allocator<char> >&);
  239. extern template _CRTIMP bool __cdecl operator>=(
  240. const basic_string<char, char_traits<char>, allocator<char> >&, const char *);
  241. extern template class _CRTIMP
  242. basic_istream<char, char_traits<char> >& __cdecl operator>>(
  243. basic_istream<char, char_traits<char> >&,
  244. basic_string<char, char_traits<char>, allocator<char> >&);
  245. extern template class _CRTIMP
  246. basic_istream<char, char_traits<char> >& __cdecl getline(
  247. basic_istream<char, char_traits<char> >&,
  248. basic_string<char, char_traits<char>, allocator<char> >&);
  249. extern template class _CRTIMP
  250. basic_istream<char, char_traits<char> >& __cdecl getline(
  251. basic_istream<char, char_traits<char> >&,
  252. basic_string<char, char_traits<char>, allocator<char> >&, const char);
  253. extern template class _CRTIMP
  254. basic_ostream<char, char_traits<char> >& __cdecl operator<<(
  255. basic_ostream<char, char_traits<char> >&,
  256. const basic_string<char, char_traits<char>, allocator<char> >&);
  257. extern template class _CRTIMP
  258. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
  259. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  260. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  261. extern template class _CRTIMP
  262. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
  263. const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  264. extern template class _CRTIMP
  265. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
  266. const wchar_t, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  267. extern template class _CRTIMP
  268. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
  269. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *);
  270. extern template class _CRTIMP
  271. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
  272. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t);
  273. extern template _CRTIMP bool __cdecl operator==(
  274. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  275. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  276. extern template _CRTIMP bool __cdecl operator==(
  277. const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  278. extern template _CRTIMP bool __cdecl operator==(
  279. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *);
  280. extern template _CRTIMP bool __cdecl operator!=(
  281. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  282. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  283. extern template _CRTIMP bool __cdecl operator!=(
  284. const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  285. extern template _CRTIMP bool __cdecl operator!=(
  286. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *);
  287. extern template _CRTIMP bool __cdecl operator<(
  288. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  289. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  290. extern template _CRTIMP bool __cdecl operator<(
  291. const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  292. extern template _CRTIMP bool __cdecl operator<(
  293. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *);
  294. extern template _CRTIMP bool __cdecl operator>(
  295. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  296. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  297. extern template _CRTIMP bool __cdecl operator>(
  298. const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  299. extern template _CRTIMP bool __cdecl operator>(
  300. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *);
  301. extern template _CRTIMP bool __cdecl operator<=(
  302. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  303. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  304. extern template _CRTIMP bool __cdecl operator<=(
  305. const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  306. extern template _CRTIMP bool __cdecl operator<=(
  307. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *);
  308. extern template _CRTIMP bool __cdecl operator>=(
  309. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  310. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  311. extern template _CRTIMP bool __cdecl operator>=(
  312. const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  313. extern template _CRTIMP bool __cdecl operator>=(
  314. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *);
  315. extern template class _CRTIMP
  316. basic_istream<wchar_t, char_traits<wchar_t> >& __cdecl operator>>(
  317. basic_istream<wchar_t, char_traits<wchar_t> >&,
  318. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  319. extern template class _CRTIMP
  320. basic_istream<wchar_t, char_traits<wchar_t> >& __cdecl getline(
  321. basic_istream<wchar_t, char_traits<wchar_t> >&,
  322. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  323. extern template class _CRTIMP
  324. basic_istream<wchar_t, char_traits<wchar_t> >& __cdecl getline(
  325. basic_istream<wchar_t, char_traits<wchar_t> >&,
  326. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t);
  327. extern template class _CRTIMP
  328. basic_ostream<wchar_t, char_traits<wchar_t> >& __cdecl operator<<(
  329. basic_ostream<wchar_t, char_traits<wchar_t> >&,
  330. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  331. #pragma warning(default:4231) /* restore previous warning */
  332. #endif // _DLL
  333. _STD_END
  334. #ifdef _MSC_VER
  335. #pragma pack(pop)
  336. #endif /* _MSC_VER */
  337. #endif /* _STRING */
  338. /*
  339. * Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
  340. * Consult your license regarding permissions and restrictions.
  341. */