ReactOS  0.4.14-dev-49-gfb4591c
_num_put.c File Reference
#include <stl/_num_put.h>
#include <stl/_limits.h>
Include dependency graph for _num_put.c:

Go to the source code of this file.

Macros

#define _STLP_NUM_PUT_C
 

Typedefs

typedef long __max_int_t
 
typedef unsigned long __umax_int_t
 

Functions

template<class _CharT , class _OutputIter >
_STLP_BEGIN_NAMESPACE _STLP_MOVE_TO_PRIV_NAMESPACE _OutputIter _STLP_CALL __copy_float_and_fill (const _CharT *__first, const _CharT *__last, _OutputIter __oi, ios_base::fmtflags __flags, streamsize __width, _CharT __fill, _CharT __xplus, _CharT __xminus)
 
template<class _OutputIter >
_OutputIter _STLP_CALL __put_float (__iostring &__str, _OutputIter __oi, ios_base &__f, wchar_t __fill, wchar_t __decimal_point, wchar_t __sep, size_t __group_pos, const string &__grouping)
 
template<class _OutputIter >
_OutputIter _STLP_CALL __put_float (__iostring &__str, _OutputIter __oi, ios_base &__f, char __fill, char __decimal_point, char __sep, size_t __group_pos, const string &__grouping)
 
template<class _CharT , class _OutputIter , class _Float >
_OutputIter _STLP_CALL __do_put_float (_OutputIter __s, ios_base &__f, _CharT __fill, _Float __x)
 
void __get_money_digits_aux (__iostring &__buf, ios_base &, _STLP_LONGEST_FLOAT_TYPE __x)
 
void __get_money_digits_aux (__iowstring &__wbuf, ios_base &__f, _STLP_LONGEST_FLOAT_TYPE __x)
 
template<class _CharT >
void _STLP_CALL __get_money_digits (_STLP_BASIC_IOSTRING(_CharT) &__buf, ios_base &__f, _STLP_LONGEST_FLOAT_TYPE __x)
 
template<class _CharT , class _OutputIter >
_OutputIter _STLP_CALL __copy_integer_and_fill (const _CharT *__buf, ptrdiff_t __len, _OutputIter __oi, ios_base::fmtflags __flg, streamsize __wid, _CharT __fill, _CharT __xplus, _CharT __xminus)
 
template<class _OutputIter >
_OutputIter _STLP_CALL __put_integer (char *__buf, char *__iend, _OutputIter __s, ios_base &__f, ios_base::fmtflags __flags, wchar_t __fill)
 
template<class _OutputIter >
_OutputIter _STLP_CALL __put_integer (char *__buf, char *__iend, _OutputIter __s, ios_base &__f, ios_base::fmtflags __flags, char __fill)
 
_STLP_DECLSPEC const char *_STLP_CALL __hex_char_table_lo ()
 
_STLP_DECLSPEC const char *_STLP_CALL __hex_char_table_hi ()
 
template<class _Integer >
char *_STLP_CALL __write_decimal_backward (char *__ptr, _Integer __x, ios_base::fmtflags __flags, const __true_type &)
 
template<class _Integer >
char *_STLP_CALL __write_decimal_backward (char *__ptr, _Integer __x, ios_base::fmtflags __flags, const __false_type &)
 
template<class _Integer >
char *_STLP_CALL __write_integer_backward (char *__buf, ios_base::fmtflags __flags, _Integer __x)
 
template<class _CharT , class _OutputIter , class _Integer >
_OutputIter _STLP_CALL __do_put_integer (_OutputIter __s, ios_base &__f, _CharT __fill, _Integer __x)
 
template<class _CharT , class _OutputIter >
_OutputIter _STLP_CALL __do_put_bool (_OutputIter __s, ios_base &__f, _CharT __fill, bool __x)
 

Macro Definition Documentation

◆ _STLP_NUM_PUT_C

#define _STLP_NUM_PUT_C

Definition at line 19 of file _num_put.c.

