本文整理汇总了C++中std::basic_ostream::good方法的典型用法代码示例。如果您正苦于以下问题:C++ basic_ostream::good方法的具体用法?C++ basic_ostream::good怎么用?C++ basic_ostream::good使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::basic_ostream
的用法示例。
在下文中一共展示了basic_ostream::good方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insert_fill_chars
inline void insert_fill_chars(std::basic_ostream<charT, traits>& os, std::size_t n) {
enum { chunk_size = 8 };
charT fill_chars[chunk_size];
std::fill_n(fill_chars, static_cast< std::size_t >(chunk_size), os.fill());
for (; n >= chunk_size && os.good(); n -= chunk_size)
os.write(fill_chars, static_cast< std::size_t >(chunk_size));
if (n > 0 && os.good())
os.write(fill_chars, n);
}
示例2: insert_aligned
void insert_aligned(std::basic_ostream<charT, traits>& os, const basic_string_ref<charT,traits>& str) {
const std::size_t size = str.size();
const std::size_t alignment_size = static_cast< std::size_t >(os.width()) - size;
const bool align_left = (os.flags() & std::basic_ostream<charT, traits>::adjustfield) == std::basic_ostream<charT, traits>::left;
if (!align_left) {
detail::insert_fill_chars(os, alignment_size);
if (os.good())
os.write(str.data(), size);
}
else {
os.write(str.data(), size);
if (os.good())
detail::insert_fill_chars(os, alignment_size);
}
}
示例3: write_info_internal
void write_info_internal(std::basic_ostream<typename Ptree::char_type> &stream,
const Ptree &pt,
const std::string &filename)
{
write_info_helper(stream, pt, -1);
if (!stream.good())
throw info_parser_error("write error", filename, 0);
}
示例4: write_info_internal
void write_info_internal(std::basic_ostream<typename Ptree::key_type::value_type> &stream,
const Ptree &pt,
const std::string &filename,
const info_writer_settings<typename Ptree::key_type::value_type> &settings)
{
write_info_helper(stream, pt, -1, settings);
if (!stream.good())
BOOST_PROPERTY_TREE_THROW(info_parser_error("write error", filename, 0));
}
示例5: write_json_internal
void write_json_internal(std::basic_ostream<typename Ptree::char_type> &stream,
const Ptree &pt,
const std::string &filename)
{
if (!verify_json(pt, 0))
throw json_parser_error("ptree contains data that cannot be represented in JSON format", filename, 0);
write_json_helper(stream, pt, 0);
stream << std::endl;
if (!stream.good())
throw json_parser_error("write error", filename, 0);
}
示例6: write_json_internal
void write_json_internal(std::basic_ostream<typename Ptree::key_type::value_type> &stream,
const Ptree &pt,
const std::string &filename,
bool pretty)
{
if (!verify_json(pt, 0))
BOOST_PROPERTY_TREE_THROW(json_parser_error("ptree contains data that cannot be represented in JSON format", filename, 0));
write_json_helper(stream, pt, 0, pretty);
stream << std::endl;
if (!stream.good())
BOOST_PROPERTY_TREE_THROW(json_parser_error("write error", filename, 0));
}