本文整理汇总了C++中stream_type::precision方法的典型用法代码示例。如果您正苦于以下问题:C++ stream_type::precision方法的具体用法?C++ stream_type::precision怎么用?C++ stream_type::precision使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stream_type
的用法示例。
在下文中一共展示了stream_type::precision方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
~local_precision() { pstream->precision(saved_prec); }
示例2: pstream
local_precision(stream_type& stream) : pstream(&stream), saved_prec(stream.precision()) {}
示例3: handle_atom
void asl_cel_format::handle_atom(stream_type& os, bool is_push) {
const format_element_t& top(stack_top());
name_t parent(stack_depth() >= 2 ? stack_n(1).tag() : name_t());
name_t grandparent(stack_depth() >= 3 ? stack_n(2).tag() : name_t());
const any_regular_t& value(top.value());
bool outputting_bag(parent == seq_name_g && grandparent == bag_name_g);
std::size_t& num_out(outputting_bag ? stack_n(2).num_out_m : stack_n(1).num_out_m);
bool named_argument(outputting_bag && (num_out & 0x1) == 0);
if (is_push) {
// if this is not the first item in the element, add a comma and set up a newline
if (num_out > 0) {
if (!outputting_bag) {
os << ", ";
} else if (named_argument) {
os << ",\n" << indents(depth());
}
} else if (outputting_bag) {
os << '\n' << indents(depth());
}
if (value.type_info() == typeid(string)) {
bool escape(needs_entity_escape(value.cast<string>()));
if (escape_m && escape)
os << "xml_unescape(";
os << '\"'
<< (escape_m && escape ? entity_escape(value.cast<string>()) : value.cast<string>())
<< '\"';
if (escape_m && escape)
os << ")";
} else if (value.type_info() == typeid(name_t)) {
if (!named_argument)
os << '@';
os << value.cast<name_t>();
if (outputting_bag && named_argument)
os << ": ";
} else if (value.type_info() == typeid(bool)) {
os << (value.cast<bool>() ? "true" : "false");
} else if (value.type_info() == typeid(double)) {
double dbl_val(value.cast<double>());
boost::int64_t int_val(static_cast<boost::int64_t>(dbl_val));
if (dbl_val == int_val) {
os << int_val;
} else {
// For asl_cel, we want to output floating-point values in decimal-based
// fixed-point notation (asl_cel doesn't support any other format) with
// a very high precision for accceptable roundtrip values.
os.setf(std::ios_base::dec, std::ios_base::basefield);
os.setf(std::ios_base::fixed, std::ios_base::floatfield);
os.precision(16);
os << dbl_val;
}
} else if (value.type_info() == typeid(empty_t)) {
os << value.cast<empty_t>();
} else if (value.type_info() == typeid(dictionary_t)) {
os << value.cast<dictionary_t>();
} else if (value.type_info() == typeid(array_t)) {
os << value.cast<array_t>();
} else {
os << "'" << value.type_info().name() << "'";
}
} else {
// up the number of outputted items for the parent to this atom
++num_out;
}
}
示例4: BasicIosFormatResetter
template<class C, class T> BasicIosFormatResetter<C,T>::
BasicIosFormatResetter(stream_type &s):
stream(s), orig_flags(s.flags()), orig_fill(s.fill()), orig_prec(s.precision()) {}
示例5: handle_atom
void pdf_format::handle_atom(stream_type& os, bool is_push)
{
const format_element_t& top(stack_top());
name_t self(top.tag());
name_t parent(stack_depth() >= 2 ? stack_n(1).tag() : name_t());
name_t grandparent(stack_depth() >= 3 ? stack_n(2).tag() : name_t());
const any_regular_t& value(top.value());
bool outputting_bag(parent == seq_name_g && grandparent == bag_name_g);
std::size_t& num_out(outputting_bag ? stack_n(2).num_out_m : stack_n(1).num_out_m);
bool named_argument(outputting_bag && num_out % 2 == 0);
if (is_push)
{
// if this is not the first item in the element, add a comma and set up a newline
if (num_out > 0)
{
if (!outputting_bag)
{
os << ' ';
}
else if (named_argument)
{
os << '\n' << indents(depth());
}
}
else if (outputting_bag)
{
os << '\n' << indents(depth());
}
if (value.type_info() == adobe::type_info<string_t>())
{
os << '(' << value.cast<string_t>() << ')';
}
else if (value.type_info() == adobe::type_info<name_t>())
{
os << '/' << value.cast<name_t>();
if (outputting_bag && named_argument)
os << " ";
}
else if (value.type_info() == adobe::type_info<bool>())
{
os << (value.cast<bool>() ? "true" : "false");
}
else if (value.type_info() == adobe::type_info<double>())
{
double dbl_val(value.cast<double>());
boost::int64_t int_val(static_cast<boost::int64_t>(dbl_val));
if (dbl_val == int_val)
{
os << int_val;
}
else
{
// For pdf, we want to output floating-point values in decimal-based
// fixed-point notation (asl_cel doesn't support any other format) with
// a very high precision for accceptable roundtrip values.
os.setf(std::ios_base::dec, std::ios_base::basefield);
os.setf(std::ios_base::fixed, std::ios_base::floatfield);
os.precision(16);
os << dbl_val;
}
}
else if (value.type_info() == adobe::type_info<empty_t>())
{
os << "null";
}
else if (value.type_info() == adobe::type_info<dictionary_t>())
{
os << value.cast<dictionary_t>();
}
else if (value.type_info() == adobe::type_info<array_t>())
{
os << value.cast<array_t>();
}
else
{
os << "(pdf_unknown: " << value.type_info().name() << ")";
}
}
else
{
// up the number of outputted items for the parent to this atom
++num_out;
}
}