stringDecoder.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Filename: stringDecoder.h
  2. // Created by: drose (11Feb02)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef STRINGDECODER_H
  19. #define STRINGDECODER_H
  20. #include "pandabase.h"
  21. ////////////////////////////////////////////////////////////////////
  22. // Class : StringDecoder
  23. // Description : The base class to a family of classes that decode
  24. // various kinds of encoded byte streams. Give it a
  25. // string, then ask it to pull the characters out one at
  26. // a time. This also serves as the plain old
  27. // byte-at-a-time decoder.
  28. ////////////////////////////////////////////////////////////////////
  29. class StringDecoder {
  30. public:
  31. INLINE StringDecoder(const string &input);
  32. virtual ~StringDecoder();
  33. virtual int get_next_character();
  34. INLINE bool is_eof();
  35. protected:
  36. INLINE bool test_eof();
  37. string _input;
  38. size_t _p;
  39. bool _eof;
  40. };
  41. ////////////////////////////////////////////////////////////////////
  42. // Class : StringUtf8Decoder
  43. // Description : This decoder extracts utf-8 sequences.
  44. ////////////////////////////////////////////////////////////////////
  45. class StringUtf8Decoder : public StringDecoder {
  46. public:
  47. INLINE StringUtf8Decoder(const string &input);
  48. virtual int get_next_character();
  49. };
  50. ////////////////////////////////////////////////////////////////////
  51. // Class : StringUnicodeDecoder
  52. // Description : This decoder extracts characters two at a time to get
  53. // a plain wide character sequence.
  54. ////////////////////////////////////////////////////////////////////
  55. class StringUnicodeDecoder : public StringDecoder {
  56. public:
  57. INLINE StringUnicodeDecoder(const string &input);
  58. virtual int get_next_character();
  59. };
  60. #include "stringDecoder.I"
  61. #endif