LeviLamina
Loading...
Searching...
No Matches
ReadOnlyBinaryStream.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/platform/Result.h"
7
8class ReadOnlyBinaryStream {
9public:
10 // member variables
11 // NOLINTBEGIN
12 ::std::string mOwnedBuffer;
13 ::std::string_view mView;
14 uint64 mReadPointer;
15 bool mHasOverflowed;
16 // NOLINTEND
17
18 ReadOnlyBinaryStream(::std::string_view buffer, bool copyBuffer)
19 : mView(buffer),
20 mReadPointer(0),
21 mHasOverflowed(false) {
22 if (copyBuffer) {
23 mOwnedBuffer = std::string(buffer);
24 mView = mOwnedBuffer;
25 }
26 }
27
28 [[nodiscard]] Bedrock::Result<void> ensureReadCompleted() const {
29 // Either we ran off the end of the buffer at some point, or we stopped short of it.
30 if (mHasOverflowed || mView.size() != mReadPointer) {
31 return nonstd::make_unexpected(
32 Bedrock::ErrorInfo<std::error_code>{std::make_error_code(std::errc::bad_message)}
33 );
34 }
35 return {};
36 }
37
38public:
39 // virtual functions
40 // NOLINTBEGIN
41 virtual ~ReadOnlyBinaryStream();
42
43 virtual ::Bedrock::Result<void> read(void* target, uint64 num);
44 // NOLINTEND
45
46public:
47 // member functions
48 // NOLINTBEGIN
49 MCAPI ::Bedrock::Result<bool> getBool();
50
51 MCAPI ::Bedrock::Result<uchar> getByte();
52
53 MCAPI ::Bedrock::Result<double> getDouble();
54
55 MCAPI ::Bedrock::Result<float> getFloat();
56
57 MCAPI ::Bedrock::Result<void> getRawBytes(::buffer_span_mut<uchar> outBuffer, uint64 length);
58
59 MCAPI ::Bedrock::Result<int> getSignedBigEndianInt();
60
61 MCAPI ::Bedrock::Result<schar> getSignedByte();
62
63 MCAPI ::Bedrock::Result<int> getSignedInt();
64
65 MCAPI ::Bedrock::Result<int64> getSignedInt64();
66
67 MCAPI ::Bedrock::Result<short> getSignedShort();
68
69 MCAPI ::Bedrock::Result<::std::string> getString(uint64 maxLength);
70
71 MCAPI ::Bedrock::Result<void> getString(::std::string& outStringStream, uint64 maxLength);
72
73 MCAPI ::Bedrock::Result<uchar> getUnsignedChar();
74
75 MCAPI ::Bedrock::Result<uint> getUnsignedInt();
76
77 MCAPI ::Bedrock::Result<uint64> getUnsignedInt64();
78
79 MCAPI ::Bedrock::Result<ushort> getUnsignedShort();
80
81 MCAPI ::Bedrock::Result<uint> getUnsignedVarInt();
82
83 MCAPI ::Bedrock::Result<uint64> getUnsignedVarInt64();
84
85 MCAPI ::Bedrock::Result<int> getVarInt();
86
87 MCAPI ::Bedrock::Result<int64> getVarInt64();
88 // NOLINTEND
89
90public:
91 // destructor thunk
92 // NOLINTBEGIN
93 MCAPI void $dtor();
94 // NOLINTEND
95
96public:
97 // virtual function thunks
98 // NOLINTBEGIN
99 MCAPI ::Bedrock::Result<void> $read(void* target, uint64 num);
100
101
102 // NOLINTEND
103
104public:
105 // vftables
106 // NOLINTBEGIN
107 MCNAPI static void** $vftable();
108 // NOLINTEND
109};
Definition Result.h:9
static MCAPI void ** $vftable()
Definition _HeaderOutputPredefine.h:343
Definition ErrorInfo.h:9
Definition buffer.h:5