source: NonGTP/Boost/boost/iostreams/device/back_inserter.hpp @ 857

Revision 857, 1.2 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]1// (C) Copyright Jonathan Turkanis 2003.
2// Distributed under the Boost Software License, Version 1.0. (See accompanying
3// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
4
5// See http://www.boost.org/libs/iostreams for documentation.
6
7#ifndef BOOST_IOSTREAMS_BACK_INSERTER_HPP_INCLUDED
8#define BOOST_IOSTREAMS_BACK_INSERTER_HPP_INCLUDED
9
10#if defined(_MSC_VER) && (_MSC_VER >= 1020)
11# pragma once
12#endif
13
14#include <boost/iostreams/detail/ios.hpp> // streamsize.
15#include <boost/iostreams/categories.hpp>
16
17namespace boost { namespace iostreams {
18
19template<typename Container>
20class back_insert_device {
21public:
22    typedef typename Container::value_type  char_type;
23    typedef sink_tag                        category;
24    back_insert_device(Container& cnt) : container(&cnt) { }
25    std::streamsize write(const char_type* s, std::streamsize n)
26    {
27        container->insert(container->end(), s, s + n);
28        return n;
29    }
30protected:
31    Container* container;
32};
33
34template<typename Container>
35back_insert_device<Container> back_inserter(Container& cnt)
36{ return back_insert_device<Container>(cnt); }
37
38} } // End namespaces iostreams, boost.
39
40#endif // #ifndef BOOST_IOSTREAMS_BACK_INSERTER_HPP_INCLUDED
Note: See TracBrowser for help on using the repository browser.