SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLIOMemory.h
Go to the documentation of this file.
1 /**
2  * \file SLIOMemory.h
3  * \date October 2022
4  * \authors Marino von Wattenwyl
5  * \copyright http://opensource.org/licenses/GPL-3.0
6  * \remarks Please use clangformat to format the code. See more code style on
7  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
8 */
9 
10 #ifndef SLPROJECT_SLIOMEMORY_H
11 #define SLPROJECT_SLIOMEMORY_H
12 
13 #include <SLFileStorage.h>
14 
15 #ifdef SL_STORAGE_WEB
16 //-----------------------------------------------------------------------------
17 //! Collection of functions for accessing files stored in memory
18 namespace SLIOMemory
19 {
20 bool exists(std::string path);
21 std::vector<char>& get(std::string path);
22 void set(std::string path, const std::vector<char>& data);
23 void clear(std::string path);
24 }
25 //-----------------------------------------------------------------------------
26 //! SLIOStream implementation for reading from memory
28 {
29 public:
30  SLIOReaderMemory(std::string path);
31  size_t read(void* buffer, size_t size);
32  size_t tell();
33  bool seek(size_t offset, Origin origin);
34  size_t size();
35 
36 protected:
37  std::string _path;
38  size_t _position;
39 };
40 //-----------------------------------------------------------------------------
41 //! SLIOStream implementation for reading to memory
43 {
44 public:
45  SLIOWriterMemory(std::string path);
46  size_t write(const void* buffer, size_t size);
47  size_t tell();
48  bool seek(size_t offset, Origin origin);
49  void flush();
50 
51 protected:
52  std::string _path;
53  size_t _position;
54 };
55 //-----------------------------------------------------------------------------
56 #endif
57 
58 #endif // SLPROJECT_SLIOMEMORY_H
SLIOStream implementation for reading from memory.
Definition: SLIOMemory.h:28
SLIOReaderMemory(std::string path)
Definition: SLIOMemory.cpp:39
size_t _position
Definition: SLIOMemory.h:38
bool seek(size_t offset, Origin origin)
Definition: SLIOMemory.cpp:56
size_t read(void *buffer, size_t size)
Definition: SLIOMemory.cpp:44
std::string _path
Definition: SLIOMemory.h:37
Interface for accessing external data using streams.
Definition: SLFileStorage.h:62
virtual size_t size()
Definition: SLFileStorage.h:76
SLIOStream implementation for reading to memory.
Definition: SLIOMemory.h:43
bool seek(size_t offset, Origin origin)
Definition: SLIOMemory.cpp:101
SLIOWriterMemory(std::string path)
Definition: SLIOMemory.cpp:81
size_t write(const void *buffer, size_t size)
Definition: SLIOMemory.cpp:88
size_t _position
Definition: SLIOMemory.h:53
std::string _path
Definition: SLIOMemory.h:52
Collection of functions for accessing files stored in memory.
Definition: SLIOMemory.h:19
std::vector< char > & get(std::string path)
Definition: SLIOMemory.cpp:24
void set(std::string path, const std::vector< char > &data)
Definition: SLIOMemory.cpp:29
void clear(std::string path)
Definition: SLIOMemory.cpp:34
bool exists(std::string path)
Definition: SLIOMemory.cpp:19