PTLib  Version 2.14.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sfile.h
Go to the documentation of this file.
1 /*
2  * sfile.h
3  *
4  * Structured file I/O channel class.
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25  * All Rights Reserved.
26  *
27  * Contributor(s): ______________________________________.
28  *
29  * $Revision: 27039 $
30  * $Author: rjongbloed $
31  * $Date: 2012-02-22 18:19:46 +1100 (Wed, 22 Feb 2012) $
32  */
33 
34 #ifndef PTLIB_STRUCTUREDFILE_H
35 #define PTLIB_STRUCTUREDFILE_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 
49 class PStructuredFile : public PFile
50 {
51  PCLASSINFO(PStructuredFile, PFile);
52 
53  private:
54  PBoolean Read(void * buf, PINDEX len) { return PFile::Read(buf, len); }
55  PBoolean Write(const void * buf, PINDEX len) { return PFile::Write(buf, len); }
56 
57  public:
68 
78  OpenMode mode,
79  OpenOptions opts = ModeDefault
80  );
81 
89  const PFilePath & name,
90  OpenMode mode = ReadWrite,
91  OpenOptions opts = ModeDefault
92  );
94 
104  PBoolean Read(
105  void * buffer
106  );
107 
115  PBoolean Write(
116  const void * buffer
117  );
119 
127  PINDEX GetStructureSize() { return structureSize; }
128 
130  enum ElementType {
146  };
147 
149  struct Element {
153  PINDEX count;
154  };
155 
157  void SetStructure(
158  Element * structure,
159  PINDEX numElements
160  );
162 
163  protected:
164  // Member variables
167 
170 
172  PINDEX numElements;
173 
174 
175 // Include platform dependent part of class
176 #ifdef _WIN32
177 #include "msos/ptlib/sfile.h"
178 #else
179 #include "unix/ptlib/sfile.h"
180 #endif
181 };
182 
183 
184 #endif // PTLIB_STRUCTUREDFILE_H
185 
186 
187 // End Of File ///////////////////////////////////////////////////////////////