Typedef Documentation

◆ __max_int_t

typedef long __max_int_t

Definition at line 267 of file _num_put.c.

◆ __umax_int_t

typedef unsigned long __umax_int_t

Definition at line 268 of file _num_put.c.

Function Documentation

◆ __copy_float_and_fill()

template<class _CharT , class _OutputIter >
_STLP_BEGIN_NAMESPACE _STLP_MOVE_TO_PRIV_NAMESPACE _OutputIter _STLP_CALL __copy_float_and_fill ( const _CharT *  __first,
const _CharT *  __last,
_OutputIter  __oi,
ios_base::fmtflags  __flags,
streamsize  __width,
_CharT  __fill,
_CharT  __xplus,
_CharT  __xminus 
)

Definition at line 42 of file _num_put.c.

46  {
47  if (__width <= __last - __first)
48  return _STLP_STD::copy(__first, __last, __oi);
49  else {
50  streamsize __pad = __width - (__last - __first);
51  ios_base::fmtflags __dir = __flags & ios_base::adjustfield;
52 
53  if (__dir == ios_base::left) {
54  __oi = _STLP_STD::copy(__first, __last, __oi);
55  return _STLP_PRIV __fill_n(__oi, __pad, __fill);
56  }
57  else if (__dir == ios_base::internal && __first != __last &&
58  (*__first == __xplus || *__first == __xminus)) {
59  *__oi++ = *__first++;
60  __oi = _STLP_PRIV __fill_n(__oi, __pad, __fill);
61  return _STLP_STD::copy(__first, __last, __oi);
62  }
63  else {
64  __oi = _STLP_PRIV __fill_n(__oi, __pad, __fill);
65  return _STLP_STD::copy(__first, __last, __oi);
66  }
67  }
68 }
_STLP_MOVE_TO_PRIV_NAMESPACE _STLP_INLINE_LOOP _OutputIter __fill_n(_OutputIter __first, _Size __n, const _Tp &__val)
Definition: _algobase.h:478
_STLP_INLINE_LOOP _InputIter __last
Definition: _algo.h:68
GLint left
Definition: glext.h:7726
#define _STLP_PRIV
Definition: _dm.h:70
int fmtflags
Definition: _ios_base.h:57
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
ios_base &_STLP_CALL internal(ios_base &__s)
Definition: _ios_base.h:311
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, const input_iterator_tag &, _Distance *)
Definition: _algobase.h:417
ptrdiff_t streamsize
Definition: char_traits.h:81

Referenced by __put_float().

◆ __copy_integer_and_fill()

template<class _CharT , class _OutputIter >
_OutputIter _STLP_CALL __copy_integer_and_fill ( const _CharT *  __buf,
ptrdiff_t  __len,
_OutputIter  __oi,
ios_base::fmtflags  __flg,
streamsize  __wid,
_CharT  __fill,
_CharT  __xplus,
_CharT  __xminus 
)

Definition at line 148 of file _num_put.c.

