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
23 StreamOutWrapper(ostream &ioWrapped) : mWrapped(ioWrapped) { }
24
26 virtual void WriteBytes(const void *inData, size_t inNumBytes) override { mWrapped.write((const char *)inData, inNumBytes); }
27
29 virtual bool IsFailed() const override { return mWrapped.fail(); }
30
31private:
32 ostream & mWrapped;
33};
34
37{
38public:
40
42 StreamInWrapper(istream &ioWrapped) : mWrapped(ioWrapped) { }
43
45 virtual void ReadBytes(void *outData, size_t inNumBytes) override { mWrapped.read((char *)outData, inNumBytes); }
46
48 virtual bool IsEOF() const override { return mWrapped.eof(); }
49
51 virtual bool IsFailed() const override { return mWrapped.fail(); }
52
53private:
54 istream & mWrapped;
55};
56
#define JPH_SUPPRESS_WARNINGS_STD_BEGIN
Definition Core.h:492
#define JPH_SUPPRESS_WARNINGS_STD_END
Definition Core.h:506
#define JPH_NAMESPACE_END
Definition Core.h:487
#define JPH_NAMESPACE_BEGIN
Definition Core.h:481
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:51
Simple binary input stream.
Definition StreamIn.h:13
Wrapper around std::istream.
Definition StreamWrapper.h:37
virtual bool IsFailed() const override
Returns true if there was an IO failure.
Definition StreamWrapper.h:51
JPH_OVERRIDE_NEW_DELETE StreamInWrapper(istream &ioWrapped)
Constructor.
Definition StreamWrapper.h:42
virtual void ReadBytes(void *outData, size_t inNumBytes) override
Write a string of bytes to the binary stream.
Definition StreamWrapper.h:45
virtual bool IsEOF() const override
Returns true when an attempt has been made to read past the end of the file.
Definition StreamWrapper.h:48
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:29
virtual void WriteBytes(const void *inData, size_t inNumBytes) override
Write a string of bytes to the binary stream.
Definition StreamWrapper.h:26
JPH_OVERRIDE_NEW_DELETE StreamOutWrapper(ostream &ioWrapped)
Constructor.
Definition StreamWrapper.h:23