Panda3D

stringDecoder.h

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