本文整理汇总了C++中std::stringstream::fill方法的典型用法代码示例。如果您正苦于以下问题:C++ stringstream::fill方法的具体用法?C++ stringstream::fill怎么用?C++ stringstream::fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::stringstream
的用法示例。
在下文中一共展示了stringstream::fill方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: jsonStringStream
//.........这里部分代码省略.........
else
s << "{ \"$ref\" : ";
s << '"' << valuestr() << "\", ";
if (format != TenGen)
s << "\"$id\" : ";
s << '"' << mongo::OID::from(valuestr() + valuestrsize()) << "\" ";
if (format == TenGen)
s << ')';
else
s << '}';
break;
}
case jstOID:
if (format == TenGen) {
s << "ObjectId( ";
} else {
s << "{ \"$oid\" : ";
}
s << '"' << __oid() << '"';
if (format == TenGen) {
s << " )";
} else {
s << " }";
}
break;
case BinData: {
ConstDataCursor reader(value());
const int len = reader.readAndAdvance<LittleEndian<int>>();
BinDataType type = static_cast<BinDataType>(reader.readAndAdvance<uint8_t>());
s << "{ \"$binary\" : \"";
base64::encode(s, reader.view(), len);
auto origFill = s.fill();
auto origFmtF = s.flags();
auto origWidth = s.width();
auto guard = MakeGuard([&s, origFill, origFmtF, origWidth] {
s.fill(origFill);
s.setf(origFmtF);
s.width(origWidth);
});
s.setf(std::ios_base::hex, std::ios_base::basefield);
s << "\", \"$type\" : \"";
s.width(2);
s.fill('0');
s << type;
s << "\" }";
break;
}
case mongo::Date:
if (format == Strict) {
Date_t d = date();
s << "{ \"$date\" : ";
// The two cases in which we cannot convert Date_t::millis to an ISO Date string are
// when the date is too large to format (SERVER-13760), and when the date is before
// the epoch (SERVER-11273). Since Date_t internally stores millis as an unsigned
// long long, despite the fact that it is logically signed (SERVER-8573), this check
// handles both the case where Date_t::millis is too large, and the case where
// Date_t::millis is negative (before the epoch).
if (d.isFormattable()) {
s << "\"" << dateToISOStringLocal(date()) << "\"";
} else {
s << "{ \"$numberLong\" : \"" << d.toMillisSinceEpoch() << "\" }";
}