Panda3D
stringDecoder.h
1 // Filename: stringDecoder.h
2 // Created by: drose (11Feb02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef STRINGDECODER_H
16 #define STRINGDECODER_H
17 
18 #include "dtoolbase.h"
19 
20 ////////////////////////////////////////////////////////////////////
21 // Class : StringDecoder
22 // Description : The base class to a family of classes that decode
23 // various kinds of encoded byte streams. Give it a
24 // string, then ask it to pull the characters out one at
25 // a time. This also serves as the plain old
26 // byte-at-a-time decoder.
27 ////////////////////////////////////////////////////////////////////
28 class EXPCL_DTOOL StringDecoder {
29 public:
30  INLINE StringDecoder(const string &input);
31  virtual ~StringDecoder();
32 
33  virtual int get_next_character();
34  INLINE bool is_eof();
35 
36  static void set_notify_ptr(ostream *ptr);
37  static ostream *get_notify_ptr();
38 
39 protected:
40  INLINE bool test_eof();
41 
42  string _input;
43  size_t _p;
44  bool _eof;
45  static ostream *_notify_ptr;
46 };
47 
48 ////////////////////////////////////////////////////////////////////
49 // Class : StringUtf8Decoder
50 // Description : This decoder extracts utf-8 sequences.
51 ////////////////////////////////////////////////////////////////////
53 public:
54  INLINE StringUtf8Decoder(const string &input);
55 
56  virtual int get_next_character();
57 };
58 
59 ////////////////////////////////////////////////////////////////////
60 // Class : StringUnicodeDecoder
61 // Description : This decoder extracts characters two at a time to get
62 // a plain wide character sequence.
63 ////////////////////////////////////////////////////////////////////
65 public:
66  INLINE StringUnicodeDecoder(const string &input);
67 
68  virtual int get_next_character();
69 };
70 
71 #include "stringDecoder.I"
72 
73 #endif
This decoder extracts utf-8 sequences.
Definition: stringDecoder.h:52
This decoder extracts characters two at a time to get a plain wide character sequence.
Definition: stringDecoder.h:64
The base class to a family of classes that decode various kinds of encoded byte streams.
Definition: stringDecoder.h:28