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