Source code of Windows XP (NT5)
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.

1165 lines
34 KiB

  1. // xlocnum internal header (from <locale>)
  2. #pragma once
  3. #ifndef _XLOCNUM_
  4. #define _XLOCNUM_
  5. #include <cerrno>
  6. #include <climits>
  7. #include <cstdio>
  8. #include <cstdlib>
  9. #include <streambuf>
  10. #pragma pack(push,8)
  11. #pragma warning(push,3)
  12. _STD_BEGIN
  13. // TEMPLATE CLASS numpunct
  14. template<class _Elem>
  15. class numpunct
  16. : public locale::facet
  17. { // facet for defining numeric punctuation text
  18. public:
  19. typedef basic_string<_Elem, char_traits<_Elem>, allocator<_Elem> >
  20. string_type;
  21. typedef _Elem char_type;
  22. static locale::id id; // unique facet id
  23. _Elem decimal_point() const
  24. { // return decimal point
  25. return (do_decimal_point());
  26. }
  27. _Elem thousands_sep() const
  28. { // return thousands separator
  29. return (do_thousands_sep());
  30. }
  31. string grouping() const
  32. { // return grouping string
  33. return (do_grouping());
  34. }
  35. string_type falsename() const
  36. { // return name for false
  37. return (do_falsename());
  38. }
  39. string_type truename() const
  40. { // return name for true
  41. return (do_truename());
  42. }
  43. explicit numpunct(size_t _Refs = 0)
  44. : locale::facet(_Refs)
  45. { // construct from current locale
  46. _Init(_Locinfo());
  47. }
  48. numpunct(const _Locinfo& _Lobj, size_t _Refs = 0)
  49. : locale::facet(_Refs)
  50. { // construct from specified locale
  51. _Init(_Lobj);
  52. }
  53. static size_t __cdecl _Getcat(const locale::facet **_Ppf = 0)
  54. { // return locale category mask and construct standard facet
  55. if (_Ppf != 0 && *_Ppf == 0)
  56. *_Ppf = _NEW_CRT numpunct<_Elem>;
  57. return (_X_NUMERIC);
  58. }
  59. _PROTECTED:
  60. virtual ~numpunct()
  61. { // destroy the object
  62. _Tidy();
  63. }
  64. protected:
  65. void _Init(const _Locinfo& _Lobj)
  66. { // initialize from _Lobj
  67. const lconv *_Ptr = _Lobj._Getlconv();
  68. _Grouping = 0;
  69. _Falsename = 0;
  70. _Truename = 0;
  71. _TRY_BEGIN
  72. _Grouping = _MAKLOCSTR(char, _Ptr->grouping, _Lobj._Getcvt());
  73. _Falsename = _MAKLOCSTR(_Elem, _Lobj._Getfalse(), _Lobj._Getcvt());
  74. _Truename = _MAKLOCSTR(_Elem, _Lobj._Gettrue(), _Lobj._Getcvt());
  75. _CATCH_ALL
  76. _Tidy();
  77. _RERAISE;
  78. _CATCH_END
  79. _Dp = _WIDEN(_Elem, _Ptr->decimal_point[0]);
  80. _Kseparator = _WIDEN(_Elem, _Ptr->thousands_sep[0]);
  81. }
  82. virtual _Elem do_decimal_point() const
  83. { // return decimal point
  84. return (_Dp);
  85. }
  86. virtual _Elem do_thousands_sep() const
  87. { // return thousands separator
  88. return (_Kseparator);
  89. }
  90. virtual string do_grouping() const
  91. { // return grouping string
  92. return (string(_Grouping));
  93. }
  94. virtual string_type do_falsename() const
  95. { // return name for false
  96. return (string_type(_Falsename));
  97. }
  98. virtual string_type do_truename() const
  99. { // return name for true
  100. return (string_type(_Truename));
  101. }
  102. private:
  103. void _Tidy()
  104. { // free all storage
  105. _DELETE_CRT_VEC((void *)_Grouping);
  106. _DELETE_CRT_VEC((void *)_Falsename);
  107. _DELETE_CRT_VEC((void *)_Truename);
  108. }
  109. const char *_Grouping; // grouping string, "" for "C" locale
  110. _Elem _Dp; // decimal point, '.' for "C" locale
  111. _Elem _Kseparator; // thousands separator, '\0' for "C" locale
  112. const _Elem *_Falsename; // name for false, "false" for "C" locale
  113. const _Elem *_Truename; // name for true, "true" for "C" locale
  114. };
  115. typedef numpunct<char> _Npc;
  116. typedef numpunct<wchar_t> _Npwc;
  117. // TEMPLATE CLASS numpunct_byname
  118. template<class _Elem>
  119. class numpunct_byname
  120. : public numpunct<_Elem>
  121. { // numpunct for named locale
  122. public:
  123. explicit numpunct_byname(const char *_Locname, size_t _Refs = 0)
  124. : numpunct<_Elem>(_Locinfo(_Locname), _Refs)
  125. { // construct for named locale
  126. }
  127. _PROTECTED:
  128. virtual ~numpunct_byname()
  129. { // destroy the object
  130. }
  131. };
  132. // STATIC numpunct::id OBJECT
  133. template<class _Elem>
  134. locale::id numpunct<_Elem>::id;
  135. #define _VIRTUAL virtual
  136. // TEMPLATE CLASS num_get
  137. template<class _Elem,
  138. class _InIt = istreambuf_iterator<_Elem, char_traits<_Elem> > >
  139. class num_get
  140. : public locale::facet
  141. { // facet for converting text to encoded numbers
  142. public:
  143. typedef numpunct<_Elem> _Mypunct;
  144. typedef basic_string<_Elem, char_traits<_Elem>, allocator<_Elem> >
  145. _Mystr;
  146. static size_t __cdecl _Getcat(const locale::facet **_Ppf = 0)
  147. { // return locale category mask and construct standard facet
  148. if (_Ppf != 0 && *_Ppf == 0)
  149. *_Ppf = _NEW_CRT num_get<_Elem, _InIt>;
  150. return (_X_NUMERIC);
  151. }
  152. static locale::id id; // unique facet id
  153. _PROTECTED:
  154. virtual ~num_get()
  155. { // destroy the object
  156. }
  157. protected:
  158. void _Init(const _Locinfo&)
  159. { // initialize from _Locinfo object (do nothing)
  160. }
  161. public:
  162. explicit num_get(size_t _Refs = 0)
  163. : locale::facet(_Refs)
  164. { // construct from current locale
  165. _Init(_Locinfo());
  166. }
  167. num_get(const _Locinfo& _Lobj, size_t _Refs = 0)
  168. : locale::facet(_Refs)
  169. { // construct from specified locale
  170. _Init(_Lobj);
  171. }
  172. typedef _Elem char_type;
  173. typedef _InIt iter_type;
  174. _InIt get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  175. ios_base::iostate& _State, _Bool& _Val) const
  176. { // get bool from [_First, _Last) into _Val
  177. return (do_get(_First, _Last, _Iosbase, _State, _Val));
  178. }
  179. _InIt get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  180. ios_base::iostate& _State, unsigned short& _Val) const
  181. { // get unsigned short from [_First, _Last) into _Val
  182. return (do_get(_First, _Last, _Iosbase, _State, _Val));
  183. }
  184. _InIt get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  185. ios_base::iostate& _State, unsigned int& _Val) const
  186. { // get unsigned int from [_First, _Last) into _Val
  187. return (do_get(_First, _Last, _Iosbase, _State, _Val));
  188. }
  189. _InIt get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  190. ios_base::iostate& _State, long& _Val) const
  191. { // get long from [_First, _Last) into _Val
  192. return (do_get(_First, _Last, _Iosbase, _State, _Val));
  193. }
  194. _InIt get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  195. ios_base::iostate& _State, unsigned long& _Val) const
  196. { // get unsigned long from [_First, _Last) into _Val
  197. return (do_get(_First, _Last, _Iosbase, _State, _Val));
  198. }
  199. #ifdef _LONGLONG
  200. _InIt get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  201. ios_base::iostate& _State, _LONGLONG& _Val) const
  202. { // get long long from [_First, _Last) into _Val
  203. return (do_get(_First, _Last, _Iosbase, _State, _Val));
  204. }
  205. _InIt get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  206. ios_base::iostate& _State, _ULONGLONG& _Val) const
  207. { // get unsigned long long from [_First, _Last) into _Val
  208. return (do_get(_First, _Last, _Iosbase, _State, _Val));
  209. }
  210. #endif /* _LONGLONG */
  211. _InIt get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  212. ios_base::iostate& _State, float& _Val) const
  213. { // get float from [_First, _Last) into _Val
  214. return (do_get(_First, _Last, _Iosbase, _State, _Val));
  215. }
  216. _InIt get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  217. ios_base::iostate& _State, double& _Val) const
  218. { // get double from [_First, _Last) into _Val
  219. return (do_get(_First, _Last, _Iosbase, _State, _Val));
  220. }
  221. _InIt get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  222. ios_base::iostate& _State, long double& _Val) const
  223. { // get long double from [_First, _Last) into _Val
  224. return (do_get(_First, _Last, _Iosbase, _State, _Val));
  225. }
  226. _InIt get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  227. ios_base::iostate& _State, void *& _Val) const
  228. { // get void pointer from [_First, _Last) into _Val
  229. return (do_get(_First, _Last, _Iosbase, _State, _Val));
  230. }
  231. protected:
  232. _VIRTUAL _InIt do_get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  233. ios_base::iostate& _State, _Bool& _Val) const
  234. { // get bool from [_First, _Last) into _Val
  235. int _Ans = -1; // negative answer indicates failure
  236. if (_Iosbase.flags() & ios_base::boolalpha)
  237. { // get false name or true name
  238. const _Mypunct& _Fac = _USE(_Iosbase.getloc(), _Mypunct);
  239. _Mystr _Str((typename _Mystr::size_type)1, (char_type)0);
  240. _Str += _Fac.falsename();
  241. _Str += (char_type)0;
  242. _Str += _Fac.truename(); // construct "\0false\0true"
  243. _Ans = _Getloctxt(_First, _Last, (size_t)2, _Str.c_str());
  244. }
  245. else
  246. { // get zero or nonzero integer
  247. char _Ac[_MAX_INT_DIG], *_Ep;
  248. errno = 0;
  249. const unsigned long _Ulo = ::strtoul(_Ac, &_Ep,
  250. _Getifld(_Ac, _First, _Last, _Iosbase.flags(),
  251. _Iosbase.getloc()));
  252. if (_Ep != _Ac && errno == 0 && _Ulo <= 1)
  253. _Ans = _Ulo;
  254. }
  255. if (_First == _Last)
  256. _State |= ios_base::eofbit;
  257. if (_Ans < 0)
  258. _State |= ios_base::failbit;
  259. else
  260. _Val = _Ans != 0; // deliver value
  261. return (_First);
  262. }
  263. _VIRTUAL _InIt do_get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  264. ios_base::iostate& _State, unsigned short& _Val) const
  265. { // get unsigned short from [_First, _Last) into _Val
  266. char _Ac[_MAX_INT_DIG], *_Ep;
  267. errno = 0;
  268. int _Base = _Getifld(_Ac, _First, _Last, _Iosbase.flags(),
  269. _Iosbase.getloc()); // gather field into _Ac
  270. char *_Ptr = _Ac[0] == '-' ? _Ac + 1 : _Ac; // point past any sign
  271. const unsigned long _Ans =
  272. ::strtoul(_Ptr, &_Ep, _Base); // convert
  273. if (_First == _Last)
  274. _State |= ios_base::eofbit;
  275. if (_Ep == _Ptr || errno != 0 || USHRT_MAX < _Ans)
  276. _State |= ios_base::failbit;
  277. else
  278. _Val = (unsigned short)(_Ac[0] == '-'
  279. ? 0 -_Ans : _Ans); // deliver value
  280. return (_First);
  281. }
  282. _VIRTUAL _InIt do_get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  283. ios_base::iostate& _State, unsigned int& _Val) const
  284. { // get unsigned int from [_First, _Last) into _Val
  285. char _Ac[_MAX_INT_DIG], *_Ep;
  286. errno = 0;
  287. int _Base = _Getifld(_Ac, _First, _Last, _Iosbase.flags(),
  288. _Iosbase.getloc()); // gather field into _Ac
  289. char *_Ptr = _Ac[0] == '-' ? _Ac + 1 : _Ac; // point past any sign
  290. const unsigned long _Ans =
  291. ::strtoul(_Ptr, &_Ep, _Base); // convert
  292. if (_First == _Last)
  293. _State |= ios_base::eofbit;
  294. if (_Ep == _Ptr || errno != 0 || UINT_MAX < _Ans)
  295. _State |= ios_base::failbit;
  296. else
  297. _Val = _Ac[0] == '-' ? 0 -_Ans : _Ans; // deliver value
  298. return (_First);
  299. }
  300. _VIRTUAL _InIt do_get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  301. ios_base::iostate& _State, long& _Val) const
  302. { // get long from [_First, _Last) into _Val
  303. char _Ac[_MAX_INT_DIG], *_Ep;
  304. errno = 0;
  305. const long _Ans = ::strtol(_Ac, &_Ep,
  306. _Getifld(_Ac, _First, _Last, _Iosbase.flags(),
  307. _Iosbase.getloc())); // gather field, convert
  308. if (_First == _Last)
  309. _State |= ios_base::eofbit;
  310. if (_Ep == _Ac || errno != 0)
  311. _State |= ios_base::failbit;
  312. else
  313. _Val = _Ans; // deliver value
  314. return (_First);
  315. }
  316. _VIRTUAL _InIt do_get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  317. ios_base::iostate& _State, unsigned long& _Val) const
  318. { // get unsigned long from [_First, _Last) into _Val
  319. char _Ac[_MAX_INT_DIG], *_Ep;
  320. errno = 0;
  321. const unsigned long _Ans = ::strtoul(_Ac, &_Ep,
  322. _Getifld(_Ac, _First, _Last, _Iosbase.flags(),
  323. _Iosbase.getloc())); // gather field, convert
  324. if (_First == _Last)
  325. _State |= ios_base::eofbit;
  326. if (_Ep == _Ac || errno != 0)
  327. _State |= ios_base::failbit;
  328. else
  329. _Val = _Ans; // deliver value
  330. return (_First);
  331. }
  332. #ifdef _LONGLONG
  333. _VIRTUAL _InIt do_get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  334. ios_base::iostate& _State, _LONGLONG& _Val) const
  335. { // get long long from [_First, _Last) into _Val
  336. char _Ac[_MAX_INT_DIG], *_Ep;
  337. errno = 0;
  338. const _LONGLONG _Ans = ::_strtoi64(_Ac, &_Ep,
  339. _Getifld(_Ac, _First, _Last, _Iosbase.flags(),
  340. _Iosbase.getloc())); // gather field, convert
  341. if (_First == _Last)
  342. _State |= ios_base::eofbit;
  343. if (_Ep == _Ac || errno != 0)
  344. _State |= ios_base::failbit;
  345. else
  346. _Val = _Ans; // deliver value
  347. return (_First);
  348. }
  349. _VIRTUAL _InIt do_get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  350. ios_base::iostate& _State, _ULONGLONG& _Val) const
  351. { // get unsigned long long from [_First, _Last) into _Val
  352. char _Ac[_MAX_INT_DIG], *_Ep;
  353. errno = 0;
  354. const _ULONGLONG _Ans = ::_strtoui64(_Ac, &_Ep,
  355. _Getifld(_Ac, _First, _Last, _Iosbase.flags(),
  356. _Iosbase.getloc())); // gather field, convert
  357. if (_First == _Last)
  358. _State |= ios_base::eofbit;
  359. if (_Ep == _Ac || errno != 0)
  360. _State |= ios_base::failbit;
  361. else
  362. _Val = _Ans; // deliver value
  363. return (_First);
  364. }
  365. #endif /* _LONGLONG */
  366. _VIRTUAL _InIt do_get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  367. ios_base::iostate& _State, float& _Val) const
  368. { // get float from [_First, _Last) into _Val
  369. char _Ac[_MAX_EXP_DIG + _MAX_SIG_DIG + 16], *_Ep;
  370. errno = 0;
  371. const float _Ans = ::_Stof(_Ac, &_Ep,
  372. _Getffld(_Ac, _First, _Last,
  373. _Iosbase.getloc())); // gather field, convert
  374. if (_First == _Last)
  375. _State |= ios_base::eofbit;
  376. if (_Ep == _Ac || errno != 0)
  377. _State |= ios_base::failbit;
  378. else
  379. _Val = _Ans; // deliver value
  380. return (_First);
  381. }
  382. _VIRTUAL _InIt do_get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  383. ios_base::iostate& _State, double& _Val) const
  384. { // get double from [_First, _Last) into _Val
  385. char _Ac[_MAX_EXP_DIG + _MAX_SIG_DIG + 16], *_Ep;
  386. errno = 0;
  387. const double _Ans = ::_Stod(_Ac, &_Ep,
  388. _Getffld(_Ac, _First, _Last,
  389. _Iosbase.getloc())); // gather field, convert
  390. if (_First == _Last)
  391. _State |= ios_base::eofbit;
  392. if (_Ep == _Ac || errno != 0)
  393. _State |= ios_base::failbit;
  394. else
  395. _Val = _Ans; // deliver value
  396. return (_First);
  397. }
  398. _VIRTUAL _InIt do_get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  399. ios_base::iostate& _State, long double& _Val) const
  400. { // get long double from [_First, _Last) into _Val
  401. char _Ac[_MAX_EXP_DIG + _MAX_SIG_DIG + 16], *_Ep;
  402. errno = 0;
  403. const long double _Ans = ::_Stold(_Ac, &_Ep,
  404. _Getffld(_Ac, _First, _Last,
  405. _Iosbase.getloc())); // gather field, convert
  406. if (_First == _Last)
  407. _State |= ios_base::eofbit;
  408. if (_Ep == _Ac || errno != 0)
  409. _State |= ios_base::failbit;
  410. else
  411. _Val = _Ans; // deliver value
  412. return (_First);
  413. }
  414. _VIRTUAL _InIt do_get(_InIt _First, _InIt _Last, ios_base& _Iosbase,
  415. ios_base::iostate& _State, void *& _Val) const
  416. { // get void pointer from [_First, _Last) into _Val
  417. char _Ac[_MAX_INT_DIG], *_Ep;
  418. errno = 0;
  419. #ifdef _LONGLONG
  420. int _Base = _Getifld(_Ac, _First, _Last, ios_base::hex,
  421. _Iosbase.getloc()); // gather field
  422. const _ULONGLONG _Ans =
  423. (sizeof (void *) == sizeof (unsigned long))
  424. ? (_ULONGLONG)::strtoul(_Ac, &_Ep, _Base)
  425. : ::_strtoui64(_Ac, &_Ep, _Base);
  426. #else /* _LONGLONG */
  427. const unsigned long _Ans = ::strtoul(_Ac, &_Ep,
  428. _Getifld(_Ac, _First, _Last, ios_base::hex,
  429. _Iosbase.getloc())); // gather field, convert
  430. #endif /* _LONGLONG */
  431. if (_First == _Last)
  432. _State |= ios_base::eofbit;
  433. if (_Ep == _Ac || errno != 0)
  434. _State |= ios_base::failbit;
  435. else
  436. _Val = (void *)((char *)0 + _Ans); // deliver value
  437. return (_First);
  438. }
  439. private:
  440. static int __cdecl _Getifld(char *_Ac, _InIt& _First, _InIt& _Last,
  441. ios_base::fmtflags _Basefield, const locale& _Loc)
  442. { // get integer field from [_First, _Last) into _Ac
  443. const _Elem _E0 = _WIDEN(_Elem, '0');
  444. const _Mypunct& _Fac = _USE(_Loc, _Mypunct);
  445. const string _Grouping = _Fac.grouping();
  446. const _Elem _Kseparator = _Fac.thousands_sep();
  447. char *_Ptr = _Ac;
  448. if (_First == _Last)
  449. ; // empty field
  450. else if (*_First == _WIDEN(_Elem, '+'))
  451. *_Ptr++ = '+', ++_First; // gather plus sign
  452. else if (*_First == _WIDEN(_Elem, '-'))
  453. *_Ptr++ = '-', ++_First; // gather minus sign
  454. _Basefield &= ios_base::basefield;
  455. int _Base = _Basefield == ios_base::oct ? 8
  456. : _Basefield == ios_base::hex ? 16
  457. : _Basefield == ios_base::_Fmtzero ? 0 : 10;
  458. bool _Seendigit = false; // seen a digit in input
  459. bool _Nonzero = false; // seen a nonzero digit in input
  460. if (_First != _Last && *_First == _E0)
  461. { // leading zero, look for 0x, 0X
  462. _Seendigit = true, ++_First;
  463. if (_First != _Last && (*_First == _WIDEN(_Elem, 'x')
  464. || *_First == _WIDEN(_Elem, 'X'))
  465. && (_Base == 0 || _Base == 16))
  466. _Base = 16, _Seendigit = false, ++_First;
  467. else if (_Base == 0)
  468. _Base = 8;
  469. }
  470. int _Dlen = _Base == 0 || _Base == 10 ? 10
  471. : _Base == 8 ? 8 : 16 + 6;
  472. string _Groups((size_t)1, (char)_Seendigit);
  473. size_t _Group = 0;
  474. for (char *const _Pe = &_Ac[_MAX_INT_DIG - 1];
  475. _First != _Last; ++_First)
  476. if (::memchr("0123456789abcdefABCDEF",
  477. *_Ptr = _NARROW(_Elem, *_First), _Dlen) != 0)
  478. { // got a digit, characterize it and add to group size
  479. if ((_Nonzero || *_Ptr != '0') && _Ptr < _Pe)
  480. ++_Ptr, _Nonzero = true;
  481. _Seendigit = true;
  482. if (_Groups[_Group] != CHAR_MAX)
  483. ++_Groups[_Group];
  484. }
  485. else if (_Groups[_Group] == '\0'
  486. || _Kseparator == (_Elem)0
  487. || *_First != _Kseparator)
  488. break; // not a group separator, done
  489. else
  490. { // add a new group to _Groups string
  491. _Groups.append((string::size_type)1, '\0');
  492. ++_Group;
  493. }
  494. if (_Group == 0)
  495. ; // no thousands separators seen
  496. else if ('\0' < _Groups[_Group])
  497. ++_Group; // add trailing group to group count
  498. else
  499. _Seendigit = false; // trailing separator, fail
  500. for (const char *_Pg = _Grouping.c_str(); _Seendigit && 0 < _Group; )
  501. if (*_Pg == CHAR_MAX)
  502. break; // end of grouping constraints to check
  503. else if (0 < --_Group && *_Pg != _Groups[_Group]
  504. || 0 == _Group && *_Pg < _Groups[_Group])
  505. _Seendigit = false; // bad group size, fail
  506. else if ('\0' < _Pg[1])
  507. ++_Pg; // group size okay, advance to next test
  508. if (_Seendigit && !_Nonzero)
  509. *_Ptr++ = '0'; // zero field, replace stripped zero(s)
  510. else if (!_Seendigit)
  511. _Ptr = _Ac; // roll back pointer to indicate failure
  512. *_Ptr = '\0';
  513. return (_Base);
  514. }
  515. static int __cdecl _Getffld(char *_Ac, _InIt& _First, _InIt &_Last,
  516. const locale& _Loc)
  517. { // get floating-point field from [_First, _Last) into _Ac
  518. const _Elem _E0 = _WIDEN(_Elem, '0');
  519. const _Mypunct& _Fac = _USE(_Loc, _Mypunct);
  520. char *_Ptr = _Ac;
  521. if (_First == _Last)
  522. ; // empty field
  523. else if (*_First == _WIDEN(_Elem, '+'))
  524. *_Ptr++ = '+', ++_First; // gather plus sign
  525. else if (*_First == _WIDEN(_Elem, '-'))
  526. *_Ptr++ = '-', ++_First; // gather minus sign
  527. bool _Seendigit = false; // seen a digit in input
  528. for (; _First != _Last && *_First == _E0; _Seendigit = true, ++_First)
  529. ; // strip leading zeros
  530. if (_Seendigit)
  531. *_Ptr++ = '0'; // put one back
  532. int _Significant = 0; // number of significant digits
  533. int _Pten = 0; // power of 10 multiplier
  534. for (; _First != _Last
  535. && (::isdigit)(*_Ptr = _NARROW(_Elem, *_First));
  536. _Seendigit = true, ++_First)
  537. if (_Significant < _MAX_SIG_DIG)
  538. ++_Ptr, ++_Significant; // save a significant digit
  539. else
  540. ++_Pten; // or just scale by 10
  541. if (_First != _Last && *_First == _Fac.decimal_point())
  542. *_Ptr++ = localeconv()->decimal_point[0], ++_First; // add .
  543. if (_Significant == 0)
  544. { // 0000. so far
  545. for (; _First != _Last && *_First == _E0;
  546. _Seendigit = true, ++_First)
  547. --_Pten; // just count leading fraction zeros
  548. if (_Pten < 0)
  549. *_Ptr++ = '0', ++_Pten; // put one back
  550. }
  551. for (; _First != _Last
  552. && (::isdigit)(*_Ptr = _NARROW(_Elem, *_First));
  553. _Seendigit = true, ++_First)
  554. if (_Significant < _MAX_SIG_DIG)
  555. ++_Ptr, ++_Significant; // save a significant fraction digit
  556. if (_Seendigit && _First != _Last
  557. && (*_First == _WIDEN(_Elem, 'e')
  558. || *_First == _WIDEN(_Elem, 'E')))
  559. { // 'e' or 'E', collect exponent
  560. *_Ptr++ = 'e', ++_First;
  561. _Seendigit = false, _Significant = 0;
  562. if (_First == _Last)
  563. ; // 'e' or 'E' is last element
  564. else if (*_First == _WIDEN(_Elem, '+'))
  565. *_Ptr++ = '+', ++_First; // gather plus sign
  566. else if (*_First == _WIDEN(_Elem, '-'))
  567. *_Ptr++ = '-', ++_First; // gather minus sign
  568. for (; _First != _Last && *_First == _E0; )
  569. _Seendigit = true, ++_First; // strip leading zeros
  570. if (_Seendigit)
  571. *_Ptr++ = '0'; // put one back
  572. for (; _First != _Last
  573. && (::isdigit)(*_Ptr = _NARROW(_Elem, *_First));
  574. _Seendigit = true, ++_First)
  575. if (_Significant < _MAX_EXP_DIG)
  576. ++_Ptr, ++_Significant; // save a significant digit
  577. }
  578. if (!_Seendigit)
  579. _Ptr = _Ac; // roll back pointer to indicate failure
  580. *_Ptr = '\0';
  581. return (_Pten);
  582. };
  583. };
  584. // STATIC num_get::id OBJECT
  585. template<class _Elem,
  586. class _InIt>
  587. locale::id num_get<_Elem, _InIt>::id;
  588. // TEMPLATE CLASS num_put
  589. template<class _Elem,
  590. class _OutIt = ostreambuf_iterator<_Elem, char_traits<_Elem> > >
  591. class num_put
  592. : public locale::facet
  593. { // facet for converting encoded numbers to text
  594. public:
  595. typedef numpunct<_Elem> _Mypunct;
  596. typedef basic_string<_Elem, char_traits<_Elem>, allocator<_Elem> >
  597. _Mystr;
  598. static size_t __cdecl _Getcat(const locale::facet **_Ppf = 0)
  599. { // return locale category mask and construct standard facet
  600. if (_Ppf != 0 && *_Ppf == 0)
  601. *_Ppf = _NEW_CRT num_put<_Elem, _OutIt>;
  602. return (_X_NUMERIC);
  603. }
  604. static locale::id id; // unique facet id
  605. _PROTECTED:
  606. virtual ~num_put()
  607. { // destroy the object
  608. }
  609. protected:
  610. void _Init(const _Locinfo&)
  611. { // initialize from _Locinfo object (do nothing)
  612. }
  613. public:
  614. explicit num_put(size_t _Refs = 0)
  615. : locale::facet(_Refs)
  616. { // construct from current locale
  617. _Init(_Locinfo());
  618. }
  619. num_put(const _Locinfo& _Lobj, size_t _Refs = 0)
  620. : locale::facet(_Refs)
  621. { // construct from specified locale
  622. _Init(_Lobj);
  623. }
  624. typedef _Elem char_type;
  625. typedef _OutIt iter_type;
  626. _OutIt put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  627. _Bool _Val) const
  628. { // put formatted bool to _Dest
  629. return (do_put(_Dest, _Iosbase, _Fill, _Val));
  630. }
  631. _OutIt put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  632. long _Val) const
  633. { // put formatted long to _Dest
  634. return (do_put(_Dest, _Iosbase, _Fill, _Val));
  635. }
  636. _OutIt put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  637. unsigned long _Val) const
  638. { // put formatted unsigned long to _Dest
  639. return (do_put(_Dest, _Iosbase, _Fill, _Val));
  640. }
  641. #ifdef _LONGLONG
  642. _OutIt put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  643. _LONGLONG _Val) const
  644. { // put formatted long long to _Dest
  645. return (do_put(_Dest, _Iosbase, _Fill, _Val));
  646. }
  647. _OutIt put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  648. _ULONGLONG _Val) const
  649. { // put formatted unsigned long long to _Dest
  650. return (do_put(_Dest, _Iosbase, _Fill, _Val));
  651. }
  652. #endif /* _LONGLONG */
  653. _OutIt put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  654. double _Val) const
  655. { // put formatted double to _Dest
  656. return (do_put(_Dest, _Iosbase, _Fill, _Val));
  657. }
  658. _OutIt put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  659. long double _Val) const
  660. { // put formatted long double to _Dest
  661. return (do_put(_Dest, _Iosbase, _Fill, _Val));
  662. }
  663. _OutIt put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  664. const void *_Val) const
  665. { // put formatted void pointer to _Dest
  666. return (do_put(_Dest, _Iosbase, _Fill, _Val));
  667. }
  668. protected:
  669. virtual _OutIt do_put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  670. _Bool _Val) const
  671. { // put formatted bool to _Dest
  672. if (!(_Iosbase.flags() & ios_base::boolalpha))
  673. return (do_put(_Dest, _Iosbase, _Fill, (long)_Val));
  674. else
  675. { // put "false" or "true"
  676. const _Mypunct& _Fac = _USE(_Iosbase.getloc(), _Mypunct);
  677. const _Mystr _Str(_Val ? _Fac.truename() : _Fac.falsename());
  678. size_t _Fillcount = _Iosbase.width() <= 0
  679. || (size_t)_Iosbase.width() <= _Str.size()
  680. ? 0 : (size_t)_Iosbase.width() - _Str.size();
  681. if ((_Iosbase.flags() & ios_base::adjustfield) != ios_base::left)
  682. { // put leading fill
  683. _Dest = _Rep(_Dest, _Fill, _Fillcount);
  684. _Fillcount = 0;
  685. }
  686. _Dest = _Put(_Dest, _Str.c_str(), _Str.size()); // put field
  687. _Iosbase.width(0);
  688. return (_Rep(_Dest, _Fill, _Fillcount)); // put trailing fill
  689. }
  690. }
  691. virtual _OutIt do_put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  692. long _Val) const
  693. { // put formatted long to _Dest
  694. char _Buf[2 * _MAX_INT_DIG], _Fmt[6];
  695. return (_Iput(_Dest, _Iosbase, _Fill, _Buf,
  696. ::sprintf(_Buf, _Ifmt(_Fmt, "ld",
  697. _Iosbase.flags()), _Val)));
  698. }
  699. virtual _OutIt do_put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  700. unsigned long _Val) const
  701. { // put formatted unsigned long to _Dest
  702. char _Buf[2 * _MAX_INT_DIG], _Fmt[6];
  703. return (_Iput(_Dest, _Iosbase, _Fill, _Buf,
  704. ::sprintf(_Buf, _Ifmt(_Fmt, "lu",
  705. _Iosbase.flags()), _Val)));
  706. }
  707. #ifdef _LONGLONG
  708. virtual _OutIt do_put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  709. _LONGLONG _Val) const
  710. { // put formatted long long to _Dest
  711. char _Buf[2 * _MAX_INT_DIG], _Fmt[8];
  712. return (_Iput(_Dest, _Iosbase, _Fill, _Buf,
  713. ::sprintf(_Buf, _Ifmt(_Fmt, "Ld",
  714. _Iosbase.flags()), _Val)));
  715. }
  716. virtual _OutIt do_put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  717. _ULONGLONG _Val) const
  718. { // put formatted unsigned long long to _Dest
  719. char _Buf[2 * _MAX_INT_DIG], _Fmt[8];
  720. return (_Iput(_Dest, _Iosbase, _Fill, _Buf,
  721. ::sprintf(_Buf, _Ifmt(_Fmt, "Lu",
  722. _Iosbase.flags()), _Val)));
  723. }
  724. #endif /* _LONGLONG */
  725. virtual _OutIt do_put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  726. double _Val) const
  727. { // put formatted double to _Dest
  728. char _Buf[_MAX_EXP_DIG + _MAX_SIG_DIG + 64], _Fmt[8];
  729. streamsize _Precision = _Iosbase.precision() <= 0
  730. && !(_Iosbase.flags() & ios_base::fixed)
  731. ? 6 : _Iosbase.precision(); // desired precision
  732. int _Significance = _MAX_SIG_DIG < _Precision
  733. ? _MAX_SIG_DIG : (int)_Precision; // actual precision for sprintf
  734. _Precision -= _Significance;
  735. size_t _Beforepoint = 0; // zeros to add before decimal point
  736. size_t _Afterpoint = 0; // zeros to add after decimal point
  737. if ((_Iosbase.flags() & ios_base::floatfield) == ios_base::fixed)
  738. { // scale silly fixed-point value
  739. bool _Signed = _Val < 0;
  740. if (_Signed)
  741. _Val = -_Val;
  742. for (; 1e35 <= _Val && _Beforepoint < 5000; _Beforepoint += 10)
  743. _Val /= 1e10; // drop 10 zeros before decimal point
  744. if (0 < _Val)
  745. for (; 10 <= _Precision && _Val <= 1e-35
  746. && _Afterpoint < 5000; _Afterpoint += 10)
  747. { // drop 10 zeros after decimal point
  748. _Val *= 1e10;
  749. _Precision -= 10;
  750. }
  751. if (_Signed)
  752. _Val = -_Val;
  753. }
  754. return (_Fput(_Dest, _Iosbase, _Fill, _Buf,
  755. _Beforepoint, _Afterpoint, _Precision,
  756. ::sprintf(_Buf, _Ffmt(_Fmt, 0, _Iosbase.flags()),
  757. _Significance, _Val))); // convert and put
  758. }
  759. virtual _OutIt do_put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  760. long double _Val) const
  761. { // put formatted long double to _Dest
  762. char _Buf[_MAX_EXP_DIG + _MAX_SIG_DIG + 64], _Fmt[8];
  763. streamsize _Precision = _Iosbase.precision() <= 0
  764. && !(_Iosbase.flags() & ios_base::fixed)
  765. ? 6 : _Iosbase.precision(); // desired precision
  766. int _Significance = _MAX_SIG_DIG < _Precision
  767. ? _MAX_SIG_DIG : (int)_Precision; // actual precision for sprintf
  768. _Precision -= _Significance;
  769. size_t _Beforepoint = 0; // zeros to add before decimal point
  770. size_t _Afterpoint = 0; // zeros to add after decimal point
  771. if ((_Iosbase.flags() & ios_base::floatfield) == ios_base::fixed)
  772. { // scale silly fixed-point value
  773. bool _Signed = _Val < 0;
  774. if (_Signed)
  775. _Val = -_Val;
  776. for (; 1e35 <= _Val && _Beforepoint < 5000; _Beforepoint += 10)
  777. _Val /= 1e10; // drop 10 zeros before decimal point
  778. if (0 < _Val)
  779. for (; 10 <= _Precision && _Val <= 1e-35
  780. && _Afterpoint < 5000; _Afterpoint += 10)
  781. { // drop 10 zeros after decimal point
  782. _Val *= 1e10;
  783. _Precision -= 10;
  784. }
  785. if (_Signed)
  786. _Val = -_Val;
  787. }
  788. return (_Fput(_Dest, _Iosbase, _Fill, _Buf,
  789. _Beforepoint, _Afterpoint, _Precision,
  790. ::sprintf(_Buf, _Ffmt(_Fmt, 'L', _Iosbase.flags()),
  791. _Significance, _Val))); // convert and put
  792. }
  793. virtual _OutIt do_put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  794. const void *_Val) const
  795. { // put formatted void pointer to _Dest
  796. char _Buf[2 * _MAX_INT_DIG];
  797. return (_Iput(_Dest, _Iosbase, _Fill, _Buf,
  798. ::sprintf(_Buf, "%p", _Val)));
  799. }
  800. static char *__cdecl _Ffmt(char *_Fmt, char _Spec,
  801. ios_base::fmtflags _Flags)
  802. { // generate sprintf format for floating-point
  803. char *_Ptr = _Fmt;
  804. *_Ptr++ = '%';
  805. if (_Flags & ios_base::showpos)
  806. *_Ptr++ = '+';
  807. if (_Flags & ios_base::showpoint)
  808. *_Ptr++ = '#';
  809. *_Ptr++ = '.';
  810. *_Ptr++ = '*'; // for precision argument
  811. if (_Spec != '\0')
  812. *_Ptr++ = _Spec; // 'L' qualifier for long double only
  813. ios_base::fmtflags _Ffl = _Flags & ios_base::floatfield;
  814. *_Ptr++ = _Ffl == ios_base::fixed ? 'f'
  815. : _Ffl == ios_base::scientific ? 'e' : 'g'; // specifier
  816. *_Ptr = '\0';
  817. return (_Fmt);
  818. }
  819. static _OutIt __cdecl _Fput(_OutIt _Dest, ios_base& _Iosbase,
  820. _Elem _Fill, const char *_Buf,
  821. size_t _Beforepoint, size_t _Afterpoint,
  822. size_t _Trailing, size_t _Count)
  823. { // put formatted floating-point to _Dest
  824. _Elem _E0 = _WIDEN(_Elem, '0');
  825. size_t _Fillcount = _Beforepoint + _Afterpoint + _Trailing + _Count;
  826. _Fillcount = _Iosbase.width() <= 0
  827. || (size_t)_Iosbase.width() <= _Fillcount
  828. ? 0 : (size_t)_Iosbase.width() - _Fillcount;
  829. ios_base::fmtflags _Adjustfield =
  830. _Iosbase.flags() & ios_base::adjustfield;
  831. if (_Adjustfield != ios_base::left
  832. && _Adjustfield != ios_base::internal)
  833. { // put leading fill
  834. _Dest = _Rep(_Dest, _Fill, _Fillcount);
  835. _Fillcount = 0;
  836. }
  837. else if (_Adjustfield == ios_base::internal)
  838. { // put internal fill
  839. if (0 < _Count && (*_Buf == '+' || *_Buf == '-'))
  840. { // but first put sign
  841. _Dest = _Putc(_Dest, _Buf, 1);
  842. ++_Buf, --_Count;
  843. }
  844. _Dest = _Rep(_Dest, _Fill, _Fillcount);
  845. _Fillcount = 0;
  846. }
  847. const char *_Ptr = (const char *)::memchr(_Buf,
  848. localeconv()->decimal_point[0], _Count); // find decimal point
  849. if (_Ptr != 0)
  850. { // has decimal point, put pieces and zero fills
  851. const _Mypunct& _Fac = _USE(_Iosbase.getloc(), _Mypunct);
  852. size_t _Fracoffset = _Ptr - _Buf + 1;
  853. _Dest = _Putc(_Dest, _Buf, _Fracoffset - 1);
  854. _Dest = _Rep(_Dest, _E0, _Beforepoint);
  855. _Dest = _Rep(_Dest, _Fac.decimal_point(), 1);
  856. _Dest = _Rep(_Dest, _E0, _Afterpoint);
  857. _Buf += _Fracoffset, _Count -= _Fracoffset;
  858. }
  859. if ((_Ptr = (const char *)::memchr(_Buf, 'e', _Count)) != 0)
  860. { // has exponent field, put it out
  861. size_t _Expoffset = _Ptr - _Buf + 1;
  862. _Dest = _Putc(_Dest, _Buf, _Expoffset - 1);
  863. _Dest = _Rep(_Dest, _E0, _Trailing), _Trailing = 0;
  864. _Dest = _Putc(_Dest, _Iosbase.flags() & ios_base::uppercase
  865. ? "E" : "e", 1);
  866. _Buf += _Expoffset, _Count -= _Expoffset;
  867. }
  868. _Dest = _Putc(_Dest, _Buf, _Count); // put leftover field
  869. _Dest = _Rep(_Dest, _E0, _Trailing); // put trailing zeros
  870. _Iosbase.width(0);
  871. return (_Rep(_Dest, _Fill, _Fillcount)); // put trailing fill
  872. }
  873. static char *__cdecl _Ifmt(char *_Fmt, const char *_Spec,
  874. ios_base::fmtflags _Flags)
  875. { // generate sprintf format for integer
  876. char *_Ptr = _Fmt;
  877. *_Ptr++ = '%';
  878. if (_Flags & ios_base::showpos)
  879. *_Ptr++ = '+';
  880. if (_Flags & ios_base::showbase)
  881. *_Ptr++ = '#';
  882. if (_Spec[0] != 'L')
  883. *_Ptr++ = _Spec[0]; // qualifier
  884. else
  885. { /* change L to I64 */
  886. *_Ptr++ = 'I';
  887. *_Ptr++ = '6';
  888. *_Ptr++ = '4';
  889. }
  890. ios_base::fmtflags _Basefield = _Flags & ios_base::basefield;
  891. *_Ptr++ = _Basefield == ios_base::oct ? 'o'
  892. : _Basefield != ios_base::hex ? _Spec[1] // 'd' or 'u'
  893. : _Flags & ios_base::uppercase ? 'X' : 'x';
  894. *_Ptr = '\0';
  895. return (_Fmt);
  896. }
  897. static _OutIt __cdecl _Iput(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill,
  898. char *_Buf, size_t _Count)
  899. { // put formatted integer to _Dest
  900. const size_t _Prefix = *_Buf == '+' || *_Buf == '-' ? 1
  901. : *_Buf == '0' && (_Buf[1] == 'x' || _Buf[1] == 'X') ? 2
  902. : 0;
  903. const _Mypunct& _Fac = _USE(_Iosbase.getloc(), _Mypunct);
  904. const string _Grouping = _Fac.grouping();
  905. const _Elem _Kseparator = _Fac.thousands_sep();
  906. bool _Grouped = '\0' < *_Grouping.c_str();
  907. if (_Grouped)
  908. { // grouping specified, add thousands separators
  909. const char *_Pg = _Grouping.c_str();
  910. size_t _Off = _Count;
  911. for (_Grouped = false; *_Pg != CHAR_MAX && '\0' < *_Pg
  912. && (size_t)*_Pg < _Off - _Prefix; _Grouped = true)
  913. { // add a comma to mark thousands separator
  914. _Off -= *_Pg;
  915. ::memmove(&_Buf[_Off + 1], &_Buf[_Off],
  916. _Count + 1 - _Off);
  917. _Buf[_Off] = ',', ++_Count;
  918. if ('\0' < _Pg[1])
  919. ++_Pg; // not last group, advance
  920. }
  921. }
  922. size_t _Fillcount = _Iosbase.width() <= 0
  923. || (size_t)_Iosbase.width() <= _Count
  924. ? 0 : (size_t)_Iosbase.width() - _Count;
  925. ios_base::fmtflags _Adjustfield =
  926. _Iosbase.flags() & ios_base::adjustfield;
  927. if (_Adjustfield != ios_base::left
  928. && _Adjustfield != ios_base::internal)
  929. { // put leading fill
  930. _Dest = _Rep(_Dest, _Fill, _Fillcount);
  931. _Fillcount = 0;
  932. }
  933. else if (_Adjustfield == ios_base::internal)
  934. { // put internal fill
  935. _Dest = _Putc(_Dest, _Buf, _Prefix); // but first put prefix
  936. _Buf += _Prefix, _Count -= _Prefix;
  937. _Dest = _Rep(_Dest, _Fill, _Fillcount), _Fillcount = 0;
  938. }
  939. if (!_Grouped)
  940. _Dest = _Putc(_Dest, _Buf, _Count); // put field
  941. else
  942. for (; ; ++_Buf, --_Count)
  943. { // put field with thousands separators for commas
  944. size_t _Groupsize = strcspn(_Buf, ",");
  945. _Dest = _Putc(_Dest, _Buf, _Groupsize);
  946. _Buf += _Groupsize, _Count -= _Groupsize;
  947. if (_Count == 0)
  948. break;
  949. if (_Kseparator != (_Elem)0)
  950. _Dest = _Rep(_Dest, _Kseparator, 1);
  951. }
  952. _Iosbase.width(0);
  953. return (_Rep(_Dest, _Fill, _Fillcount)); // put trailing fill
  954. }
  955. static _OutIt __cdecl _Put(_OutIt _Dest, const _Elem *_Ptr, size_t _Count)
  956. { // put [_Ptr, _Ptr + _Count) to _Dest
  957. for (; 0 < _Count; --_Count, ++_Dest, ++_Ptr)
  958. *_Dest = *_Ptr;
  959. return (_Dest);
  960. }
  961. static _OutIt __cdecl _Putc(_OutIt _Dest, const char *_Ptr, size_t _Count)
  962. { // put char sequence [_Ptr, _Ptr + _Count) to _Dest
  963. for (; 0 < _Count; --_Count, ++_Dest, ++_Ptr)
  964. *_Dest = _WIDEN(_Elem, *_Ptr);
  965. return (_Dest);
  966. }
  967. static _OutIt __cdecl _Rep(_OutIt _Dest, _Elem _Ch, size_t _Count)
  968. { // put _Count * _Ch to _Dest
  969. for (; 0 < _Count; --_Count, ++_Dest)
  970. *_Dest = _Ch;
  971. return (_Dest);
  972. }
  973. };
  974. // STATIC num_put::id OBJECT
  975. template<class _Elem,
  976. class _OutIt>
  977. locale::id num_put<_Elem, _OutIt>::id;
  978. #ifdef _DLL_CPPLIB
  979. #ifdef __FORCE_INSTANCE
  980. template class _CRTIMP2 numpunct<char>;
  981. template class _CRTIMP2 numpunct<wchar_t>;
  982. #ifdef _CRTBLD_NATIVE_WCHAR_T
  983. template class _CRTIMP2 numpunct<unsigned short>;
  984. #endif
  985. template class _CRTIMP2 num_get<char,
  986. istreambuf_iterator<char, char_traits<char> > >;
  987. template class _CRTIMP2 num_get<wchar_t,
  988. istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
  989. #ifdef _CRTBLD_NATIVE_WCHAR_T
  990. template class _CRTIMP2 num_get<unsigned short,
  991. istreambuf_iterator<unsigned short, char_traits<unsigned short> > >;
  992. #endif
  993. template class _CRTIMP2 num_put<char,
  994. ostreambuf_iterator<char, char_traits<char> > >;
  995. template class _CRTIMP2 num_put<wchar_t,
  996. ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
  997. #ifdef _CRTBLD_NATIVE_WCHAR_T
  998. template class _CRTIMP2 num_put<unsigned short,
  999. ostreambuf_iterator<unsigned short, char_traits<unsigned short> > >;
  1000. #endif
  1001. #endif // __FORCE_INSTANCE
  1002. #endif // _DLL_CPPLIB
  1003. _STD_END
  1004. #pragma warning(pop)
  1005. #pragma pack(pop)
  1006. #endif /* _XLOCNUM_ */
  1007. /*
  1008. * Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
  1009. * Consult your license regarding permissions and restrictions.
  1010. V3.10:0009 */