本文整理汇总了C++中__iostring::append方法的典型用法代码示例。如果您正苦于以下问题:C++ __iostring::append方法的具体用法?C++ __iostring::append怎么用?C++ __iostring::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类__iostring
的用法示例。
在下文中一共展示了__iostring::append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __get_floor_digits
void _STLP_CALL __get_floor_digits(__iostring &out, _STLP_LONG_DOUBLE __x) {
#ifdef USE_SPRINTF_INSTEAD
char cvtbuf[128];
# ifndef _STLP_NO_LONG_DOUBLE
# ifndef N_PLAT_NLM
snprintf(ARRAY_AND_SIZE(cvtbuf), "%Lf", __x); // check for 1234.56!
# else
sprintf(cvtbuf, "%Lf", __x); // check for 1234.56!
# endif
# else
snprintf(ARRAY_AND_SIZE(cvtbuf), "%f", __x); // check for 1234.56!
# endif
char *p = strchr( cvtbuf, '.' );
if ( p == 0 ) {
out.append( cvtbuf );
} else {
out.append( cvtbuf, p );
}
#else
char cvtbuf[NDIG+2];
char * bp;
int decpt, sign;
#ifndef _STLP_NO_LONG_DOUBLE
bp = _Stl_qfcvtR(__x, 0, &decpt, &sign, cvtbuf);
#else
bp = _Stl_fcvtR(__x, 0, &decpt, &sign, cvtbuf);
#endif
if (sign) {
out += '-';
}
out.append(bp, bp + decpt);
#endif // USE_PRINTF_INSTEAD
}
示例2: __format_float_fixed
size_t __format_float_fixed(__iostring &buf, const char * bp,
int decpt, int sign, bool /* x */,
ios_base::fmtflags flags,
int precision, bool islong ) {
size_t __group_pos;
char static_buf[128];
int const BUF_SIZE = sizeof(static_buf) - 1;
char *sbuf = static_buf;
if (sign && decpt > -precision && *bp != 0)
*sbuf++ = '-';
else if (flags & ios_base::showpos)
*sbuf++ = '+';
int rzero = 0;
int nn = decpt;
int k = 0;
int maxfsig = islong ? 2*MAXFSIG : MAXFSIG;
do {
int nnn = (min) (nn, BUF_SIZE);
nn -= nnn;
do {
*sbuf++ = ((nnn <= 0 || *bp == 0 || k >= maxfsig) ?
'0' : (++k, *bp++));
} while (--nnn > 0);
buf.append(static_buf, sbuf);
sbuf = static_buf;
} while (nn != 0);
// decimal point if needed
__group_pos = buf.size() - 1;
if (flags & ios_base::showpoint || precision > 0) {
*sbuf++ = '.';
++__group_pos;
}
// digits after decimal point if any
nn = (min) (precision, MAXFCVT);
if (precision > nn)
rzero = precision - nn;
while (nn != 0) {
int nnn = (min) (nn, BUF_SIZE);
nn -= nnn;
while (--nnn >= 0) {
*sbuf++ = (++decpt <= 0 || *bp == 0 || k >= maxfsig) ?
'0' : (++k, *bp++);
}
buf.append(static_buf, sbuf);
sbuf = static_buf;
}
// trailing zeros if needed
while (rzero != 0) {
int nnn = (min) (rzero, BUF_SIZE);
rzero -= nnn;
while (nnn-- > 0) {
*sbuf++ = '0';
}
buf.append(static_buf, sbuf);
sbuf = static_buf;
}
return __group_pos;
}