home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / FWStream / Include / FWStrmF.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-08  |  7.4 KB  |  288 lines  |  [TEXT/MPS ]

  1. #ifndef FWSTRMF_H
  2. #define FWSTRMF_H
  3. //========================================================================================
  4. //
  5. //    File:                FWStrmF.h
  6. //    Release Version:    $ 1.0d11 $
  7. //
  8. //    Copyright:    (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWASINKS_H
  13. #include "FWASinks.h"
  14. #endif
  15.  
  16. #ifndef FWPRIEXC_H
  17. #include "FWPriExc.h"
  18. #endif
  19.  
  20. #if FW_LIB_EXPORT_PRAGMAS
  21. #pragma lib_export on
  22. #endif
  23.  
  24. //========================================================================================
  25. //    Exception constants
  26. //========================================================================================
  27.  
  28. const FW_PlatformError FW_xReadableStreamFormatter = -30000;    // !!! JEL !!! Need approved values
  29. const FW_PlatformError FW_xWritableStreamFormatter = -30001;    // !!! JEL !!! Need approved values
  30.  
  31. //========================================================================================
  32. //    CLASS FW_CReadableStreamFormatter
  33. //========================================================================================
  34.  
  35. class FW_CLASS_ATTR FW_CReadableStreamFormatter FW_AUTO_DESTRUCT_OBJECT
  36. {
  37.  
  38. public:
  39.  
  40.     FW_CReadableStreamFormatter();
  41.     virtual~ FW_CReadableStreamFormatter();
  42.  
  43.     virtual void ReadBytes(FW_CSink& sink,
  44.                            void* destination,
  45.                            long count);
  46.  
  47.     virtual void ReadChars(FW_CSink& sink,
  48.                            char* destination,
  49.                            long count);
  50.     
  51.     virtual void ReadSignedChars(FW_CSink& sink,
  52.                                  signed char* destination,
  53.                                  long count);
  54.     
  55.     virtual void ReadUnsignedChars(FW_CSink& sink,
  56.                                    unsigned char* destination,
  57.                                    long count);
  58.  
  59.     virtual void ReadNullTerminatedString(FW_CSink& sink,
  60.                                           char* destination);
  61.  
  62.     virtual void ReadInts(FW_CSink& sink,
  63.                           int* destination,
  64.                           long count);
  65.  
  66.     virtual void ReadUnsignedInts(FW_CSink& sink,
  67.                                   unsigned int* destination,
  68.                                   long count);
  69.  
  70.     virtual void ReadShorts(FW_CSink& sink,
  71.                             short* destination,
  72.                             long count);
  73.  
  74.     virtual void ReadUnsignedShorts(FW_CSink& sink,
  75.                                     unsigned short* destination,
  76.                                     long count);
  77.  
  78.     virtual void ReadLongs(FW_CSink& sink,
  79.                            long* destination,
  80.                            long count);
  81.     
  82.     virtual void ReadUnsignedLongs(FW_CSink& sink,
  83.                                    unsigned long* destination,
  84.                                    long count);
  85.  
  86.     virtual void ReadFloats(FW_CSink& sink,
  87.                             float* destination,
  88.                             long count);
  89.  
  90.     virtual void ReadDoubles(FW_CSink& sink,
  91.                              double* destination,
  92.                              long count);
  93.  
  94. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  95.     virtual void ReadLongDoubles(FW_CSink& sink,
  96.                                  long double* destination,
  97.                                  long count);
  98. #endif
  99.  
  100. protected:
  101.  
  102.     void Identity(FW_CSink& sink,
  103.                   void* destination,
  104.                   long count,
  105.                   long itemSize);
  106.  
  107. private:
  108.     FW_CReadableStreamFormatter(const FW_CReadableStreamFormatter& formatter);
  109.     FW_CReadableStreamFormatter& operator=(const FW_CReadableStreamFormatter& formatter);
  110.         // Shouldn't copy instances of this class.
  111. };
  112.  
  113.  
  114. //========================================================================================
  115. //    CLASS FW_CWritableStreamFormatter
  116. //========================================================================================
  117.  
  118. class FW_CLASS_ATTR FW_CWritableStreamFormatter FW_AUTO_DESTRUCT_OBJECT
  119. {
  120.  
  121. public:
  122.  
  123.     FW_CWritableStreamFormatter();
  124.     virtual~ FW_CWritableStreamFormatter();
  125.  
  126.     virtual void WriteBytes(FW_CSink& sink,
  127.                             const void* source,
  128.                             long count);
  129.  
  130.     virtual void WriteChars(FW_CSink& sink,
  131.                             const char* source,
  132.                             long count);
  133.  
  134.     virtual void WriteSignedChars(FW_CSink& sink,
  135.                                   const signed char* source,
  136.                                   long count);
  137.     
  138.     virtual void WriteUnsignedChars(FW_CSink& sink,
  139.                                     const unsigned char* source,
  140.                                     long count);
  141.  
  142.     virtual void WriteNullTerminatedString(FW_CSink& sink,
  143.                                            const char* source);
  144.  
  145.     virtual void WriteInts(FW_CSink& sink,
  146.                            const int* source,
  147.                            long count);
  148.     
  149.     virtual void WriteUnsignedInts(FW_CSink& sink,
  150.                                    const unsigned int* source,
  151.                                    long count);
  152.  
  153.     virtual void WriteShorts(FW_CSink& sink,
  154.                              const short* source,
  155.                              long count);
  156.     
  157.     virtual void WriteUnsignedShorts(FW_CSink& sink,
  158.                                      const unsigned short* source,
  159.                                      long count);
  160.  
  161.     virtual void WriteLongs(FW_CSink& sink,
  162.                             const long* source,
  163.                             long count);
  164.     
  165.     virtual void WriteUnsignedLongs(FW_CSink& sink,
  166.                                     const unsigned long* source,
  167.                                     long count);
  168.  
  169.     virtual void WriteFloats(FW_CSink& sink,
  170.                              const float* source,
  171.                              long count);
  172.  
  173.     virtual void WriteDoubles(FW_CSink& sink,
  174.                               const double* source,
  175.                               long count);
  176.  
  177. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  178.     virtual void WriteLongDoubles(FW_CSink& sink,
  179.                                   const long double* source,
  180.                                   long count);
  181. #endif
  182.  
  183. protected:
  184.  
  185.     void Identity(FW_CSink& sink,
  186.                   const void* source,
  187.                   long count,
  188.                   long itemSize);
  189.  
  190. private:
  191.     FW_CWritableStreamFormatter(const FW_CWritableStreamFormatter& formatter);
  192.     FW_CWritableStreamFormatter& operator=(const FW_CWritableStreamFormatter& formatter);
  193.         // Shouldn't copy instances of this class.
  194. };
  195.  
  196.  
  197. //======================================================================================
  198. //    class FW_CByteSwapper
  199. //======================================================================================
  200.  
  201. class FW_CLASS_ATTR FW_CByteSwapper 
  202. {
  203. public:
  204.     static void SwapShort(void *aShort);
  205.     static void SwapLong(void *aLong);
  206. };
  207.  
  208.  
  209. //======================================================================================
  210. //    class FW_CReadableSwapBytesFormatter
  211. //======================================================================================
  212.  
  213. class FW_CLASS_ATTR FW_CReadableSwapBytesFormatter : public FW_CReadableStreamFormatter
  214. {
  215. public:
  216.  
  217.     FW_CReadableSwapBytesFormatter();
  218.     virtual~ FW_CReadableSwapBytesFormatter();
  219.  
  220.     virtual void ReadInts(FW_CSink& sink,
  221.                           int* destination,
  222.                           long count);
  223.  
  224.     virtual void ReadUnsignedInts(FW_CSink& sink,
  225.                                   unsigned int* destination,
  226.                                   long count);
  227.  
  228.     virtual void ReadShorts(FW_CSink& sink,
  229.                             short* destination,
  230.                             long count);
  231.  
  232.     virtual void ReadUnsignedShorts(FW_CSink& sink,
  233.                                     unsigned short* destination,
  234.                                     long count);
  235.  
  236.     virtual void ReadLongs(FW_CSink& sink,
  237.                            long* destination,
  238.                            long count);
  239.  
  240.     virtual void ReadUnsignedLongs(FW_CSink& sink,
  241.                                    unsigned long* destination,
  242.                                    long count);
  243. };
  244.  
  245.  
  246. //======================================================================================
  247. //    class FW_CWritableSwapBytesFormatter
  248. //======================================================================================
  249.  
  250. class FW_CLASS_ATTR FW_CWritableSwapBytesFormatter : public FW_CWritableStreamFormatter
  251. {
  252. public:
  253.  
  254.     FW_CWritableSwapBytesFormatter();
  255.     virtual~ FW_CWritableSwapBytesFormatter();
  256.  
  257.     virtual void WriteInts(FW_CSink& sink,
  258.                            const int* source,
  259.                            long count);
  260.  
  261.     virtual void WriteUnsignedInts(FW_CSink& sink,
  262.                                    const unsigned int* source,
  263.                                    long count);
  264.  
  265.     virtual void WriteShorts(FW_CSink& sink,
  266.                              const short* source,
  267.                              long count);
  268.  
  269.     virtual void WriteUnsignedShorts(FW_CSink& sink,
  270.                                      const unsigned short* source,
  271.                                      long count);
  272.  
  273.     virtual void WriteLongs(FW_CSink& sink,
  274.                             const long* source,
  275.                             long count);
  276.  
  277.     virtual void WriteUnsignedLongs(FW_CSink& sink,
  278.                                     const unsigned long* source,
  279.                                     long count);
  280. };
  281.  
  282.  
  283. #if FW_LIB_EXPORT_PRAGMAS
  284. #pragma lib_export off
  285. #endif
  286.  
  287. #endif
  288.