20 #if !defined(__MITSUBA_CORE_SSTREAM_H_)
21 #define __MITSUBA_CORE_SSTREAM_H_
23 #include <mitsuba/mitsuba.h>
69 inline const std::string &
getPeer()
const {
return m_peer; }
84 static bool handleError(
const std::string &peer,
const std::string &cmd,
ELogLevel level =
EError);
93 void read(
void *ptr,
size_t size);
94 void write(
const void *ptr,
size_t size);
95 void seek(
size_t pos);
116 size_t m_received, m_sent;
size_t getReceivedBytes() const
Return the number of received bytes.
Definition: sstream.h:72
virtual void flush()=0
Flush the stream's buffers.
virtual bool canRead() const =0
Can we read from the stream?
#define MTS_EXPORT_CORE
Definition: getopt.h:29
virtual bool canWrite() const =0
Can we write to the stream?
virtual void read(void *ptr, size_t size)=0
Read a specified amount of data from the stream.
int socket_t
Socket typedef. For Windows it is based on the code in WinSock2.h.
Definition: sstream.h:45
Abstract seekable stream class.
Definition: stream.h:58
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
ELogLevel
Available Log message types.
Definition: formatter.h:28
Error message, causes an exception to be thrown.
Definition: formatter.h:33
const std::string & getPeer() const
Return the peer's name.
Definition: sstream.h:69
virtual void write(const void *ptr, size_t size)=0
Write a specified amount of data into the stream.
virtual size_t getPos() const =0
Get the current position inside the stream.
size_t getSentBytes() const
Return the number of sent bytes.
Definition: sstream.h:75
bool handleError(const std::string &cmd, ELogLevel level=EError)
Handle the last socket-specific error (looks up the appropriate OS description)
Definition: sstream.h:81
virtual std::string toString() const
Return a string representation.
virtual void seek(size_t pos)=0
Seek to a position inside the stream.
Portable Stream implementation, which encapsulates a socket for IPv4/IPv6 network communications...
Definition: sstream.h:37
virtual size_t getSize() const =0
Return the size of the stream.
virtual void truncate(size_t size)=0
Truncate the stream to a given size.