Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
IInputStream.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <cstddef>
6#include <optional>
7#include <string>
8
9namespace ph
10{
11
13{
14public:
21 virtual void read(std::size_t numBytes, std::byte* out_bytes) = 0;
22
29 virtual void readString(std::string* out_string, char delimiter) = 0;
30
36 virtual void seekGet(std::size_t pos) = 0;
37
42 virtual std::optional<std::size_t> tellGet() = 0;
43
47 operator bool () const override = 0;
48
57 virtual std::size_t readSome(std::size_t numBytes, std::byte* out_bytes);
58
64 void readLine(std::string* out_string);
65};
66
67// In-header Implementations:
68
69inline std::size_t IInputStream::readSome(const std::size_t numBytes, std::byte* const out_bytes)
70{
71 read(numBytes, out_bytes);
72 return numBytes;
73}
74
75inline void IInputStream::readLine(std::string* const out_string)
76{
77 readString(out_string, '\n');
78}
79
80}// end namespace ph
Definition IDataStream.h:9
Definition IInputStream.h:13
virtual std::optional< std::size_t > tellGet()=0
Get the current input position of the stream. The unit of the position is defined by the implementati...
void readLine(std::string *out_string)
Read a line. Equivalent to calling readString(std::string*, char) with ' ' as the delimiter.
Definition IInputStream.h:75
virtual void seekGet(std::size_t pos)=0
Set the input position of the stream. The unit of the position is defined by the implementation.
virtual void read(std::size_t numBytes, std::byte *out_bytes)=0
Read specific number of raw bytes in one go. The method does not return before finishing the reading ...
virtual void readString(std::string *out_string, char delimiter)=0
Read a string in one go. Note the EOF is also considered a delimiter (the final one).
virtual std::size_t readSome(std::size_t numBytes, std::byte *out_bytes)
Read some data in the form of raw bytes. The method may return before finish reading all bytes....
Definition IInputStream.h:69
The root for all renderer implementations.
Definition EEngineProject.h:6