151  {
152  if (__len >= __wid)
153  return _STLP_STD::copy(__buf, __buf + __len, __oi);
154  else {
155  //casting numeric_limits<ptrdiff_t>::max to streamsize only works is ptrdiff_t is signed or streamsize representation
156  //is larger than ptrdiff_t one.
157  _STLP_STATIC_ASSERT((sizeof(streamsize) > sizeof(ptrdiff_t)) ||
160  __STATIC_CAST(streamsize, __wid - __len)));
161  ios_base::fmtflags __dir = __flg & ios_base::adjustfield;
162 
163  if (__dir == ios_base::left) {
164  __oi = _STLP_STD::copy(__buf, __buf + __len, __oi);
165  return _STLP_PRIV __fill_n(__oi, __pad, __fill);
166  }
167  else if (__dir == ios_base::internal && __len != 0 &&
168  (__buf[0] == __xplus || __buf[0] == __xminus)) {
169  *__oi++ = __buf[0];
170  __oi = __fill_n(__oi, __pad, __fill);
171  return _STLP_STD::copy(__buf + 1, __buf + __len, __oi);
172  }
173  else if (__dir == ios_base::internal && __len >= 2 &&
174  (__flg & ios_base::showbase) &&
175  (__flg & ios_base::basefield) == ios_base::hex) {
176  *__oi++ = __buf[0];
177  *__oi++ = __buf[1];
178  __oi = __fill_n(__oi, __pad, __fill);
179  return _STLP_STD::copy(__buf + 2, __buf + __len, __oi);
180  }
181  else {
182  __oi = __fill_n(__oi, __pad, __fill);
183  return _STLP_STD::copy(__buf, __buf + __len, __oi);
184  }
185  }
186 }
ios_base &_STLP_CALL showbase(ios_base &__s)
Definition: _ios_base.h:273
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
_STLP_MOVE_TO_PRIV_NAMESPACE _STLP_INLINE_LOOP _OutputIter __fill_n(_OutputIter __first, _Size __n, const _Tp &__val)
Definition: _algobase.h:478
static const char hex[16]
Definition: profile.c:123
_STLP_STATIC_ASSERT(sizeof(nl_catd_type)<=sizeof(int)) class _STLP_CLASS_DECLSPEC _Catalog_nl_catd_map
GLint left
Definition: glext.h:7726
#define _STLP_PRIV
Definition: _dm.h:70
int fmtflags
Definition: _ios_base.h:57
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
#define min(a, b)
Definition: monoChain.cc:55
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
ios_base &_STLP_CALL internal(ios_base &__s)
Definition: _ios_base.h:311
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, const input_iterator_tag &, _Distance *)
Definition: _algobase.h:417
ptrdiff_t streamsize
Definition: char_traits.h:81

Referenced by __put_integer().

◆ __do_put_bool()

template<class _CharT , class _OutputIter >
_OutputIter _STLP_CALL __do_put_bool ( _OutputIter  __s,
ios_base __f,
_CharT  __fill,
bool  __x 
)

Definition at line 386 of file _num_put.c.

386  {
387  const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__f.getloc());
388 
389  basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > __str = __x ? __np.truename() : __np.falsename();
390 
391  streamsize __wid = __f.width(0);
392  if (__str.size() >= __STATIC_CAST(size_t, __wid))
393  return _STLP_STD::copy(__str.begin(), __str.end(), __s);
394  else {
395  streamsize __pad = __wid - __str.size();
396  ios_base::fmtflags __dir = __f.flags() & ios_base::adjustfield;
397 
398  if (__dir == ios_base::left) {
399  __s = _STLP_STD::copy(__str.begin(), __str.end(), __s);
400  return __fill_n(__s, __pad, __fill);
401  }
402  else /* covers right and internal padding */ {
403  __s = __fill_n(__s, __pad, __fill);
404  return _STLP_STD::copy(__str.begin(), __str.end(), __s);
405  }
406  }
407 }
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
locale getloc() const
Definition: _ios_base.h:143
_STLP_MOVE_TO_PRIV_NAMESPACE _STLP_INLINE_LOOP _OutputIter __fill_n(_OutputIter __first, _Size __n, const _Tp &__val)
Definition: _algobase.h:478
fmtflags flags() const
Definition: _ios_base.h:107
GLint left
Definition: glext.h:7726
streamsize width() const
Definition: _ios_base.h:134
int fmtflags
Definition: _ios_base.h:57
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, const input_iterator_tag &, _Distance *)
Definition: _algobase.h:417
ptrdiff_t streamsize
Definition: char_traits.h:81

Referenced by num_put< _CharT, _OutputIter >::do_put().

◆ __do_put_float()

template<class _CharT , class _OutputIter , class _Float >
_OutputIter _STLP_CALL __do_put_float ( _OutputIter  __s,
ios_base __f,
_CharT  __fill,
_Float  __x 
)

Definition at line 115 of file _num_put.c.

