Exemple #1
0
 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);
     }
Exemple #2
0
 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);
         }
     }
 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);
 }
 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));
 }
 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);
 }
 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));
 }