Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

sfile.h

Go to the documentation of this file.
00001 /*
00002  * sfile.h
00003  *
00004  * Structured file I/O channel class.
00005  *
00006  * Portable Windows Library
00007  *
00008  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Portable Windows Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
00025  * All Rights Reserved.
00026  *
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Log: sfile.h,v $
00030  * Revision 1.19  2003/09/17 05:41:59  csoutheren
00031  * Removed recursive includes
00032  *
00033  * Revision 1.18  2003/09/17 01:18:02  csoutheren
00034  * Removed recursive include file system and removed all references
00035  * to deprecated coooperative threading support
00036  *
00037  * Revision 1.17  2002/09/16 01:08:59  robertj
00038  * Added #define so can select if #pragma interface/implementation is used on
00039  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00040  *
00041  * Revision 1.16  2001/05/22 12:49:32  robertj
00042  * Did some seriously wierd rewrite of platform headers to eliminate the
00043  *   stupid GNU compiler warning about braces not matching.
00044  *
00045  * Revision 1.15  1999/03/09 02:59:51  robertj
00046  * Changed comments to doc++ compatible documentation.
00047  *
00048  * Revision 1.14  1999/02/16 08:11:10  robertj
00049  * MSVC 6.0 compatibility changes.
00050  *
00051  * Revision 1.13  1998/09/24 07:24:01  robertj
00052  * Moved structured fiel into separate module so don't need silly implementation file for GNU C.
00053  *
00054  * Revision 1.12  1998/09/23 06:21:23  robertj
00055  * Added open source copyright license.
00056  *
00057  * Revision 1.11  1996/01/23 13:15:38  robertj
00058  * Mac Metrowerks compiler support.
00059  *
00060  * Revision 1.10  1995/06/17 11:13:19  robertj
00061  * Documentation update.
00062  *
00063  * Revision 1.9  1995/03/14 12:42:34  robertj
00064  * Updated documentation to use HTML codes.
00065  *
00066  * Revision 1.8  1995/01/14  06:19:39  robertj
00067  * Documentation
00068  *
00069  * Revision 1.7  1994/08/23  11:32:52  robertj
00070  * Oops
00071  *
00072  * Revision 1.6  1994/08/22  00:46:48  robertj
00073  * Added pragma fro GNU C++ compiler.
00074  *
00075  * Revision 1.5  1994/04/20  12:17:44  robertj
00076  * PFilePath split
00077  *
00078  * Revision 1.4  1994/01/03  04:42:23  robertj
00079  * Mass changes to common container classes and interactors etc etc etc.
00080  *
00081  * Revision 1.3  1993/08/21  01:50:33  robertj
00082  * Made Clone() function optional, default will assert if called.
00083  *
00084  * Revision 1.2  1993/07/14  12:49:16  robertj
00085  * Fixed RCS keywords.
00086  *
00087  */
00088 
00089 #ifndef _PSTRUCTUREDFILE
00090 #define _PSTRUCTUREDFILE
00091 
00092 #ifdef P_USE_PRAGMA
00093 #pragma interface
00094 #endif
00095 
00096 
00104 class PStructuredFile : public PFile
00105 {
00106   PCLASSINFO(PStructuredFile, PFile);
00107 
00108   private:
00109     BOOL Read(void * buf, PINDEX len) { return PFile::Read(buf, len); }
00110     BOOL Write(const void * buf, PINDEX len) { return PFile::Write(buf, len); }
00111 
00112   public:
00122     PStructuredFile();
00123 
00132     PStructuredFile(
00133       OpenMode mode,          
00134       int opts = ModeDefault  
00135     );
00136       
00143     PStructuredFile(
00144       const PFilePath & name,    
00145       OpenMode mode = ReadWrite, 
00146       int opts = ModeDefault     
00147     );
00149 
00159     BOOL Read(
00160       void * buffer   
00161     );
00162       
00170     BOOL Write(
00171       const void * buffer   
00172     );
00174 
00182     PINDEX GetStructureSize() { return structureSize; }
00183 
00185     enum ElementType {
00187       Character,    
00189       Integer16,    
00191       Integer32,    
00193       Integer64,    
00195       Float32,      
00197       Float64,      
00199       Float80,      
00200       NumElementTypes
00201     };
00202 
00204     struct Element {
00206       ElementType type;   
00208       PINDEX      count;  
00209     };
00210 
00212     void SetStructure(
00213       Element * structure,  
00214       PINDEX numElements    
00215     );
00217 
00218   protected:
00219   // Member variables
00221     PINDEX structureSize;
00222 
00224     Element * structure;
00225 
00227     PINDEX numElements;
00228 
00229 
00230 // Include platform dependent part of class
00231 #ifdef _WIN32
00232 #include "msos/ptlib/sfile.h"
00233 #else
00234 #include "unix/ptlib/sfile.h"
00235 #endif
00236 };
00237 
00238 #endif
00239 
00240 // End Of File ///////////////////////////////////////////////////////////////

Generated on Tue Mar 15 10:44:52 2005 for PWLib by  doxygen 1.4.0