blob: 994dd5231fe71b1c5cff72617c8b1c2fd6c2a6ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#ifndef NW4R_UT_CHAR_STRM_READER_H
#define NW4R_UT_CHAR_STRM_READER_H
#include "nw4r/types_nw4r.h"
namespace nw4r {
namespace ut {
class CharStrmReader {
public:
typedef u16 (CharStrmReader::*ReadFunc)();
CharStrmReader(ReadFunc func) : mCharStrm(NULL), mReadFunc(func) {}
~CharStrmReader() {}
u16 ReadNextCharUTF8();
u16 ReadNextCharUTF16();
u16 ReadNextCharCP1252();
u16 ReadNextCharSJIS();
const void *GetCurrentPos() const {
return mCharStrm;
}
template <typename T>
T GetChar(int offset) const {
return static_cast<const T *>(mCharStrm)[offset];
}
template <typename T>
void StepStrm(int offset) {
static_cast<const T *>(mCharStrm) += offset;
}
u16 Next() {
return (this->*mReadFunc)();
}
void Set(const char *strm) {
mCharStrm = strm;
}
void Set(const wchar_t *strm) {
mCharStrm = strm;
}
private:
const void *mCharStrm; // at 0x0
ReadFunc mReadFunc; // at 0x4
};
} // namespace ut
} // namespace nw4r
#endif
|