NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
ut_CharStrmReader.h
1#ifndef NW4R_UT_CHAR_STRM_READER_H
2#define NW4R_UT_CHAR_STRM_READER_H
3#include <nw4r/types_nw4r.h>
4
5namespace nw4r {
6namespace ut {
7
8class CharStrmReader {
9public:
10 typedef u16 (CharStrmReader::*ReadFunc)();
11
12public:
13 explicit CharStrmReader(ReadFunc pFunc)
14 : mCharStrm(NULL), mReadFunc(pFunc) {}
15
16 ~CharStrmReader() {}
17
18 u16 ReadNextCharUTF8();
19 u16 ReadNextCharUTF16();
20 u16 ReadNextCharCP1252();
21 u16 ReadNextCharSJIS();
22
23 u16 Next() {
24 return (this->*mReadFunc)();
25 }
26
27 const void* GetCurrentPos() const {
28 return mCharStrm;
29 }
30
31 void Set(const char* pStrm) {
32 mCharStrm = pStrm;
33 }
34 void Set(const wchar_t* pStrm) {
35 mCharStrm = pStrm;
36 }
37
38private:
39 template <typename T> T GetChar(int offset) const {
40 return static_cast<const T*>(mCharStrm)[offset];
41 }
42
43 template <typename T> void StepStrm(int offset) {
44 static_cast<const T*>(mCharStrm) += offset;
45 }
46
47private:
48 const void* mCharStrm; // at 0x0
49 ReadFunc mReadFunc; // at 0x4
50};
51
52} // namespace ut
53} // namespace nw4r
54
55#endif
Debugging library which includes various utilities used by the rest of nw4r.
Definition ut_list.cpp:4