Last change
on this file since 138 was
138,
checked in by epyon, 12 years ago
|
- io/std_stream - PROPER std_stream implementation
- io/std_stream - got rid of memmove
- formats/obj_loader - no copy on read, properly streamed
|
File size:
1.4 KB
|
Line | |
---|
1 | // Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
|
---|
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 |
|
---|
15 | #include <nv/common.hh>
|
---|
16 | #include <nv/interface/stream.hh>
|
---|
17 | #include <streambuf>
|
---|
18 | #include <istream>
|
---|
19 | #include <vector>
|
---|
20 |
|
---|
21 | namespace nv
|
---|
22 | {
|
---|
23 |
|
---|
24 | class std_streambuf : public std::streambuf
|
---|
25 | {
|
---|
26 | public:
|
---|
27 | explicit std_streambuf( stream* source, bool owner = false, std::size_t bsize = 256, std::size_t put_back = 8 );
|
---|
28 | virtual ~std_streambuf();
|
---|
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:
|
---|
35 | std_streambuf( const std_streambuf& ); // dissalow copy
|
---|
36 | std_streambuf *operator =( const std_streambuf& ); // dissalow assign
|
---|
37 | int_type underflow();
|
---|
38 | };
|
---|
39 |
|
---|
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 |
|
---|
51 | } // namespace nv
|
---|
52 |
|
---|
53 | #endif // NV_STD_STREAM_HH
|
---|
Note: See
TracBrowser
for help on using the repository browser.