Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
StreamWrapper.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
9
11#include <ostream>
13
15
18{
19public:
21 StreamOutWrapper(ostream &ioWrapped) : mWrapped(ioWrapped) { }
22
24 virtual void WriteBytes(const void *inData, size_t inNumBytes) override { mWrapped.write((const char *)inData, inNumBytes); }
25
27 virtual bool IsFailed() const override { return mWrapped.fail(); }
28
29private:
30 ostream & mWrapped;
31};
32
35{
36public:
38 StreamInWrapper(istream &ioWrapped) : mWrapped(ioWrapped) { }
39
41 virtual void ReadBytes(void *outData, size_t inNumBytes) override { mWrapped.read((char *)outData, inNumBytes); }
42
44 virtual bool IsEOF() const override { return mWrapped.eof(); }
45
47 virtual bool IsFailed() const override { return mWrapped.fail(); }
48
49private:
50 istream & mWrapped;
51};
52
#define JPH_SUPPRESS_WARNINGS_STD_BEGIN
Definition: Core.h:372
#define JPH_SUPPRESS_WARNINGS_STD_END
Definition: Core.h:384
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
Simple binary input stream.
Definition: StreamIn.h:13
Wrapper around std::istream.
Definition: StreamWrapper.h:35
virtual bool IsFailed() const override
Returns true if there was an IO failure.
Definition: StreamWrapper.h:47
StreamInWrapper(istream &ioWrapped)
Constructor.
Definition: StreamWrapper.h:38
virtual void ReadBytes(void *outData, size_t inNumBytes) override
Write a string of bytes to the binary stream.
Definition: StreamWrapper.h:41
virtual bool IsEOF() const override
Returns true when an attempt has been made to read past the end of the file.
Definition: StreamWrapper.h:44
Simple binary output stream.
Definition: StreamOut.h:13
Wrapper around std::ostream.
Definition: StreamWrapper.h:18
virtual bool IsFailed() const override
Returns true if there was an IO failure.
Definition: StreamWrapper.h:27
StreamOutWrapper(ostream &ioWrapped)
Constructor.
Definition: StreamWrapper.h:21
virtual void WriteBytes(const void *inData, size_t inNumBytes) override
Write a string of bytes to the binary stream.
Definition: StreamWrapper.h:24