116  {
117  __iostring __buf;
118 
119  size_t __group_pos = __write_float(__buf, __f.flags(), (int)__f.precision(), __x);
120 
121  const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__f.getloc());
122  return __put_float(__buf, __s, __f, __fill,
123  __np.decimal_point(), __np.thousands_sep(),
124  __group_pos, __np.grouping());
125 }
streamsize precision() const
Definition: _ios_base.h:127
locale getloc() const
Definition: _ios_base.h:143
fmtflags flags() const
Definition: _ios_base.h:107
_OutputIter _STLP_CALL __put_float(__iostring &__str, _OutputIter __oi, ios_base &__f, wchar_t __fill, wchar_t __decimal_point, wchar_t __sep, size_t __group_pos, const string &__grouping)
Definition: _num_put.c:74
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, const input_iterator_tag &, _Distance *)
Definition: _algobase.h:417
size_t _STLP_CALL __write_float(__iostring &buf, ios_base::fmtflags flags, int precision, double x)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by num_put< _CharT, _OutputIter >::do_put().

◆ __do_put_integer()

template<class _CharT , class _OutputIter , class _Integer >
_OutputIter _STLP_CALL __do_put_integer ( _OutputIter  __s,
ios_base __f,
_CharT  __fill,
_Integer  __x 
)

Definition at line 372 of file _num_put.c.

372  {
373  // buffer size = number of bytes * number of digit necessary in the smallest Standard base (base 8, 3 digits/byte)
374  // plus the longest base representation '0x'
375  // Do not use __buf_size to define __buf static buffer, some compilers (HP aCC) do not accept const variable as
376  // the specification of a static buffer size.
377  char __buf[sizeof(_Integer) * 3 + 2];
378  const ptrdiff_t __buf_size = sizeof(__buf) / sizeof(char);
379  ios_base::fmtflags __flags = __f.flags();
380  char* __ibeg = __write_integer_backward((char*)__buf + __buf_size, __flags, __x);
381  return __put_integer(__ibeg, (char*)__buf + __buf_size, __s, __f, __flags, __fill);
382 }
fmtflags flags() const
Definition: _ios_base.h:107
char *_STLP_CALL __write_integer_backward(char *__buf, ios_base::fmtflags __flags, _Integer __x)
Definition: _num_put.c:304
_OutputIter _STLP_CALL __put_integer(char *__buf, char *__iend, _OutputIter __s, ios_base &__f, ios_base::fmtflags __flags, wchar_t __fill)
Definition: _num_put.c:192
int fmtflags
Definition: _ios_base.h:57
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, const input_iterator_tag &, _Distance *)
Definition: _algobase.h:417

Referenced by num_put< _CharT, _OutputIter >::do_put().

◆ __get_money_digits()

template<class _CharT >
void _STLP_CALL __get_money_digits ( _STLP_BASIC_IOSTRING(_CharT) &  __buf,
ios_base __f,
_STLP_LONGEST_FLOAT_TYPE  __x 
)

Definition at line 141 of file _num_put.c.

142 { __get_money_digits_aux(__buf, __f, __x); }
void __get_money_digits_aux(__iostring &__buf, ios_base &, _STLP_LONGEST_FLOAT_TYPE __x)
Definition: _num_put.c:127

Referenced by money_put< _CharT, _OutputIter >::do_put().

◆ __get_money_digits_aux() [1/2]

void __get_money_digits_aux ( __iostring __buf,
ios_base ,
_STLP_LONGEST_FLOAT_TYPE  __x 
)
inline

Definition at line 127 of file _num_put.c.

128 { __get_floor_digits(__buf, __x); }
void _STLP_CALL __get_floor_digits(__iostring &out, _STLP_LONGEST_FLOAT_TYPE __x)

Referenced by __get_money_digits().

◆ __get_money_digits_aux() [2/2]

void __get_money_digits_aux ( __iowstring __wbuf,
ios_base __f,
_STLP_LONGEST_FLOAT_TYPE  __x 
)
inline

Definition at line 131 of file _num_put.c.

