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

SLIOStream implementation for writing to native files. More...

#include <SLIONative.h>

Inheritance diagram for SLIOWriterNative:
[legend]

Public Member Functions

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

Private Attributes

std::ofstream _stream
 

Additional Inherited Members

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

Detailed Description

SLIOStream implementation for writing to native files.

Definition at line 32 of file SLIONative.h.

Constructor & Destructor Documentation

◆ SLIOWriterNative()

SLIOWriterNative::SLIOWriterNative ( std::string  path)

Definition at line 53 of file SLIONative.cpp.

54  : _stream(path, std::ios::binary)
55 {
56 }
std::ofstream _stream
Definition: SLIONative.h:42

Member Function Documentation

◆ flush()

void SLIOWriterNative::flush ( )
virtual

Reimplemented from SLIOStream.

Definition at line 84 of file SLIONative.cpp.

85 {
86  _stream.flush();
87 }

◆ seek()

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

Reimplemented from SLIOStream.

Definition at line 71 of file SLIONative.cpp.

72 {
73  std::ios::seekdir nativeOrigin = std::ios::beg;
74  if (origin == IOO_beg)
75  nativeOrigin = std::ios::beg;
76  else if (origin == IOO_cur)
77  nativeOrigin = std::ios::cur;
78  else if (origin == IOO_end)
79  nativeOrigin = std::ios::end;
80 
81  return (bool)_stream.seekp((std::streamsize)offset, nativeOrigin);
82 }

◆ tell()

size_t SLIOWriterNative::tell ( )
virtual

Reimplemented from SLIOStream.

Definition at line 66 of file SLIONative.cpp.

67 {
68  return (size_t)_stream.tellp();
69 }

◆ write()

size_t SLIOWriterNative::write ( const void buffer,
size_t  size 
)
virtual

Reimplemented from SLIOStream.

Definition at line 58 of file SLIONative.cpp.

59 {
60  size_t offsetBefore = (size_t)_stream.tellp();
61  _stream.write(static_cast<const char*>(buffer), (std::streamsize)size);
62  size_t offsetAfter = (size_t)_stream.tellp();
63  return offsetAfter - offsetBefore;
64 }
virtual size_t size()
Definition: SLFileStorage.h:76

Member Data Documentation

◆ _stream

std::ofstream SLIOWriterNative::_stream
private

Definition at line 42 of file SLIONative.h.


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