source: trunk/nv/io/std_stream.hh @ 319

Last change on this file since 319 was 319, checked in by epyon, 11 years ago
  • created core module and moved all free source files there
  • took the opportunity to update all copyright lines and minor cleanup
  • minor fixes
  • not all examples are up to date
File size: 1.4 KB
RevLine 
[319]1// Copyright (C) 2012-2014 ChaosForge Ltd
[134]2// http://chaosforge.org/
3//
4// This file is part of NV Libraries.
5// For conditions of distribution and use, see copyright notice in nv.hh
6/**
7 * @file std_stream.hh
8 * @author Kornel Kisielewicz epyon@chaosforge.org
9 * @brief stream adapter for usage with STL
10 */
11
12#ifndef NV_STD_STREAM_HH
13#define NV_STD_STREAM_HH
14
[319]15#include <nv/core/common.hh>
[134]16#include <nv/interface/stream.hh>
17#include <streambuf>
[138]18#include <istream>
[134]19#include <vector>
20
21namespace nv
22{
[138]23
24        class std_streambuf : public std::streambuf
[134]25        {
26        public:
[138]27                explicit std_streambuf( stream* source, bool owner = false, std::size_t bsize = 256, std::size_t put_back = 8 );
28                virtual ~std_streambuf();
[134]29        protected:
30                stream*           m_stream;
31                bool              m_owner;
32                std::vector<char> m_buffer;
33                std::size_t       m_put_back;
34        private:
[138]35                std_streambuf( const std_streambuf& );             // dissalow copy
36                std_streambuf *operator =( const std_streambuf& ); // dissalow assign
[134]37                int_type underflow();
38        };
39
[138]40        class std_stream : public std::istream
41        {
42        public:
43                explicit std_stream( stream* source, bool owner = false, std::size_t bsize = 256, std::size_t put_back = 8 )
44                        : std::istream( &m_streambuf )
45                        , m_streambuf( source, owner, bsize, put_back )
46                {}
47        private:
48                std_streambuf m_streambuf;
49        };
50
[134]51} // namespace nv
52
53#endif // NV_STD_STREAM_HH
Note: See TracBrowser for help on using the repository browser.