131  {
132  __iostring __buf;
133  __get_floor_digits(__buf, __x);
134 
135  const ctype<wchar_t>& __ct = use_facet<ctype<wchar_t> >(__f.getloc());
136  __convert_float_buffer(__buf, __wbuf, __ct, wchar_t(0), false);
137 }
locale getloc() const
Definition: _ios_base.h:143
void _STLP_CALL __get_floor_digits(__iostring &out, _STLP_LONGEST_FLOAT_TYPE __x)
void _STLP_CALL __convert_float_buffer(__iostring const &str, __iowstring &out, const ctype< wchar_t > &ct, wchar_t dot, bool __check_dot)

◆ __hex_char_table_hi()

_STLP_DECLSPEC const char* _STLP_CALL __hex_char_table_hi ( )

Definition at line 121 of file num_put.cpp.

122 { return "0123456789ABCDEFX"; }

Referenced by __write_integer_backward(), and num_put< _CharT, _OutputIter >::do_put().

◆ __hex_char_table_lo()

_STLP_DECLSPEC const char* _STLP_CALL __hex_char_table_lo ( )

Definition at line 118 of file num_put.cpp.

119 { return "0123456789abcdefx"; }

Referenced by __write_integer_backward(), and num_put< _CharT, _OutputIter >::do_put().

◆ __put_float() [1/2]

template<class _OutputIter >
_OutputIter _STLP_CALL __put_float ( __iostring __str,
_OutputIter  __oi,
ios_base __f,
wchar_t  __fill,
wchar_t  __decimal_point,
wchar_t  __sep,
size_t  __group_pos,
const string __grouping 
)

Definition at line 74 of file _num_put.c.

77  {
78  const ctype<wchar_t>& __ct = use_facet<ctype<wchar_t> >(__f.getloc());
79 
80  __iowstring __wbuf;
81  __convert_float_buffer(__str, __wbuf, __ct, __decimal_point);
82 
83  if (!__grouping.empty()) {
84  __insert_grouping(__wbuf, __group_pos, __grouping,
85  __sep, __ct.widen('+'), __ct.widen('-'), 0);
86  }
87 
88  return __copy_float_and_fill(__wbuf.data(), __wbuf.data() + __wbuf.size(), __oi,
89  __f.flags(), __f.width(0), __fill, __ct.widen('+'), __ct.widen('-'));
90 }
ptrdiff_t _STLP_CALL __insert_grouping(char *first, char *last, const string &grouping, char separator, char Plus, char Minus, int basechars)
Definition: num_put.cpp:135
locale getloc() const
Definition: _ios_base.h:143
void _STLP_CALL __convert_float_buffer(__iostring const &str, __iowstring &out, const ctype< wchar_t > &ct, wchar_t dot, bool __check_dot)
fmtflags flags() const
Definition: _ios_base.h:107
streamsize width() const
Definition: _ios_base.h:134
wchar_t widen(char __c) const
Definition: _ctype.h:206
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, const input_iterator_tag &, _Distance *)
Definition: _algobase.h:417
_STLP_BEGIN_NAMESPACE _STLP_MOVE_TO_PRIV_NAMESPACE _OutputIter _STLP_CALL __copy_float_and_fill(const _CharT *__first, const _CharT *__last, _OutputIter __oi, ios_base::fmtflags __flags, streamsize __width, _CharT __fill, _CharT __xplus, _CharT __xminus)
Definition: _num_put.c:42

Referenced by __do_put_float().

◆ __put_float() [2/2]

template<class _OutputIter >
_OutputIter _STLP_CALL __put_float ( __iostring __str,
_OutputIter  __oi,
ios_base __f,
char  __fill,
char  __decimal_point,
char  __sep,
size_t  __group_pos,
const string __grouping 
)

Definition at line 96 of file _num_put.c.

