forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringDecoder.h
More file actions
70 lines (56 loc) · 1.67 KB
/
stringDecoder.h
File metadata and controls
70 lines (56 loc) · 1.67 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file stringDecoder.h
* @author drose
* @date 2002-02-11
*/
#ifndef STRINGDECODER_H
#define STRINGDECODER_H
#include "dtoolbase.h"
/**
* The base class to a family of classes that decode various kinds of encoded
* byte streams. Give it a string, then ask it to pull the characters out one
* at a time. This also serves as the plain old byte-at-a-time decoder.
*/
class EXPCL_DTOOL_DTOOLUTIL StringDecoder {
public:
INLINE StringDecoder(const std::string &input);
virtual ~StringDecoder();
virtual char32_t get_next_character();
INLINE bool is_eof();
static void set_notify_ptr(std::ostream *ptr);
static std::ostream *get_notify_ptr();
protected:
INLINE bool test_eof();
std::string _input;
size_t _p;
bool _eof;
static std::ostream *_notify_ptr;
};
/**
* This decoder extracts utf-8 sequences.
*/
class StringUtf8Decoder : public StringDecoder {
public:
INLINE StringUtf8Decoder(const std::string &input);
virtual char32_t get_next_character();
};
/**
* This decoder extracts characters two at a time to get a plain wide
* character sequence. It supports surrogate pairs.
*/
class StringUtf16Decoder : public StringDecoder {
public:
INLINE StringUtf16Decoder(const std::string &input);
virtual char32_t get_next_character();
};
// Deprecated alias of StringUtf16Encoder.
typedef StringUtf16Decoder StringUnicodeDecoder;
#include "stringDecoder.I"
#endif