home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Applications / Nuntius 1.2 / src / Nuntius / UNetAsciiConverter.h < prev    next >
Encoding:
Text File  |  1994-02-20  |  1.9 KB  |  84 lines  |  [TEXT/MPS ]

  1. // Copyright © 1993 Peter Speck (speck@dat.ruc.dk).  All rights reserved.
  2. // UNetAsciiConverter.h
  3.  
  4. /*
  5.  *
  6.  * Japanese Text Code Converter
  7.  * Between Network Code and Macintosh Native Code
  8.  *
  9.  * Copyright (c) 1993 by Shigeru Kanemoto
  10.  *                   and HappySize Incorporated
  11.  *
  12.  *
  13.  */
  14.  
  15. // Ported to C++ by Peter Speck, juni 1993
  16.  
  17.  
  18. #ifndef __UPTROBJECT__
  19. #include "UPtrObject.h"
  20. #endif
  21.  
  22. class PTextCodeConverter;
  23.  
  24. /* Code Conversion Direction */
  25. typedef enum {
  26.     tcvImport,        /* Import into Macintosh */
  27.     tcvExport,        /* Export from Macintosh */
  28. } TCVDirection;
  29.  
  30. typedef Boolean (PTextCodeConverter::*ImportFunc)();
  31. typedef Boolean (PTextCodeConverter::*ExportFunc)();
  32. // returns false when reaching end of text
  33.  
  34. class PTextCodeConverter : public PPtrObject
  35. {
  36.     public:
  37.         virtual void ConvertNet2Mac();
  38.         virtual void ConvertMac2Net();
  39.  
  40.         PTextCodeConverter();
  41.         virtual ~PTextCodeConverter();
  42.     protected:
  43.         virtual unsigned char GetNextChar() = 0;
  44.         // return Ascii0 if end of text
  45.         virtual void OutputOneChar(unsigned char ch) = 0;
  46.         virtual void OutputTwoChars(unsigned char ch1, unsigned char ch2) = 0;
  47.     
  48.     private:
  49.         ImportFunc fImportFunc;
  50.         ExportFunc fExportFunc;
  51.         unsigned char fCurrentExportChar;
  52.         
  53.         Boolean im_roman();
  54.         Boolean im_kana();
  55.         Boolean im_kanji();
  56.         Boolean ImportSwitch();
  57.         Boolean ex_roman();
  58.         Boolean ex_kana();
  59.         Boolean ex_kanji();
  60.         void ExportSwitchToRoman();
  61.         void ExportSwitchToKatakana();
  62.         void ExportSwitchToKanji();
  63. };
  64.  
  65. class PStringTextCodeConverter : public PTextCodeConverter
  66. {
  67.     public:
  68.         CStr255 fOutputString;
  69.         
  70.         virtual void ConvertNet2Mac();
  71.         virtual void ConvertMac2Net();
  72.  
  73.         PStringTextCodeConverter(const CStr255 &inputString);
  74.         virtual ~PStringTextCodeConverter();
  75.     protected:
  76.         virtual unsigned char GetNextChar();
  77.         virtual void OutputOneChar(unsigned char ch);
  78.         virtual void OutputTwoChars(unsigned char ch1, unsigned char c2);
  79.  
  80.     private:
  81.         const CStr255 &fInputString;
  82.         short fInputIndex;
  83. };
  84.