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.

754 lines
26 KiB

  1. // string standard header
  2. #pragma once
  3. #ifndef _STRING_
  4. #define _STRING_
  5. #include <istream>
  6. #pragma pack(push,8)
  7. #pragma warning(push,3)
  8. #pragma warning(disable: 4189)
  9. _STD_BEGIN
  10. // basic_string TEMPLATE FUNCTIONS
  11. template<class _Elem,
  12. class _Traits,
  13. class _Alloc> inline
  14. basic_string<_Elem, _Traits, _Alloc> __cdecl operator+(
  15. const basic_string<_Elem, _Traits, _Alloc>& _Left,
  16. const basic_string<_Elem, _Traits, _Alloc>& _Right)
  17. { // return string + string
  18. return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right);
  19. }
  20. template<class _Elem,
  21. class _Traits,
  22. class _Alloc> inline
  23. basic_string<_Elem, _Traits, _Alloc> __cdecl operator+(
  24. const _Elem *_Left,
  25. const basic_string<_Elem, _Traits, _Alloc>& _Right)
  26. { // return NTCS + string
  27. return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right);
  28. }
  29. template<class _Elem,
  30. class _Traits,
  31. class _Alloc> inline
  32. basic_string<_Elem, _Traits, _Alloc> __cdecl operator+(
  33. const _Elem _Left,
  34. const basic_string<_Elem, _Traits, _Alloc>& _Right)
  35. { // return character + string
  36. return (basic_string<_Elem, _Traits, _Alloc>(1, _Left) += _Right);
  37. }
  38. template<class _Elem,
  39. class _Traits,
  40. class _Alloc> inline
  41. basic_string<_Elem, _Traits, _Alloc> __cdecl operator+(
  42. const basic_string<_Elem, _Traits, _Alloc>& _Left,
  43. const _Elem *_Right)
  44. { // return string + NTCS
  45. return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right);
  46. }
  47. template<class _Elem,
  48. class _Traits,
  49. class _Alloc> inline
  50. basic_string<_Elem, _Traits, _Alloc> __cdecl operator+(
  51. const basic_string<_Elem, _Traits, _Alloc>& _Left,
  52. const _Elem _Right)
  53. { // return string + character
  54. return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right);
  55. }
  56. template<class _Elem,
  57. class _Traits,
  58. class _Alloc> inline
  59. bool __cdecl operator==(
  60. const basic_string<_Elem, _Traits, _Alloc>& _Left,
  61. const basic_string<_Elem, _Traits, _Alloc>& _Right)
  62. { // test for string equality
  63. return (_Left.compare(_Right) == 0);
  64. }
  65. template<class _Elem,
  66. class _Traits,
  67. class _Alloc> inline
  68. bool __cdecl operator==(
  69. const _Elem * _Left,
  70. const basic_string<_Elem, _Traits, _Alloc>& _Right)
  71. { // test for NTCS vs. string equality
  72. return (_Right.compare(_Left) == 0);
  73. }
  74. template<class _Elem,
  75. class _Traits,
  76. class _Alloc> inline
  77. bool __cdecl operator==(
  78. const basic_string<_Elem, _Traits, _Alloc>& _Left,
  79. const _Elem *_Right)
  80. { // test for string vs. NTCS equality
  81. return (_Left.compare(_Right) == 0);
  82. }
  83. template<class _Elem,
  84. class _Traits,
  85. class _Alloc> inline
  86. bool __cdecl operator!=(
  87. const basic_string<_Elem, _Traits, _Alloc>& _Left,
  88. const basic_string<_Elem, _Traits, _Alloc>& _Right)
  89. { // test for string inequality
  90. return (!(_Left == _Right));
  91. }
  92. template<class _Elem,
  93. class _Traits,
  94. class _Alloc> inline
  95. bool __cdecl operator!=(
  96. const _Elem *_Left,
  97. const basic_string<_Elem, _Traits, _Alloc>& _Right)
  98. { // test for NTCS vs. string inequality
  99. return (!(_Left == _Right));
  100. }
  101. template<class _Elem,
  102. class _Traits,
  103. class _Alloc> inline
  104. bool __cdecl operator!=(
  105. const basic_string<_Elem, _Traits, _Alloc>& _Left,
  106. const _Elem *_Right)
  107. { // test for string vs. NTCS inequality
  108. return (!(_Left == _Right));
  109. }
  110. template<class _Elem,
  111. class _Traits,
  112. class _Alloc> inline
  113. bool __cdecl operator<(
  114. const basic_string<_Elem, _Traits, _Alloc>& _Left,
  115. const basic_string<_Elem, _Traits, _Alloc>& _Right)
  116. { // test if string < string
  117. return (_Left.compare(_Right) < 0);
  118. }
  119. template<class _Elem,
  120. class _Traits,
  121. class _Alloc> inline
  122. bool __cdecl operator<(
  123. const _Elem * _Left,
  124. const basic_string<_Elem, _Traits, _Alloc>& _Right)
  125. { // test if NTCS < string
  126. return (_Right.compare(_Left) > 0);
  127. }
  128. template<class _Elem,
  129. class _Traits,
  130. class _Alloc> inline
  131. bool __cdecl operator<(
  132. const basic_string<_Elem, _Traits, _Alloc>& _Left,
  133. const _Elem *_Right)
  134. { // test if string < NTCS
  135. return (_Left.compare(_Right) < 0);
  136. }
  137. template<class _Elem,
  138. class _Traits,
  139. class _Alloc> inline
  140. bool __cdecl operator>(
  141. const basic_string<_Elem, _Traits, _Alloc>& _Left,
  142. const basic_string<_Elem, _Traits, _Alloc>& _Right)
  143. { // test if string > string
  144. return (_Right < _Left);
  145. }
  146. template<class _Elem,
  147. class _Traits,
  148. class _Alloc> inline
  149. bool __cdecl operator>(
  150. const _Elem * _Left,
  151. const basic_string<_Elem, _Traits, _Alloc>& _Right)
  152. { // test if NTCS > string
  153. return (_Right < _Left);
  154. }
  155. template<class _Elem,
  156. class _Traits,
  157. class _Alloc> inline
  158. bool __cdecl operator>(
  159. const basic_string<_Elem, _Traits, _Alloc>& _Left,
  160. const _Elem *_Right)
  161. { // test if string > NTCS
  162. return (_Right < _Left);
  163. }
  164. template<class _Elem,
  165. class _Traits,
  166. class _Alloc> inline
  167. bool __cdecl operator<=(
  168. const basic_string<_Elem, _Traits, _Alloc>& _Left,
  169. const basic_string<_Elem, _Traits, _Alloc>& _Right)
  170. { // test if string <= string
  171. return (!(_Right < _Left));
  172. }
  173. template<class _Elem,
  174. class _Traits,
  175. class _Alloc> inline
  176. bool __cdecl operator<=(
  177. const _Elem * _Left,
  178. const basic_string<_Elem, _Traits, _Alloc>& _Right)
  179. { // test if NTCS <= string
  180. return (!(_Right < _Left));
  181. }
  182. template<class _Elem,
  183. class _Traits,
  184. class _Alloc> inline
  185. bool __cdecl operator<=(
  186. const basic_string<_Elem, _Traits, _Alloc>& _Left,
  187. const _Elem *_Right)
  188. { // test if string <= NTCS
  189. return (!(_Right < _Left));
  190. }
  191. template<class _Elem,
  192. class _Traits,
  193. class _Alloc> inline
  194. bool __cdecl operator>=(
  195. const basic_string<_Elem, _Traits, _Alloc>& _Left,
  196. const basic_string<_Elem, _Traits, _Alloc>& _Right)
  197. { // test if string >= string
  198. return (!(_Left < _Right));
  199. }
  200. template<class _Elem,
  201. class _Traits,
  202. class _Alloc> inline
  203. bool __cdecl operator>=(
  204. const _Elem * _Left,
  205. const basic_string<_Elem, _Traits, _Alloc>& _Right)
  206. { // test if NTCS >= string
  207. return (!(_Left < _Right));
  208. }
  209. template<class _Elem,
  210. class _Traits,
  211. class _Alloc> inline
  212. bool __cdecl operator>=(
  213. const basic_string<_Elem, _Traits, _Alloc>& _Left,
  214. const _Elem *_Right)
  215. { // test if string >= NTCS
  216. return (!(_Left < _Right));
  217. }
  218. template<class _Elem,
  219. class _Traits,
  220. class _Alloc> inline
  221. void swap(
  222. basic_string<_Elem, _Traits, _Alloc>& _Left,
  223. basic_string<_Elem, _Traits, _Alloc>& _Right)
  224. { // swap _Left and _Right strings
  225. _Left.swap(_Right);
  226. }
  227. #ifdef _DLL_CPPLIB
  228. #ifndef CRTDLL2
  229. template class _CRTIMP2 basic_string<char,
  230. char_traits<char>, allocator<char> > __cdecl operator+(
  231. const basic_string<char, char_traits<char>, allocator<char> >&,
  232. const basic_string<char, char_traits<char>, allocator<char> >&);
  233. template class _CRTIMP2 basic_string<char,
  234. char_traits<char>, allocator<char> > __cdecl operator+(
  235. const char *,
  236. const basic_string<char, char_traits<char>, allocator<char> >&);
  237. template class _CRTIMP2 basic_string<char,
  238. char_traits<char>, allocator<char> > __cdecl operator+(
  239. const char,
  240. const basic_string<char, char_traits<char>, allocator<char> >&);
  241. template class _CRTIMP2 basic_string<char,
  242. char_traits<char>, allocator<char> > __cdecl operator+(
  243. const basic_string<char, char_traits<char>, allocator<char> >&,
  244. const char *);
  245. template class _CRTIMP2 basic_string<char,
  246. char_traits<char>, allocator<char> > __cdecl operator+(
  247. const basic_string<char, char_traits<char>, allocator<char> >&,
  248. const char);
  249. template _CRTIMP2 bool __cdecl operator==(
  250. const basic_string<char, char_traits<char>, allocator<char> >&,
  251. const basic_string<char, char_traits<char>, allocator<char> >&);
  252. template _CRTIMP2 bool __cdecl operator==(
  253. const char *,
  254. const basic_string<char, char_traits<char>, allocator<char> >&);
  255. template _CRTIMP2 bool __cdecl operator==(
  256. const basic_string<char, char_traits<char>, allocator<char> >&,
  257. const char *);
  258. template _CRTIMP2 bool __cdecl operator!=(
  259. const basic_string<char, char_traits<char>, allocator<char> >&,
  260. const basic_string<char, char_traits<char>, allocator<char> >&);
  261. template _CRTIMP2 bool __cdecl operator!=(
  262. const char *,
  263. const basic_string<char, char_traits<char>, allocator<char> >&);
  264. template _CRTIMP2 bool __cdecl operator!=(
  265. const basic_string<char, char_traits<char>, allocator<char> >&,
  266. const char *);
  267. template _CRTIMP2 bool __cdecl operator<(
  268. const basic_string<char, char_traits<char>, allocator<char> >&,
  269. const basic_string<char, char_traits<char>, allocator<char> >&);
  270. template _CRTIMP2 bool __cdecl operator<(
  271. const char *,
  272. const basic_string<char, char_traits<char>, allocator<char> >&);
  273. template _CRTIMP2 bool __cdecl operator<(
  274. const basic_string<char, char_traits<char>, allocator<char> >&,
  275. const char *);
  276. template _CRTIMP2 bool __cdecl operator>(
  277. const basic_string<char, char_traits<char>, allocator<char> >&,
  278. const basic_string<char, char_traits<char>, allocator<char> >&);
  279. template _CRTIMP2 bool __cdecl operator>(
  280. const char *,
  281. const basic_string<char, char_traits<char>, allocator<char> >&);
  282. template _CRTIMP2 bool __cdecl operator>(
  283. const basic_string<char, char_traits<char>, allocator<char> >&,
  284. const char *);
  285. template _CRTIMP2 bool __cdecl operator<=(
  286. const basic_string<char, char_traits<char>, allocator<char> >&,
  287. const basic_string<char, char_traits<char>, allocator<char> >&);
  288. template _CRTIMP2 bool __cdecl operator<=(
  289. const char *,
  290. const basic_string<char, char_traits<char>, allocator<char> >&);
  291. template _CRTIMP2 bool __cdecl operator<=(
  292. const basic_string<char, char_traits<char>, allocator<char> >&,
  293. const char *);
  294. template _CRTIMP2 bool __cdecl operator>=(
  295. const basic_string<char, char_traits<char>, allocator<char> >&,
  296. const basic_string<char, char_traits<char>, allocator<char> >&);
  297. template _CRTIMP2 bool __cdecl operator>=(
  298. const char *,
  299. const basic_string<char, char_traits<char>, allocator<char> >&);
  300. template _CRTIMP2 bool __cdecl operator>=(
  301. const basic_string<char, char_traits<char>, allocator<char> >&,
  302. const char *);
  303. template class _CRTIMP2 basic_string<wchar_t,
  304. char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
  305. const basic_string<wchar_t, char_traits<wchar_t>,
  306. allocator<wchar_t> >&,
  307. const basic_string<wchar_t, char_traits<wchar_t>,
  308. allocator<wchar_t> >&);
  309. template class _CRTIMP2 basic_string<wchar_t,
  310. char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
  311. const wchar_t *,
  312. const basic_string<wchar_t, char_traits<wchar_t>,
  313. allocator<wchar_t> >&);
  314. template class _CRTIMP2 basic_string<wchar_t,
  315. char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
  316. const wchar_t,
  317. const basic_string<wchar_t, char_traits<wchar_t>,
  318. allocator<wchar_t> >&);
  319. template class _CRTIMP2 basic_string<wchar_t,
  320. char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
  321. const basic_string<wchar_t, char_traits<wchar_t>,
  322. allocator<wchar_t> >&,
  323. const wchar_t *);
  324. template class _CRTIMP2 basic_string<wchar_t,
  325. char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+(
  326. const basic_string<wchar_t, char_traits<wchar_t>,
  327. allocator<wchar_t> >&,
  328. const wchar_t);
  329. template _CRTIMP2 bool __cdecl operator==(
  330. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  331. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  332. template _CRTIMP2 bool __cdecl operator==(
  333. const wchar_t *,
  334. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  335. template _CRTIMP2 bool __cdecl operator==(
  336. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  337. const wchar_t *);
  338. template _CRTIMP2 bool __cdecl operator!=(
  339. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  340. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  341. template _CRTIMP2 bool __cdecl operator!=(
  342. const wchar_t *,
  343. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  344. template _CRTIMP2 bool __cdecl operator!=(
  345. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  346. const wchar_t *);
  347. template _CRTIMP2 bool __cdecl operator<(
  348. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  349. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  350. template _CRTIMP2 bool __cdecl operator<(
  351. const wchar_t *,
  352. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  353. template _CRTIMP2 bool __cdecl operator<(
  354. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  355. const wchar_t *);
  356. template _CRTIMP2 bool __cdecl operator>(
  357. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  358. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  359. template _CRTIMP2 bool __cdecl operator>(
  360. const wchar_t *,
  361. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  362. template _CRTIMP2 bool __cdecl operator>(
  363. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  364. const wchar_t *);
  365. template _CRTIMP2 bool __cdecl operator<=(
  366. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  367. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  368. template _CRTIMP2 bool __cdecl operator<=(
  369. const wchar_t *,
  370. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  371. template _CRTIMP2 bool __cdecl operator<=(
  372. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  373. const wchar_t *);
  374. template _CRTIMP2 bool __cdecl operator>=(
  375. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  376. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  377. template _CRTIMP2 bool __cdecl operator>=(
  378. const wchar_t *,
  379. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  380. template _CRTIMP2 bool __cdecl operator>=(
  381. const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  382. const wchar_t *);
  383. #ifdef _CRTBLD_NATIVE_WCHAR_T
  384. template class _CRTIMP2 basic_string<unsigned short,
  385. char_traits<unsigned short>, allocator<unsigned short> > __cdecl operator+(
  386. const basic_string<unsigned short, char_traits<unsigned short>,
  387. allocator<unsigned short> >&,
  388. const basic_string<unsigned short, char_traits<unsigned short>,
  389. allocator<unsigned short> >&);
  390. template class _CRTIMP2 basic_string<unsigned short,
  391. char_traits<unsigned short>, allocator<unsigned short> > __cdecl operator+(
  392. const unsigned short *,
  393. const basic_string<unsigned short, char_traits<unsigned short>,
  394. allocator<unsigned short> >&);
  395. template class _CRTIMP2 basic_string<unsigned short,
  396. char_traits<unsigned short>, allocator<unsigned short> > __cdecl operator+(
  397. const unsigned short,
  398. const basic_string<unsigned short, char_traits<unsigned short>,
  399. allocator<unsigned short> >&);
  400. template class _CRTIMP2 basic_string<unsigned short,
  401. char_traits<unsigned short>, allocator<unsigned short> > __cdecl operator+(
  402. const basic_string<unsigned short, char_traits<unsigned short>,
  403. allocator<unsigned short> >&,
  404. const unsigned short *);
  405. template class _CRTIMP2 basic_string<unsigned short,
  406. char_traits<unsigned short>, allocator<unsigned short> > __cdecl operator+(
  407. const basic_string<unsigned short, char_traits<unsigned short>,
  408. allocator<unsigned short> >&,
  409. const unsigned short);
  410. template _CRTIMP2 bool __cdecl operator==(
  411. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
  412. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
  413. template _CRTIMP2 bool __cdecl operator==(
  414. const unsigned short *,
  415. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
  416. template _CRTIMP2 bool __cdecl operator==(
  417. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
  418. const unsigned short *);
  419. template _CRTIMP2 bool __cdecl operator!=(
  420. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
  421. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
  422. template _CRTIMP2 bool __cdecl operator!=(
  423. const unsigned short *,
  424. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
  425. template _CRTIMP2 bool __cdecl operator!=(
  426. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
  427. const unsigned short *);
  428. template _CRTIMP2 bool __cdecl operator<(
  429. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
  430. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
  431. template _CRTIMP2 bool __cdecl operator<(
  432. const unsigned short *,
  433. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
  434. template _CRTIMP2 bool __cdecl operator<(
  435. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
  436. const unsigned short *);
  437. template _CRTIMP2 bool __cdecl operator>(
  438. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
  439. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
  440. template _CRTIMP2 bool __cdecl operator>(
  441. const unsigned short *,
  442. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
  443. template _CRTIMP2 bool __cdecl operator>(
  444. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
  445. const unsigned short *);
  446. template _CRTIMP2 bool __cdecl operator<=(
  447. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
  448. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
  449. template _CRTIMP2 bool __cdecl operator<=(
  450. const unsigned short *,
  451. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
  452. template _CRTIMP2 bool __cdecl operator<=(
  453. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
  454. const unsigned short *);
  455. template _CRTIMP2 bool __cdecl operator>=(
  456. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
  457. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
  458. template _CRTIMP2 bool __cdecl operator>=(
  459. const unsigned short *,
  460. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
  461. template _CRTIMP2 bool __cdecl operator>=(
  462. const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
  463. const unsigned short *);
  464. #endif
  465. #endif // CRTDLL2
  466. #endif // _DLL_CPPLIB
  467. // basic_string INSERTERS AND EXTRACTORS
  468. template<class _Elem,
  469. class _Traits,
  470. class _Alloc> inline
  471. basic_istream<_Elem, _Traits>& __cdecl operator>>(
  472. basic_istream<_Elem, _Traits>& _Istr,
  473. basic_string<_Elem, _Traits, _Alloc>& _Str)
  474. { // extract a string
  475. typedef ctype<_Elem> _Ctype;
  476. typedef basic_istream<_Elem, _Traits> _Myis;
  477. typedef basic_string<_Elem, _Traits, _Alloc> _Mystr;
  478. typedef typename _Mystr::size_type _Mysizt;
  479. ios_base::iostate _State = ios_base::goodbit;
  480. bool _Changed = false;
  481. const typename _Myis::sentry _Ok(_Istr);
  482. if (_Ok)
  483. { // state okay, extract characters
  484. const _Ctype& _Fac = _USE(_Istr.getloc(), _Ctype);
  485. _Str.erase();
  486. _TRY_IO_BEGIN
  487. _Mysizt _Size = 0 < _Istr.width()
  488. && (_Mysizt)_Istr.width() < _Str.max_size()
  489. ? (_Mysizt)_Istr.width() : _Str.max_size();
  490. typename _Traits::int_type _Meta = _Istr.rdbuf()->sgetc();
  491. for (; 0 < _Size; --_Size, _Meta = _Istr.rdbuf()->snextc())
  492. if(_Traits::eq_int_type(_Traits::eof(), _Meta))
  493. { // end of file, quit
  494. _State |= ios_base::eofbit;
  495. break;
  496. }
  497. else if (_Fac.is(_Ctype::space, _Traits::to_char_type(_Meta)))
  498. break; // whitespace, quit
  499. else
  500. { // add character to string
  501. _Str.append(1, _Traits::to_char_type(_Meta));
  502. _Changed = true;
  503. }
  504. _CATCH_IO_(_Istr)
  505. }
  506. _Istr.width(0);
  507. if (!_Changed)
  508. _State |= ios_base::failbit;
  509. _Istr.setstate(_State);
  510. return (_Istr);
  511. }
  512. template<class _Elem,
  513. class _Traits,
  514. class _Alloc> inline
  515. basic_istream<_Elem, _Traits>& __cdecl getline(
  516. basic_istream<_Elem, _Traits>& _Istr,
  517. basic_string<_Elem, _Traits, _Alloc>& _Str)
  518. { // get characters into string, discard newline
  519. return (getline(_Istr, _Str, _Istr.widen('\n')));
  520. }
  521. template<class _Elem,
  522. class _Traits,
  523. class _Alloc> inline
  524. basic_istream<_Elem, _Traits>& __cdecl getline(
  525. basic_istream<_Elem, _Traits>& _Istr,
  526. basic_string<_Elem, _Traits, _Alloc>& _Str, const _Elem _Delim)
  527. { // get characters into string, discard delimiter
  528. typedef basic_istream<_Elem, _Traits> _Myis;
  529. ios_base::iostate _State = ios_base::goodbit;
  530. bool _Changed = false;
  531. const typename _Myis::sentry _Ok(_Istr, true);
  532. if (_Ok)
  533. { // state okay, extract characters
  534. _TRY_IO_BEGIN
  535. _Str.erase();
  536. const typename _Traits::int_type _Metadelim =
  537. _Traits::to_int_type(_Delim);
  538. typename _Traits::int_type _Meta = _Istr.rdbuf()->sgetc();
  539. for (; ; _Meta = _Istr.rdbuf()->snextc())
  540. if (_Traits::eq_int_type(_Traits::eof(), _Meta))
  541. { // end of file, quit
  542. _State |= ios_base::eofbit;
  543. break;
  544. }
  545. else if (_Traits::eq_int_type(_Meta, _Metadelim))
  546. { // got a delimiter, discard it and quit
  547. _Changed = true;
  548. _Istr.rdbuf()->sbumpc();
  549. break;
  550. }
  551. else if (_Str.max_size() <= _Str.size())
  552. { // string too large, quit
  553. _State |= ios_base::failbit;
  554. break;
  555. }
  556. else
  557. { // got a character, add it to string
  558. _Str += _Traits::to_char_type(_Meta);
  559. _Changed = true;
  560. }
  561. _CATCH_IO_(_Istr)
  562. }
  563. if (!_Changed)
  564. _State |= ios_base::failbit;
  565. _Istr.setstate(_State);
  566. return (_Istr);
  567. }
  568. template<class _Elem,
  569. class _Traits,
  570. class _Alloc> inline
  571. basic_ostream<_Elem, _Traits>& __cdecl operator<<(
  572. basic_ostream<_Elem, _Traits>& _Ostr,
  573. const basic_string<_Elem, _Traits, _Alloc>& _Str)
  574. { // insert a string
  575. typedef basic_ostream<_Elem, _Traits> _Myos;
  576. typedef basic_string<_Elem, _Traits, _Alloc> _Mystr;
  577. typedef typename _Mystr::size_type _Mysizt;
  578. ios_base::iostate _State = ios_base::goodbit;
  579. _Mysizt _Size = _Str.size();
  580. _Mysizt _Pad = _Ostr.width() <= 0 || (_Mysizt)_Ostr.width() <= _Size
  581. ? 0 : (_Mysizt)_Ostr.width() - _Size;
  582. const typename _Myos::sentry _Ok(_Ostr);
  583. if (!_Ok)
  584. _State |= ios_base::badbit;
  585. else
  586. { // state okay, insert characters
  587. _TRY_IO_BEGIN
  588. if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left)
  589. for (; 0 < _Pad; --_Pad) // pad on left
  590. if (_Traits::eq_int_type(_Traits::eof(),
  591. _Ostr.rdbuf()->sputc(_Ostr.fill())))
  592. { // insertion failed, quit
  593. _State |= ios_base::badbit;
  594. break;
  595. }
  596. if (_State == ios_base::goodbit)
  597. for (_Mysizt _Count = 0; _Count < _Size; ++_Count)
  598. if (_Traits::eq_int_type(_Traits::eof(),
  599. _Ostr.rdbuf()->sputc(_Str[_Count])))
  600. { // insertion failed, quit
  601. _State |= ios_base::badbit;
  602. break;
  603. }
  604. if (_State == ios_base::goodbit)
  605. for (; 0 < _Pad; --_Pad) // pad on right
  606. if (_Traits::eq_int_type(_Traits::eof(),
  607. _Ostr.rdbuf()->sputc(_Ostr.fill())))
  608. { // insertion failed, quit
  609. _State |= ios_base::badbit;
  610. break;
  611. }
  612. _Ostr.width(0);
  613. _CATCH_IO_(_Ostr)
  614. }
  615. _Ostr.setstate(_State);
  616. return (_Ostr);
  617. }
  618. #ifdef _DLL_CPPLIB
  619. #ifndef CRTDLL2
  620. template class _CRTIMP2 basic_istream<char,
  621. char_traits<char> >& __cdecl operator>>(
  622. basic_istream<char, char_traits<char> >&,
  623. basic_string<char, char_traits<char>, allocator<char> >&);
  624. template class _CRTIMP2 basic_istream<char,
  625. char_traits<char> >& __cdecl getline(
  626. basic_istream<char, char_traits<char> >&,
  627. basic_string<char, char_traits<char>, allocator<char> >&);
  628. template class _CRTIMP2 basic_istream<char,
  629. char_traits<char> >& __cdecl getline(
  630. basic_istream<char, char_traits<char> >&,
  631. basic_string<char, char_traits<char>, allocator<char> >&,
  632. const char);
  633. template class _CRTIMP2 basic_ostream<char,
  634. char_traits<char> >& __cdecl operator<<(
  635. basic_ostream<char, char_traits<char> >&,
  636. const basic_string<char, char_traits<char>, allocator<char> >&);
  637. template class _CRTIMP2 basic_istream<wchar_t,
  638. char_traits<wchar_t> >& __cdecl operator>>(
  639. basic_istream<wchar_t, char_traits<wchar_t> >&,
  640. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  641. template class _CRTIMP2 basic_istream<wchar_t,
  642. char_traits<wchar_t> >& __cdecl getline(
  643. basic_istream<wchar_t, char_traits<wchar_t> >&,
  644. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&);
  645. template class _CRTIMP2 basic_istream<wchar_t,
  646. char_traits<wchar_t> >& __cdecl getline(
  647. basic_istream<wchar_t, char_traits<wchar_t> >&,
  648. basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&,
  649. const wchar_t);
  650. template class _CRTIMP2 basic_ostream<wchar_t,
  651. char_traits<wchar_t> >& __cdecl operator<<(
  652. basic_ostream<wchar_t, char_traits<wchar_t> >&,
  653. const basic_string<wchar_t, char_traits<wchar_t>,
  654. allocator<wchar_t> >&);
  655. #ifdef _CRTBLD_NATIVE_WCHAR_T
  656. template class _CRTIMP2 basic_istream<unsigned short,
  657. char_traits<unsigned short> >& __cdecl operator>>(
  658. basic_istream<unsigned short, char_traits<unsigned short> >&,
  659. basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
  660. template class _CRTIMP2 basic_istream<unsigned short,
  661. char_traits<unsigned short> >& __cdecl getline(
  662. basic_istream<unsigned short, char_traits<unsigned short> >&,
  663. basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
  664. template class _CRTIMP2 basic_istream<unsigned short,
  665. char_traits<unsigned short> >& __cdecl getline(
  666. basic_istream<unsigned short, char_traits<unsigned short> >&,
  667. basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
  668. const unsigned short);
  669. template class _CRTIMP2 basic_ostream<unsigned short,
  670. char_traits<unsigned short> >& __cdecl operator<<(
  671. basic_ostream<unsigned short, char_traits<unsigned short> >&,
  672. const basic_string<unsigned short, char_traits<unsigned short>,
  673. allocator<unsigned short> >&);
  674. #endif
  675. #endif // CRTDLL2
  676. #endif // _DLL_CPPLIB
  677. _STD_END
  678. #pragma warning(default: 4189)
  679. #pragma warning(pop)
  680. #pragma pack(pop)
  681. #endif /* _STRING */
  682. /*
  683. * Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
  684. * Consult your license regarding permissions and restrictions.
  685. V3.10:0009 */