SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLIOReaderNative Class Reference

SLIOStream implementation for reading from native files. More...

#include <SLIONative.h>

Inheritance diagram for SLIOReaderNative:
[legend]

Public Member Functions

 SLIOReaderNative (std::string path)
 
size_t read (void *buffer, size_t size)
 
size_t tell ()
 
bool seek (size_t offset, Origin origin)
 
size_t size ()
 
- Public Member Functions inherited from SLIOStream
virtual ~SLIOStream ()=default
 
virtual size_t write (const void *buffer, size_t size)
 
virtual void flush ()
 

Private Attributes

std::ifstream _stream
 

Additional Inherited Members

- Public Types inherited from SLIOStream
enum  Origin { IOO_beg , IOO_cur , IOO_end }
 

Detailed Description

SLIOStream implementation for reading from native files.

Definition at line 18 of file SLIONative.h.

Constructor & Destructor Documentation

◆ SLIOReaderNative()

SLIOReaderNative::SLIOReaderNative ( std::string  path)

Definition at line 14 of file SLIONative.cpp.

15  : _stream(path, std::ios::binary)
16 {
17  //assert(!_stream.fail());
18 }
std::ifstream _stream
Definition: SLIONative.h:28

Member Function Documentation

◆ read()

size_t SLIOReaderNative::read ( void buffer,
size_t  size 
)
virtual

Reimplemented from SLIOStream.

Definition at line 20 of file SLIONative.cpp.

21 {
22  _stream.read((char*)buffer, (std::streamsize)size);
23  return _stream.gcount();
24 }

◆ seek()

bool SLIOReaderNative::seek ( size_t  offset,
Origin  origin 
)
virtual

Reimplemented from SLIOStream.

Definition at line 31 of file SLIONative.cpp.

32 {
33  std::ios::seekdir nativeOrigin = std::ios::beg;
34  if (origin == IOO_beg)
35  nativeOrigin = std::ios::beg;
36  else if (origin == IOO_cur)
37  nativeOrigin = std::ios::cur;
38  else if (origin == IOO_end)
39  nativeOrigin = std::ios::end;
40 
41  return (bool)_stream.seekg((std::streamsize)offset, nativeOrigin);
42 }

◆ size()

size_t SLIOReaderNative::size ( )
virtual

Reimplemented from SLIOStream.

Definition at line 44 of file SLIONative.cpp.

45 {
46  std::streamsize pos = _stream.tellg();
47  _stream.seekg(0, std::ios::end);
48  size_t size = (size_t)_stream.tellg();
49  _stream.seekg(pos, std::ios::beg);
50  return size;
51 }

◆ tell()

size_t SLIOReaderNative::tell ( )
virtual

Reimplemented from SLIOStream.

Definition at line 26 of file SLIONative.cpp.

27 {
28  return (size_t)_stream.tellg();
29 }

Member Data Documentation

◆ _stream

std::ifstream SLIOReaderNative::_stream
private

Definition at line 28 of file SLIONative.h.


The documentation for this class was generated from the following files: