PTLib  Version 2.18.8
 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 
30 #ifndef PTLIB_STRUCTUREDFILE_H
31 #define PTLIB_STRUCTUREDFILE_H
32 
33 #ifdef P_USE_PRAGMA
34 #pragma interface
35 #endif
36 
37 
45 class PStructuredFile : public PFile
46 {
47  PCLASSINFO(PStructuredFile, PFile);
48 
49  private:
50  PBoolean Read(void * buf, PINDEX len) { return PFile::Read(buf, len); }
51  PBoolean Write(const void * buf, PINDEX len) { return PFile::Write(buf, len); }
52 
53  public:
64 
74  OpenMode mode,
75  OpenOptions opts = ModeDefault
76  );
77 
85  const PFilePath & name,
86  OpenMode mode = ReadWrite,
87  OpenOptions opts = ModeDefault
88  );
90 
100  PBoolean Read(
101  void * buffer
102  );
103 
111  PBoolean Write(
112  const void * buffer
113  );
115 
123  PINDEX GetStructureSize() { return structureSize; }
124 
126  enum ElementType {
142  };
143 
145  struct Element {
149  PINDEX count;
150  };
151 
153  void SetStructure(
154  Element * structure,
155  PINDEX numElements
156  );
158 
159  protected:
160  // Member variables
163 
166 
168  PINDEX numElements;
169 
170 
171 // Include platform dependent part of class
172 #ifdef _WIN32
173 #include "msos/ptlib/sfile.h"
174 #else
175 #include "unix/ptlib/sfile.h"
176 #endif
177 };
178 
179 
180 #endif // PTLIB_STRUCTUREDFILE_H
181 
182 
183 // End Of File ///////////////////////////////////////////////////////////////
virtual PBoolean Read(void *buf, PINDEX len)
Low level read from the file channel.
Element is a 64 bit IEE floating point number.
Definition: sfile.h:138
This class represents a disk file.
Definition: file.h:57
Element * structure
Array of elements in the structure.
Definition: sfile.h:165
Element is a 16 bit integer.
Definition: sfile.h:130
ElementType type
Type of element in structure.
Definition: sfile.h:147
Elements in the structure definition.
Definition: sfile.h:145
Element is a 80 bit IEE floating point number.
Definition: sfile.h:140
This class describes a full description for a file on the particular platform.
Definition: filepath.h:61
File can be both read and written.
Definition: file.h:77
Definition: sfile.h:141
ElementType
All element types in a structure.
Definition: sfile.h:126
Element is a 32 bit IEE floating point number.
Definition: sfile.h:136
PINDEX structureSize
Number of bytes in structure.
Definition: sfile.h:162
PINDEX numElements
Number of elements in the array.
Definition: sfile.h:168
virtual PBoolean Write(const void *buf, PINDEX len)
Low level write to the file channel.
PINDEX count
Count of elements of this type.
Definition: sfile.h:149
void SetStructure(Element *structure, PINDEX numElements)
Set the structure of each record in the file.
Element is a single character.
Definition: sfile.h:128
bool PBoolean
Definition: object.h:174
PStructuredFile()
Create a structured file object but do not open it.
Element is a 32 bit integer.
Definition: sfile.h:132
A class representing a a structured file that is portable accross CPU architectures (as in the XDR pr...
Definition: sfile.h:45
PINDEX GetStructureSize()
Get the size of each structure in the file.
Definition: sfile.h:123
Element is a 64 bit integer.
Definition: sfile.h:134
OpenMode
When a file is opened, it may restrict the access available to operations on the object instance...
Definition: file.h:74