- Timestamp:
- 06/29/13 19:02:04 (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/io/std_stream.hh
r134 r138 16 16 #include <nv/interface/stream.hh> 17 17 #include <streambuf> 18 #include <istream> 18 19 #include <vector> 19 20 20 21 namespace nv 21 22 { 22 class std_stream : public std::streambuf 23 24 class std_streambuf : public std::streambuf 23 25 { 24 26 public: 25 explicit std_stream ( stream* source, bool owner = false, std::size_t bsize = 256, std::size_t put_back = 8 );26 ~std_stream();27 explicit std_streambuf( stream* source, bool owner = false, std::size_t bsize = 256, std::size_t put_back = 8 ); 28 virtual ~std_streambuf(); 27 29 protected: 28 30 stream* m_stream; … … 31 33 std::size_t m_put_back; 32 34 private: 33 std_stream ( const std_stream& ); // dissalow copy34 std_stream *operator =( const std_stream& ); // dissalow assign35 std_streambuf( const std_streambuf& ); // dissalow copy 36 std_streambuf *operator =( const std_streambuf& ); // dissalow assign 35 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; 36 49 }; 37 50 -
trunk/src/formats/obj_loader.cc
r136 r138 6 6 7 7 #include "nv/formats/obj_loader.hh" 8 #include "nv/io/std_stream.hh" 8 9 #include <sstream> 9 10 … … 187 188 m_mesh = new mesh(); 188 189 mesh_obj_reader reader( m_mesh ); 189 size_t size = source.size(); 190 char* data = new char[ size ]; 191 source.read( data, 1, size ); 192 std::string cache( data, size ); 193 std::istringstream sstream( cache ); 190 std_stream sstream( &source ); 194 191 reader.read_stream( sstream ); 195 192 m_size = reader.size; -
trunk/src/io/std_stream.cc
r135 r138 9 9 #include "nv/io/std_stream.hh" 10 10 #include <algorithm> 11 #include <cstring> // TODO: remove, see below12 11 13 12 using namespace nv; 14 13 15 std_stream ::std_stream( stream* source, bool owner /*= false*/, std::size_t bsize /*= 256*/, std::size_t put_back /*= 8 */ )14 std_streambuf::std_streambuf( stream* source, bool owner /*= false*/, std::size_t bsize /*= 256*/, std::size_t put_back /*= 8 */ ) 16 15 : m_stream( source ) 17 16 , m_owner( owner ) … … 23 22 } 24 23 25 std_stream ::~std_stream()24 std_streambuf::~std_streambuf() 26 25 { 27 26 if ( m_owner ) … … 31 30 } 32 31 33 std_stream ::int_type std_stream::underflow()32 std_streambuf::int_type std_streambuf::underflow() 34 33 { 35 34 if (gptr() < egptr()) … … 45 44 { 46 45 // Make arrangements for putback characters 47 // TODO: std::copy( egptr() - m_put_back, egptr(), base ); instead? 48 std::memmove(base, egptr() - m_put_back, m_put_back); 46 std::copy( egptr() - m_put_back, egptr(), base ); 49 47 start += m_put_back; 50 48 }
Note: See TracChangeset
for help on using the changeset viewer.