source: trunk/legacy/std_stream.hh @ 537

Last change on this file since 537 was 442, checked in by epyon, 10 years ago
  • more std removal - only <random> left
File size: 1.4 KB
Line 
1// Copyright (C) 2012-2015 ChaosForge Ltd
2// http://chaosforge.org/
3//
4// This file is part of Nova libraries.
5// For conditions of distribution and use, see copying.txt file in root folder.
6
7/**
8 * @file std_stream.hh
9 * @author Kornel Kisielewicz epyon@chaosforge.org
10 * @brief stream adapter for usage with STL
11 */
12
13#ifndef NV_IO_STD_STREAM_HH
14#define NV_IO_STD_STREAM_HH
15
16#include <nv/common.hh>
17#include <nv/stl/stream.hh>
18#include <streambuf>
19#include <istream>
20#include <vector>
21
22namespace nv
23{
24
25        class std_streambuf : public std::streambuf
26        {
27        public:
28                explicit std_streambuf( stream* source, bool owner = false, std::size_t bsize = 256, std::size_t put_back = 8 );
29                virtual ~std_streambuf();
30        protected:
31                stream*           m_stream;
32                bool              m_owner;
33                std::vector<char> m_buffer;
34                std::size_t       m_put_back;
35        private:
36                std_streambuf( const std_streambuf& );             // dissalow copy
37                std_streambuf *operator =( const std_streambuf& ); // dissalow assign
38                int_type underflow();
39        };
40
41        class std_stream : public std::istream
42        {
43        public:
44                explicit std_stream( stream* source, bool owner = false, std::size_t bsize = 256, std::size_t put_back = 8 )
45                        : std::istream( &m_streambuf )
46                        , m_streambuf( source, owner, bsize, put_back )
47                {}
48        private:
49                std_streambuf m_streambuf;
50        };
51
52} // namespace nv
53
54#endif // NV_IO_STD_STREAM_HH
Note: See TracBrowser for help on using the repository browser.