home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / g__lib / sfile.h < prev    next >
C/C++ Source or Header  |  1993-07-23  |  2KB  |  85 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of GNU CC.
  7.  
  8. GNU CC is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY.  No author or distributor
  10. accepts responsibility to anyone for the consequences of using it
  11. or for whether it serves any particular purpose or works at all,
  12. unless he says so in writing.  Refer to the GNU CC General Public
  13. License for full details.
  14.  
  15. Everyone is granted permission to copy, modify and redistribute
  16. GNU CC, but only under the conditions described in the
  17. GNU CC General Public License.   A copy of this license is
  18. supposed to have been given to you along with GNU CC so you
  19. can know your rights and responsibilities.  It should be in a
  20. file named COPYING.  Among other things, the copyright notice
  21. and this notice must be preserved on all copies.  
  22. */
  23.  
  24. #ifndef _SFile_h
  25. #pragma once
  26. #define _SFile_h 1
  27.  
  28. #include <File.h>
  29.  
  30. class SFile: public File
  31. {
  32. protected:
  33.   int       sz;                   // unit size for structured binary IO
  34.  
  35. public:
  36.             SFile();
  37.             SFile(const char* filename, int size, io_mode m, access_mode a);
  38.             SFile(const char* filename, int size, const char* m);
  39.             SFile(int filedesc, int size, io_mode m);
  40.             SFile(FILE* fileptr,  int size);
  41.  
  42.             ~SFile();
  43.  
  44.   int       size();
  45.   int       setsize(int s);
  46.  
  47.   SFile&    get(void* x);
  48.   SFile&    put(void* x);
  49.   SFile&    operator[](long i);
  50. };
  51.  
  52. //#ifdef __OPTIMIZE__
  53.  
  54.  
  55. inline  int SFile::size()
  56.   return sz; 
  57. }          
  58.  
  59. inline  int SFile::setsize(int s)
  60.   int old = sz; 
  61.   sz = s;  
  62.   return old; 
  63. }
  64.  
  65. inline  SFile& SFile::get(void* x)
  66.   read(x, sz, 1);  return *this; 
  67. }
  68.  
  69. inline  SFile& SFile::put(void* x)
  70.   write(x, sz, 1);  return *this; 
  71. }
  72.  
  73. inline SFile&  SFile::operator[](long i)
  74.   seek(i * sz, 0);  return *this; 
  75. }
  76.  
  77. //#endif
  78.  
  79. #endif
  80.