OROCHI
 
Loading...
Searching...
No Matches
GxStreamReader.h
Go to the documentation of this file.
1//===========================================================================
10//===========================================================================
11#pragma once
12
13GX_CORE_NAMESPACE_BEGIN()
14
15//===========================================================================
17//===========================================================================
19{
20 //-----------------------------------------------------------
22 //-----------------------------------------------------------
24public:
26 enum class RESULT
27 {
28 SUCCESS = 0,
29
30 ERROR_CANCELED = -1,
31 ERROR_ADDRESS = -2,
32 ERROR_SIZE = -3,
33 ERROR_READ_FAILED = -4,
34 ERROR_RESERVE_FAILED = -5
35 };
36
37 // new, delete指定
38 GX_OPERATOR_NEW_DELETE(GxAllocatorList::ALLOCATOR_TYPE::TEMPORARY)
39
40
41 //-----------------------------------------------------------
43 //-----------------------------------------------------------
45protected:
48public:
50 GxStreamReader(GxStream& stream, GX_ENDIAN endian = GX_ENDIAN::NATIVE, GxMemoryStream* pExport = nullptr)
51 : _pStream(&stream)
52 , _pExport(pExport)
53 , _result(RESULT::SUCCESS)
54 , _endian(endian)
55 {}
57 virtual ~GxStreamReader(void) {}
58
59private:
63 GX_FORCE_INLINE const GxStreamReader& operator=(const GxStreamReader&);
64
66 //-----------------------------------------------------------
68 //-----------------------------------------------------------
70public:
72 b32 readS8(s8& dst);
74 b32 readU8(u8& dst);
76 b32 readS16(s16& dst);
78 b32 readU16(u16& dst);
80 b32 readS32(s32& dst);
82 b32 readU32(u32& dst);
84 b32 readS64(s64& dst);
86 b32 readU64(u64& dst);
88 b32 readS128(s128& dst);
90 b32 readU128(u128& dst);
92 b32 readB32(b32& dst);
94 b32 readF32(f32& dst);
96 b32 readF64(f64& dst);
98 void* readBlock(void* pDst, u32 size);
100 void* readPlane(void* pDst, u32 size);
101
103 constexpr void setExportStream(GxMemoryStream* pExport){ _pExport = pExport; }
105 void* exportS8(void);
107 void* exportU8(void);
109 void* exportS16(void);
111 void* exportU16(void);
113 void* exportS32(void);
115 void* exportU32(void);
117 void* exportS64(void);
119 void* exportU64(void);
121 void* exportB32(void);
123 void* exportF32(void);
125 void* exportF64(void);
127 void* exportBlock(u32 size, GxMemory::ALIGNMENT alignment = GxMemory::ALIGNMENT::_4);
129 void* exportReserve(u32 size, GxMemory::ALIGNMENT alignment = GxMemory::ALIGNMENT::_4);
131 void* getExportCurrent(GxMemory::ALIGNMENT alignment = GxMemory::ALIGNMENT::_4);
132
133protected:
135 virtual b32 read(void* pDst, u32 size);
136
138 //-----------------------------------------------------------
140 //-----------------------------------------------------------
142public:
144 constexpr GxStream* getStream(void) const { return _pStream; }
146 GX_FORCE_INLINE u32 getCurrentPosition(void) const { return _pStream->getPosition(); }
148 constexpr RESULT getResult(void) const { return _result; }
150 constexpr void setEndian(GX_ENDIAN endian) { _endian = endian; }
152 constexpr GX_ENDIAN getEndian(void) const { return _endian; }
153
155 //-----------------------------------------------------------
157 //-----------------------------------------------------------
159protected:
164
166};
167
168GX_CORE_NAMESPACE_END()
GX_ENDIAN
エンディアン定義
Definition GxDefine.h:220
@ NATIVE
ネイティブエンディアン
ALIGNMENT
メモリアライメント定義
Definition GxMemory.h:51
@ _4
4byteアライメント
Definition GxMemory.h:52
メモリストリームクラス
Definition GxStream.h:248
ストリーム基礎クラス
Definition GxStream.h:20
ストリーム読み込みクラス
Definition GxStreamReader.h:19
GX_FORCE_INLINE u32 getCurrentPosition(void) const
現在ストリーム位置取得
Definition GxStreamReader.h:146
constexpr void setExportStream(GxMemoryStream *pExport)
エクスポートストリーム設定
Definition GxStreamReader.h:103
GX_ENDIAN _endian
ストリーム内エンディアン定義
Definition GxStreamReader.h:163
GxStream * _pStream
読み込みストリーム
Definition GxStreamReader.h:160
RESULT
処理結果定義
Definition GxStreamReader.h:27
GxMemoryStream * _pExport
エクスポート用ストリーム
Definition GxStreamReader.h:161
GxStreamReader(GxStream &stream, GX_ENDIAN endian=GX_ENDIAN::NATIVE, GxMemoryStream *pExport=nullptr)
コンストラクタ
Definition GxStreamReader.h:50
constexpr RESULT getResult(void) const
詳細結果取得
Definition GxStreamReader.h:148
constexpr void setEndian(GX_ENDIAN endian)
エンディアン指定
Definition GxStreamReader.h:150
virtual ~GxStreamReader(void)
デストラクタ
Definition GxStreamReader.h:57
constexpr GX_ENDIAN getEndian(void) const
エンディアン取得
Definition GxStreamReader.h:152
RESULT _result
処理結果
Definition GxStreamReader.h:162
constexpr GxStream * getStream(void) const
ストリーム取得
Definition GxStreamReader.h:144
GxStreamReader(void)
ディフォルトコンストラクタ (※使用禁止)
Definition GxStreamReader.h:47
32bitブーリアン
Definition GxDefine.h:173