99  {
100  if ((__group_pos < __str.size()) && (__str[__group_pos] == '.')) {
101  __str[__group_pos] = __decimal_point;
102  }
103 
104  if (!__grouping.empty()) {
105  __insert_grouping(__str, __group_pos,
106  __grouping, __sep, '+', '-', 0);
107  }
108 
109  return __copy_float_and_fill(__str.data(), __str.data() + __str.size(), __oi,
110  __f.flags(), __f.width(0), __fill, '+', '-');
111 }
ptrdiff_t _STLP_CALL __insert_grouping(char *first, char *last, const string &grouping, char separator, char Plus, char Minus, int basechars)
Definition: num_put.cpp:135
const _CharT * data() const
Definition: _string.h:950
size_type size() const
Definition: _string.h:400
fmtflags flags() const
Definition: _ios_base.h:107
streamsize width() const
Definition: _ios_base.h:134
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, const input_iterator_tag &, _Distance *)
Definition: _algobase.h:417
_STLP_BEGIN_NAMESPACE _STLP_MOVE_TO_PRIV_NAMESPACE _OutputIter _STLP_CALL __copy_float_and_fill(const _CharT *__first, const _CharT *__last, _OutputIter __oi, ios_base::fmtflags __flags, streamsize __width, _CharT __fill, _CharT __xplus, _CharT __xminus)
Definition: _num_put.c:42

◆ __put_integer() [1/2]

template<class _OutputIter >
_OutputIter _STLP_CALL __put_integer ( char __buf,
char __iend,
_OutputIter  __s,
ios_base __f,
ios_base::fmtflags  __flags,
wchar_t  __fill 
)

Definition at line 192 of file _num_put.c.

194  {
195  locale __loc = __f.getloc();
196  const ctype<wchar_t>& __ct = use_facet<ctype<wchar_t> >(__loc);
197 
198  wchar_t __xplus = __ct.widen('+');
199  wchar_t __xminus = __ct.widen('-');
200 
201  wchar_t __wbuf[64];
202  __ct.widen(__buf, __iend, __wbuf);
203  ptrdiff_t __len = __iend - __buf;
204  wchar_t* __eend = __wbuf + __len;
205 
206  const numpunct<wchar_t>& __np = use_facet<numpunct<wchar_t> >(__loc);
207  const string& __grouping = __np.grouping();
208 
209  if (!__grouping.empty()) {
210  int __basechars;
211  if (__flags & ios_base::showbase)
212  switch (__flags & ios_base::basefield) {
213  case ios_base::hex: __basechars = 2; break;
214  case ios_base::oct: __basechars = 1; break;
215  default: __basechars = 0;
216  }
217  else
218  __basechars = 0;
219 
220  __len = __insert_grouping(__wbuf, __eend, __grouping, __np.thousands_sep(),
221  __xplus, __xminus, __basechars);
222  }
223 
224  return __copy_integer_and_fill((wchar_t*)__wbuf, __len, __s,
225  __flags, __f.width(0), __fill, __xplus, __xminus);
226 }
string grouping() const
Definition: _numpunct.h:87
ios_base &_STLP_CALL showbase(ios_base &__s)
Definition: _ios_base.h:273
ptrdiff_t _STLP_CALL __insert_grouping(char *first, char *last, const string &grouping, char separator, char Plus, char Minus, int basechars)
Definition: num_put.cpp:135
locale getloc() const
Definition: _ios_base.h:143
wchar_t thousands_sep() const
Definition: _numpunct.h:86
static const char hex[16]
Definition: profile.c:123
Definition: _locale.h:75
_OutputIter _STLP_CALL __copy_integer_and_fill(const _CharT *__buf, ptrdiff_t __len, _OutputIter __oi, ios_base::fmtflags __flg, streamsize __wid, _CharT __fill, _CharT __xplus, _CharT __xminus)
Definition: _num_put.c:148
streamsize width() const
Definition: _ios_base.h:134
wchar_t widen(char __c) const
Definition: _ctype.h:206
ios_base &_STLP_CALL oct(ios_base &__s)
Definition: _ios_base.h:327
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, const input_iterator_tag &, _Distance *)
Definition: _algobase.h:417

