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.20 2005/11/25 03:43:47 csoutheren 00031 * Fixed function argument comments to be compatible with Doxygen 00032 * 00033 * Revision 1.19 2003/09/17 05:41:59 csoutheren 00034 * Removed recursive includes 00035 * 00036 * Revision 1.18 2003/09/17 01:18:02 csoutheren 00037 * Removed recursive include file system and removed all references 00038 * to deprecated coooperative threading support 00039 * 00040 * Revision 1.17 2002/09/16 01:08:59 robertj 00041 * Added #define so can select if #pragma interface/implementation is used on 00042 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00043 * 00044 * Revision 1.16 2001/05/22 12:49:32 robertj 00045 * Did some seriously wierd rewrite of platform headers to eliminate the 00046 * stupid GNU compiler warning about braces not matching. 00047 * 00048 * Revision 1.15 1999/03/09 02:59:51 robertj 00049 * Changed comments to doc++ compatible documentation. 00050 * 00051 * Revision 1.14 1999/02/16 08:11:10 robertj 00052 * MSVC 6.0 compatibility changes. 00053 * 00054 * Revision 1.13 1998/09/24 07:24:01 robertj 00055 * Moved structured fiel into separate module so don't need silly implementation file for GNU C. 00056 * 00057 * Revision 1.12 1998/09/23 06:21:23 robertj 00058 * Added open source copyright license. 00059 * 00060 * Revision 1.11 1996/01/23 13:15:38 robertj 00061 * Mac Metrowerks compiler support. 00062 * 00063 * Revision 1.10 1995/06/17 11:13:19 robertj 00064 * Documentation update. 00065 * 00066 * Revision 1.9 1995/03/14 12:42:34 robertj 00067 * Updated documentation to use HTML codes. 00068 * 00069 * Revision 1.8 1995/01/14 06:19:39 robertj 00070 * Documentation 00071 * 00072 * Revision 1.7 1994/08/23 11:32:52 robertj 00073 * Oops 00074 * 00075 * Revision 1.6 1994/08/22 00:46:48 robertj 00076 * Added pragma fro GNU C++ compiler. 00077 * 00078 * Revision 1.5 1994/04/20 12:17:44 robertj 00079 * PFilePath split 00080 * 00081 * Revision 1.4 1994/01/03 04:42:23 robertj 00082 * Mass changes to common container classes and interactors etc etc etc. 00083 * 00084 * Revision 1.3 1993/08/21 01:50:33 robertj 00085 * Made Clone() function optional, default will assert if called. 00086 * 00087 * Revision 1.2 1993/07/14 12:49:16 robertj 00088 * Fixed RCS keywords. 00089 * 00090 */ 00091 00092 #ifndef _PSTRUCTUREDFILE 00093 #define _PSTRUCTUREDFILE 00094 00095 #ifdef P_USE_PRAGMA 00096 #pragma interface 00097 #endif 00098 00099 00107 class PStructuredFile : public PFile 00108 { 00109 PCLASSINFO(PStructuredFile, PFile); 00110 00111 private: 00112 BOOL Read(void * buf, PINDEX len) { return PFile::Read(buf, len); } 00113 BOOL Write(const void * buf, PINDEX len) { return PFile::Write(buf, len); } 00114 00115 public: 00125 PStructuredFile(); 00126 00135 PStructuredFile( 00136 OpenMode mode, 00137 int opts = ModeDefault 00138 ); 00139 00146 PStructuredFile( 00147 const PFilePath & name, 00148 OpenMode mode = ReadWrite, 00149 int opts = ModeDefault 00150 ); 00152 00162 BOOL Read( 00163 void * buffer 00164 ); 00165 00173 BOOL Write( 00174 const void * buffer 00175 ); 00177 00185 PINDEX GetStructureSize() { return structureSize; } 00186 00188 enum ElementType { 00190 Character, 00192 Integer16, 00194 Integer32, 00196 Integer64, 00198 Float32, 00200 Float64, 00202 Float80, 00203 NumElementTypes 00204 }; 00205 00207 struct Element { 00209 ElementType type; 00211 PINDEX count; 00212 }; 00213 00215 void SetStructure( 00216 Element * structure, 00217 PINDEX numElements 00218 ); 00220 00221 protected: 00222 // Member variables 00224 PINDEX structureSize; 00225 00227 Element * structure; 00228 00230 PINDEX numElements; 00231 00232 00233 // Include platform dependent part of class 00234 #ifdef _WIN32 00235 #include "msos/ptlib/sfile.h" 00236 #else 00237 #include "unix/ptlib/sfile.h" 00238 #endif 00239 }; 00240 00241 #endif 00242 00243 // End Of File ///////////////////////////////////////////////////////////////