All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sfile.h
Go to the documentation of this file.
/*
* sfile.h
*
* Structured file I/O channel class.
*
* Portable Windows Library
*
* Copyright (c) 1993-1998 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Portions are Copyright (C) 1993 Free Software Foundation, Inc.
* All Rights Reserved.
*
* Contributor(s): ______________________________________.
*
* $Revision: 24177 $
* $Author: rjongbloed $
* $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
*/
#ifndef PTLIB_STRUCTUREDFILE_H
#define PTLIB_STRUCTUREDFILE_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
class PStructuredFile : public PFile
{
PCLASSINFO(PStructuredFile, PFile);
private:
PBoolean Read(void * buf, PINDEX len) { return PFile::Read(buf, len); }
PBoolean Write(const void * buf, PINDEX len) { return PFile::Write(buf, len); }
public:
PStructuredFile();
PStructuredFile(
OpenMode mode,
int opts = ModeDefault
);
PStructuredFile(
const PFilePath & name,
OpenMode mode = ReadWrite,
int opts = ModeDefault
);
PBoolean Read(
void * buffer
);
PBoolean Write(
const void * buffer
);
PINDEX GetStructureSize() { return structureSize; }
enum ElementType {
Character,
Integer16,
Integer32,
Integer64,
Float32,
Float64,
Float80,
NumElementTypes
};
struct Element {
ElementType type;
PINDEX count;
};
void SetStructure(
Element * structure,
PINDEX numElements
);
protected:
// Member variables
PINDEX structureSize;
Element * structure;
PINDEX numElements;
// Include platform dependent part of class
#ifdef _WIN32
#include "msos/ptlib/sfile.h"
#else
#include "unix/ptlib/sfile.h"
#endif
};
#endif // PTLIB_STRUCTUREDFILE_H
// End Of File ///////////////////////////////////////////////////////////////
PFile::Read
virtual PBoolean Read(void *buf, PINDEX len)
Low level read from the file channel.
PStructuredFile::Float64
Element is a 64 bit IEE floating point number.
Definition: sfile.h:142
PFile
This class represents a disk file.
Definition: file.h:60
PStructuredFile::structure
Element * structure
Array of elements in the structure.
Definition: sfile.h:169
PStructuredFile::Integer16
Element is a 16 bit integer.
Definition: sfile.h:134
PStructuredFile::Element::type
ElementType type
Type of element in structure.
Definition: sfile.h:151
PStructuredFile::Element
Elements in the structure definition.
Definition: sfile.h:149
PStructuredFile::Float80
Element is a 80 bit IEE floating point number.
Definition: sfile.h:144
PFilePath
This class describes a full description for a file on the particular platform.
Definition: filepath.h:65
PFile::ReadWrite
File can be both read and written.
Definition: file.h:80
PStructuredFile::NumElementTypes
Definition: sfile.h:145
PStructuredFile::ElementType
ElementType
All element types in a structure.
Definition: sfile.h:130
PStructuredFile::Float32
Element is a 32 bit IEE floating point number.
Definition: sfile.h:140
PBoolean
BOOL PBoolean
Definition: object.h:102
PStructuredFile::structureSize
PINDEX structureSize
Number of bytes in structure.
Definition: sfile.h:166
PStructuredFile::numElements
PINDEX numElements
Number of elements in the array.
Definition: sfile.h:172
PFile::Write
virtual PBoolean Write(const void *buf, PINDEX len)
Low level write to the file channel.
PStructuredFile::Element::count
PINDEX count
Count of elements of this type.
Definition: sfile.h:153
PStructuredFile::SetStructure
void SetStructure(Element *structure, PINDEX numElements)
Set the structure of each record in the file.
PStructuredFile::Character
Element is a single character.
Definition: sfile.h:132
PFile::ModeDefault
File options depend on the OpenMode parameter.
Definition: file.h:95
PStructuredFile::PStructuredFile
PStructuredFile()
Create a structured file object but do not open it.
PStructuredFile::Integer32
Element is a 32 bit integer.
Definition: sfile.h:136
PStructuredFile
A class representing a a structured file that is portable accross CPU architectures (as in the XDR pr...
Definition: sfile.h:49
PStructuredFile::GetStructureSize
PINDEX GetStructureSize()
Get the size of each structure in the file.
Definition: sfile.h:127
PStructuredFile::Integer64
Element is a 64 bit integer.
Definition: sfile.h:138
PFile::OpenMode
OpenMode
When a file is opened, it may restrict the access available to operations on the object instance...
Definition: file.h:77