# 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  * $Revision: 24177 $
    00030  * $Author: rjongbloed $
    00031  * $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
    00032  */
    00033
    00034 #ifndef PTLIB_STRUCTUREDFILE_H
    00035 #define PTLIB_STRUCTUREDFILE_H
    00036
    00037 #ifdef P_USE_PRAGMA
    00038 #pragma interface
    00039 #endif
    00040
    00041
    00049 class PStructuredFile : public PFile
    00050 {
    00051   PCLASSINFO(PStructuredFile, PFile);
    00052
    00053   private:
    00054     PBoolean Read(void * buf, PINDEX len) { return PFile::Read(buf, len); }
    00055     PBoolean Write(const void * buf, PINDEX len) { return PFile::Write(buf, len); }
    00056
    00057   public:
    00067     PStructuredFile();
    00068
    00077     PStructuredFile(
    00078       OpenMode mode,
    00079       int opts = ModeDefault
    00080     );
    00081
    00088     PStructuredFile(
    00089       const PFilePath & name,
    00090       OpenMode mode = ReadWrite,
    00091       int opts = ModeDefault
    00092     );
    00094
    00104     PBoolean Read(
    00105       void * buffer
    00106     );
    00107
    00115     PBoolean Write(
    00116       const void * buffer
    00117     );
    00119
    00127     PINDEX GetStructureSize() { return structureSize; }
    00128
    00130     enum ElementType {
    00132       Character,
    00134       Integer16,
    00136       Integer32,
    00138       Integer64,
    00140       Float32,
    00142       Float64,
    00144       Float80,
    00145       NumElementTypes
    00146     };
    00147
    00149     struct Element {
    00151       ElementType type;
    00153       PINDEX      count;
    00154     };
    00155
    00157     void SetStructure(
    00158       Element * structure,
    00159       PINDEX numElements
    00160     );
    00162
    00163   protected:
    00164   // Member variables
    00166     PINDEX structureSize;
    00167
    00169     Element * structure;
    00170
    00172     PINDEX numElements;
    00173
    00174
    00175 // Include platform dependent part of class
    00176 #ifdef _WIN32
    00177 #include "msos/ptlib/sfile.h"
    00178 #else
    00179 #include "unix/ptlib/sfile.h"
    00180 #endif
    00181 };
    00182
    00183
    00184 #endif // PTLIB_STRUCTUREDFILE_H
    00185
    00186
    00187 // End Of File ///////////////////////////////////////////////////////////////