00001 // Filename: stringDecoder.h 00002 // Created by: drose (11Feb02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef STRINGDECODER_H 00020 #define STRINGDECODER_H 00021 00022 #include "pandabase.h" 00023 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : StringDecoder 00027 // Description : The base class to a family of classes that decode 00028 // various kinds of encoded byte streams. Give it a 00029 // string, then ask it to pull the characters out one at 00030 // a time. This also serves as the plain old 00031 // byte-at-a-time decoder. 00032 //////////////////////////////////////////////////////////////////// 00033 class StringDecoder { 00034 public: 00035 INLINE StringDecoder(const string &input); 00036 virtual ~StringDecoder(); 00037 00038 virtual int get_next_character(); 00039 INLINE bool is_eof(); 00040 00041 protected: 00042 INLINE bool test_eof(); 00043 00044 string _input; 00045 size_t _p; 00046 bool _eof; 00047 }; 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Class : StringUtf8Decoder 00051 // Description : This decoder extracts utf-8 sequences. 00052 //////////////////////////////////////////////////////////////////// 00053 class StringUtf8Decoder : public StringDecoder { 00054 public: 00055 INLINE StringUtf8Decoder(const string &input); 00056 00057 virtual int get_next_character(); 00058 }; 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Class : StringUnicodeDecoder 00062 // Description : This decoder extracts characters two at a time to get 00063 // a plain wide character sequence. 00064 //////////////////////////////////////////////////////////////////// 00065 class StringUnicodeDecoder : public StringDecoder { 00066 public: 00067 INLINE StringUnicodeDecoder(const string &input); 00068 00069 virtual int get_next_character(); 00070 }; 00071 00072 #include "stringDecoder.I" 00073 00074 #endif