Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:50

0001 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
0002 // (C) Copyright 2003-2007 Jonathan Turkanis
0003 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
0005 
0006 // See http://www.boost.org/libs/iostreams for documentation.
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 } } // End namespaces iostreams, boost.
0040 
0041 #endif // #ifndef BOOST_IOSTREAMS_BACK_INSERTER_HPP_INCLUDED