File indexing completed on 2025-01-18 09:38:50
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_IOSTREAMS_BACK_INSERTER_HPP_INCLUDED
0009 #define BOOST_IOSTREAMS_BACK_INSERTER_HPP_INCLUDED
0010
0011 #if defined(_MSC_VER)
0012 # pragma once
0013 #endif
0014
0015 #include <boost/iostreams/detail/ios.hpp> // streamsize.
0016 #include <boost/iostreams/categories.hpp>
0017
0018 namespace boost { namespace iostreams {
0019
0020 template<typename Container>
0021 class back_insert_device {
0022 public:
0023 typedef typename Container::value_type char_type;
0024 typedef sink_tag category;
0025 back_insert_device(Container& cnt) : container(&cnt) { }
0026 std::streamsize write(const char_type* s, std::streamsize n)
0027 {
0028 container->insert(container->end(), s, s + n);
0029 return n;
0030 }
0031 protected:
0032 Container* container;
0033 };
0034
0035 template<typename Container>
0036 back_insert_device<Container> back_inserter(Container& cnt)
0037 { return back_insert_device<Container>(cnt); }
0038
0039 } }
0040
0041 #endif