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.

352 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. #ifndef CRTDLL2
  183. #pragma warning(disable:4231) /* the extern before template is a non-standard extension */
  184. extern template class _CRTIMP2
  185. basic_string<char, char_traits<char>, allocator<char> > __cdecl operator+(
  186. const basic_string<char, char_traits<char>, allocator<char> >&,
  187. const basic_string<char, char_traits<char>, allocator<char> >&);
  188. extern template class _CRTIMP2
  189. basic_string<char, char_traits<char>, allocator<char> > __cdecl operator+(
  190. const char *, const basic_string<char, char_traits<char>, allocator<char> >&);
  191. extern template class _CRTIMP2
  192. basic_string<char, char_traits<char>, allocator<char> > __cdecl operator+(
  193. const char, const basic_string<char, char_traits<char>, allocator<char> >&);
  194. extern template class _CRTIMP2
  195. basic_string<char, char_traits<char>, allocator<char> > __cdecl operator+(
  196. const basic_string<char, char_traits<char>, allocator<char> >&, const char *);
  197. extern template class _CRTIMP2
  198. basic_string<char, char_traits<char>, allocator<char> > __cdecl operator+(
  199. const basic_string<char, char_traits<char>, allocator<char> >&, const char);
  200. extern template _CRTIMP2 bool __cdecl operator==(
  201. const basic_string<char, char_traits<char>, allocator<char> >&,
  202. const basic_string<char, char_traits<char>, allocator<char> >&);
  203. extern template _CRTIMP2 bool __cdecl operator==(
  204. const char *, const basic_string<char, char_traits<char>, allocator<char> >&);
  205. extern template _CRTIMP2 bool __cdecl operator==(
  206. const basic_string<char, char_traits<char>, allocator<char> >&, const char *);
  207. extern template _CRTIMP2 bool __cdecl operator!=(
  208. const basic_string<char, char_traits<char>, allocator<char> >&,
  209. const basic_string<char, char_traits<char>, allocator<char> >&);
  210. extern template _CRTIMP2 bool __cdecl operator!=(
  211. const char *, const basic_string<char, char_traits<char>, allocator<char> >&);
  212. extern template _CRTIMP2 bool __cdecl operator!=(
  213. const basic_string<char, char_traits<char>, allocator<char> >&, const char *);
  214. extern template _CRTIMP2 bool __cdecl operator<(
  215. const basic_string<char, char_traits<char>, allocator<char> >&,
  216. const basic_string<char, char_traits<char>, allocator<char> >&);
  217. extern template _CRTIMP2 bool __cdecl operator<(
  218. const char *, const basic_string<char, char_traits<char>, allocator<char> >&);
  219. extern template _CRTIMP2 bool __cdecl operator<(
  220. const basic_string<char, char_traits<char>, allocator<char> >&, const char *);
  221. extern template _CRTIMP2 bool __cdecl operator>(
  222. const basic_string<char, char_traits<char>, allocator<char> >&,
  223. const basic_string<char, char_traits<char>, allocator<char> >&);
  224. extern template _CRTIMP2 bool __cdecl operator>(
  225. const char *, const basic_string<char, char_traits<char>, allocator<char> >&);
  226. extern template _CRTIMP2 bool __cdecl operator>(
  227. const basic_string<char, char_traits<char>, allocator<char> >&, const char *);
  228. extern template _CRTIMP2 bool __cdecl operator<=(
  229. const basic_string<char, char_traits<char>, allocator<char> >&,
  230. const basic_string<char, char_traits<char>, allocator<char> >&);
  231. extern template _CRTIMP2 bool __cdecl operator<=(
  232. const char *, const basic_string<char, char_traits<char>, allocator<char> >&);
  233. extern template _CRTIMP2 bool __cdecl operator<=(
  234. const basic_string<char, char_traits<char>, allocator<char> >&, const char *);
  235. extern template _CRTIMP2 bool __cdecl operator>=(
  236. const basic_string<char, char_traits<char>, allocator<char> >&,
  237. const basic_string<char, char_traits<char>, allocator<char> >&);
  238. extern template _CRTIMP2 bool __cdecl operator>=(
  239. const char *, const basic_string<char, char_traits<char>, allocator<char> >&);
  240. extern template _CRTIMP2 bool __cdecl operator>=(
  241. const basic_string<char, char_traits<char>, allocator<char> >&, const char *);
  242. extern template class _CRTIMP2
  243. basic_istream<char, char_traits<char> >& __cdecl operator>>(
  244. basic_istream<char, char_traits<char> >&,
  245. basic_string<char, char_traits<char>, allocator<char> >&);
  246. extern template class _CRTIMP2
  247. basic_istream<char, char_traits<char> >& __cdecl getline(
  248. basic_istream<char, char_traits<char> >&,
  249. basic_string<char, char_traits<char>, allocator<char> >&);
  250. extern template class _CRTIMP2
  251. basic_istream<char, char_traits<char> >& __cdecl getline(
  252. basic_istream<char, char_traits<char> >&,
  253. basic_string<char, char_traits<char>, allocator<char> >&, const char);
  254. extern template class _CRTIMP2
  255. basic_ostream<char, char_traits<char> >& __cdecl operator<<(
  256. basic_ostream<char, char_traits<char> >&,
  257. const basic_string<char, char_traits<char>, allocator<char> >&);
  258. extern template class _CRTIMP2
  259. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
  260. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  261. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  262. extern template class _CRTIMP2
  263. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
  264. const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  265. extern template class _CRTIMP2
  266. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
  267. const wchar_t, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  268. extern template class _CRTIMP2
  269. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
  270. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *);
  271. extern template class _CRTIMP2
  272. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
  273. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t);
  274. extern template _CRTIMP2 bool __cdecl operator==(
  275. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  276. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  277. extern template _CRTIMP2 bool __cdecl operator==(
  278. const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  279. extern template _CRTIMP2 bool __cdecl operator==(
  280. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *);
  281. extern template _CRTIMP2 bool __cdecl operator!=(
  282. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  283. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  284. extern template _CRTIMP2 bool __cdecl operator!=(
  285. const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  286. extern template _CRTIMP2 bool __cdecl operator!=(
  287. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *);
  288. extern template _CRTIMP2 bool __cdecl operator<(
  289. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  290. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  291. extern template _CRTIMP2 bool __cdecl operator<(
  292. const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  293. extern template _CRTIMP2 bool __cdecl operator<(
  294. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *);
  295. extern template _CRTIMP2 bool __cdecl operator>(
  296. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  297. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  298. extern template _CRTIMP2 bool __cdecl operator>(
  299. const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  300. extern template _CRTIMP2 bool __cdecl operator>(
  301. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *);
  302. extern template _CRTIMP2 bool __cdecl operator<=(
  303. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  304. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  305. extern template _CRTIMP2 bool __cdecl operator<=(
  306. const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  307. extern template _CRTIMP2 bool __cdecl operator<=(
  308. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *);
  309. extern template _CRTIMP2 bool __cdecl operator>=(
  310. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  311. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  312. extern template _CRTIMP2 bool __cdecl operator>=(
  313. const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  314. extern template _CRTIMP2 bool __cdecl operator>=(
  315. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *);
  316. extern template class _CRTIMP2
  317. basic_istream<wchar_t, char_traits<wchar_t> >& __cdecl operator>>(
  318. basic_istream<wchar_t, char_traits<wchar_t> >&,
  319. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  320. extern template class _CRTIMP2
  321. basic_istream<wchar_t, char_traits<wchar_t> >& __cdecl getline(
  322. basic_istream<wchar_t, char_traits<wchar_t> >&,
  323. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  324. extern template class _CRTIMP2
  325. basic_istream<wchar_t, char_traits<wchar_t> >& __cdecl getline(
  326. basic_istream<wchar_t, char_traits<wchar_t> >&,
  327. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t);
  328. extern template class _CRTIMP2
  329. basic_ostream<wchar_t, char_traits<wchar_t> >& __cdecl operator<<(
  330. basic_ostream<wchar_t, char_traits<wchar_t> >&,
  331. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  332. #pragma warning(default:4231) /* restore previous warning */
  333. #endif // CRTDLL2
  334. #endif // _DLL
  335. _STD_END
  336. #ifdef _MSC_VER
  337. #pragma pack(pop)
  338. #endif /* _MSC_VER */
  339. #endif /* _STRING */
  340. /*
  341. * Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
  342. * Consult your license regarding permissions and restrictions.
  343. */