/* Class declaration for the Seq_IO class The Seq_IO class can be used independently or as part of the MiniDB project. Copyright (C) 1998 Hossein Hakimzadeh Comments and bug fixes can be sent to hhakimza@iusb.edu This code is dedicated to my former student Willard. He was a hard working student and a very decent individual. I miss his stories. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef SEQ_IO_H #define SEQ_IO_H #define CLOSED 0 #define OPEN_FOR_READ 1 #define OPEN_FOR_WRITE 2 #define FALSE 0 #define TRUE 1 #define ON 1 #define OFF 0 //----------------------------------------------------------------- #include class Seq_IO { char FileName[256]; // *.dat fstream Seqfp; // Pointer to file class int State; // File state (OPEN for READ WRITE, APPEND, or CLOSED) int Verbose; // Verbose flag (ON / OFF) public: Seq_IO(char *filename); // Constructor ~Seq_IO(); // Destructor void EraseFile(void); // Erase the file int OpenForWrite(void); // If file does not exist create it, if it does, erase it. int OpenForAppend(void); // If file does not exist create it, if it does, place the file point at the end of the file. int OpenForRead(void); // Return 1 if successful int CloseFile(); // if the file is open, close it, otherwise return -1 int WriteData(char *a_record); // Write/Append a record int ReadData(char *a_record, char rec_sep); // Read record (starting current file location, until a record separator is found) int ReadData(char *a_record, unsigned long record_location, char rec_sep); // Read a record (until a record separator is found) unsigned long GetCurrentFileLocation(void); // if the file is open, get the current location unsigned long SetCurrentFileLocation( unsigned long location); // if the file is open, set the file pointer to location unsigned long FileSize(void); // if the file is open, return the last location in the file }; #endif