Referenced by __do_put_integer().

◆ __put_integer() [2/2]

template<class _OutputIter >
_OutputIter _STLP_CALL __put_integer ( char __buf,
char __iend,
_OutputIter  __s,
ios_base __f,
ios_base::fmtflags  __flags,
char  __fill 
)

Definition at line 232 of file _num_put.c.

233  {
234  char __grpbuf[64];
235  ptrdiff_t __len = __iend - __buf;
236 
237  const numpunct<char>& __np = use_facet<numpunct<char> >(__f.getloc());
238  const string& __grouping = __np.grouping();
239 
240  if (!__grouping.empty()) {
241  int __basechars;
242  if (__flags & ios_base::showbase)
243  switch (__flags & ios_base::basefield) {
244  case ios_base::hex: __basechars = 2; break;
245  case ios_base::oct: __basechars = 1; break;
246  default: __basechars = 0;
247  }
248  else
249  __basechars = 0;
250 
251  // make sure there is room at the end of the buffer
252  // we pass to __insert_grouping
253  _STLP_STD::copy(__buf, __iend, (char *) __grpbuf);
254  __buf = __grpbuf;
255  __iend = __grpbuf + __len;
256  __len = __insert_grouping(__buf, __iend, __grouping, __np.thousands_sep(),
257  '+', '-', __basechars);
258  }
259 
260  return __copy_integer_and_fill(__buf, __len, __s, __flags, __f.width(0), __fill, '+', '-');
261 }
ios_base &_STLP_CALL showbase(ios_base &__s)
Definition: _ios_base.h:273
ptrdiff_t _STLP_CALL __insert_grouping(char *first, char *last, const string &grouping, char separator, char Plus, char Minus, int basechars)
Definition: num_put.cpp:135
locale getloc() const
Definition: _ios_base.h:143
static const char hex[16]
Definition: profile.c:123
_OutputIter _STLP_CALL __copy_integer_and_fill(const _CharT *__buf, ptrdiff_t __len, _OutputIter __oi, ios_base::fmtflags __flg, streamsize __wid, _CharT __fill, _CharT __xplus, _CharT __xminus)
Definition: _num_put.c:148
string grouping() const
Definition: _numpunct.h:58
char thousands_sep() const
Definition: _numpunct.h:57
streamsize width() const
Definition: _ios_base.h:134
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
ios_base &_STLP_CALL oct(ios_base &__s)
Definition: _ios_base.h:327
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, const input_iterator_tag &, _Distance *)
Definition: _algobase.h:417

◆ __write_decimal_backward() [1/2]

template<class _Integer >
char* _STLP_CALL __write_decimal_backward ( char __ptr,
_Integer  __x,
ios_base::fmtflags  __flags,
const __true_type  
)
inline

Definition at line 276 of file _num_put.c.

276  {
277  const bool __negative = __x < 0 ;
278  __max_int_t __temp = __x;
279  __umax_int_t __utemp = __negative?-__temp:__temp;
280 
281  for (; __utemp != 0; __utemp /= 10)
282  *--__ptr = (char)((int)(__utemp % 10) + '0');
283  // put sign if needed or requested
284  if (__negative)
285  *--__ptr = '-';
286  else if (__flags & ios_base::showpos)
287  *--__ptr = '+';
288  return __ptr;
289 }
unsigned long __umax_int_t
Definition: _num_put.c:268
long __max_int_t
Definition: _num_put.c:267
ios_base &_STLP_CALL showpos(ios_base &__s)
Definition: _ios_base.h:285
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by __write_integer_backward().

◆ __write_decimal_backward() [2/2]

template<class _Integer >
char* _STLP_CALL __write_decimal_backward ( char __ptr,
_Integer  __x,
ios_base::fmtflags  __flags,
const __false_type  
)
inline

Definition at line 293 of file _num_put.c.

293  {
294  for (; __x != 0; __x /= 10)
295  *--__ptr = (char)((int)(__x % 10) + '0');
296  // put sign if requested
297  if (__flags & ios_base::showpos)
298  *--__ptr = '+';
299  return __ptr;
300 }
ios_base &_STLP_CALL showpos(ios_base &__s)
Definition: _ios_base.h:285
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ __write_integer_backward()

template<class _Integer >
char* _STLP_CALL __write_integer_backward ( char __buf,
ios_base::fmtflags  __flags,
_Integer  __x 
)

Definition at line 304 of file _num_put.c.

304  {
305  char* __ptr = __buf;
306 
307  if (__x == 0) {
308  *--__ptr = '0';
309  if ((__flags & ios_base::showpos) && ((__flags & (ios_base::oct | ios_base::hex)) == 0))
310  *--__ptr = '+';
311  // oct or hex base shall not be added to the 0 value (see '#' flag in C formating strings)
312  }
313  else {
314  switch (__flags & ios_base::basefield) {
315  case ios_base::oct:
316  {
317  __umax_int_t __temp = __x;
318  // if the size of integer is less than 8, clear upper part
319  if ( sizeof(__x) < 8 && sizeof(__umax_int_t) >= 8 )
320  __temp &= 0xFFFFFFFF;
321 
322  for (; __temp != 0; __temp >>=3)
323  *--__ptr = (char)((((unsigned)__temp)& 0x7) + '0');
324 
325  // put leading '0' if showbase is set
326  if (__flags & ios_base::showbase)
327  *--__ptr = '0';
328  }
329  break;
330  case ios_base::hex:
331  {
332  const char* __table_ptr = (__flags & ios_base::uppercase) ?
334  __umax_int_t __temp = __x;
335  // if the size of integer is less than 8, clear upper part
336  if ( sizeof(__x) < 8 && sizeof(__umax_int_t) >= 8 )
337  __temp &= 0xFFFFFFFF;
338 
339  for (; __temp != 0; __temp >>=4)
340  *--__ptr = __table_ptr[((unsigned)__temp & 0xF)];
341 
342  if (__flags & ios_base::showbase) {
343  *--__ptr = __table_ptr[16];
344  *--__ptr = '0';
345  }
346  }
347  break;
348  //case ios_base::dec:
349  default:
350  {
351 #if defined(__HP_aCC) && (__HP_aCC == 1)
352  bool _IsSigned = !((_Integer)-1 > 0);
353  if (_IsSigned)
354  __ptr = __write_decimal_backward(__ptr, __x, __flags, __true_type() );
355  else
356  __ptr = __write_decimal_backward(__ptr, __x, __flags, __false_type() );
357 #else
358  typedef typename __bool2type<numeric_limits<_Integer>::is_signed>::_Ret _IsSigned;
359  __ptr = __write_decimal_backward(__ptr, __x, __flags, _IsSigned());
360 #endif
361  }
362  break;
363  }
364  }
365 
366  // return pointer to beginning of the string
367  return __ptr;
368 }
unsigned long __umax_int_t
Definition: _num_put.c:268
ios_base &_STLP_CALL showbase(ios_base &__s)
Definition: _ios_base.h:273
static const char hex[16]
Definition: profile.c:123
ios_base &_STLP_CALL uppercase(ios_base &__s)
Definition: _ios_base.h:297
_STLP_DECLSPEC const char *_STLP_CALL __hex_char_table_hi()
Definition: num_put.cpp:121
_STLP_DECLSPEC const char *_STLP_CALL __hex_char_table_lo()
Definition: num_put.cpp:118
ios_base &_STLP_CALL showpos(ios_base &__s)
Definition: _ios_base.h:285
ios_base &_STLP_CALL oct(ios_base &__s)
Definition: _ios_base.h:327
char *_STLP_CALL __write_decimal_backward(char *__ptr, _Integer __x, ios_base::fmtflags __flags, const __true_type &)
Definition: _num_put.c:276

Referenced by __do_put_integer(), and __write_integer().