/* Class definition for the Data_File class The Data_File class can be used independently or as part of the MiniDB project. Copyright (C) 2007 Hossein Hakimzadeh Comments and bug fixes can be sent to hhakimza@iusb.edu 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 DATA_FILE_H #define DATA_FILE_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 class Data_File { char FileName[256]; // *.dta char RecordSeparator; // defaulted to '~' char FieldSeparator; // defaulted to '^' unsigned long CurrentFileLocation; unsigned long EOFLocation; int Verbose; // Verbose flag (ON / OFF) public: Data_File(char *filename, char field_separator, char record_separator);//Constructor ~Data_File(); // Destructor void SetRecordSeparator(char separator); // Default separator = '~' void SetFieldSeparator(char separator); // Default separator = '^' void Initialize(void); unsigned long GetCurrentFileLocation(); unsigned long FileSize(); int WriteRecord(char *a_record); // Write/Append a record int ReadRecord(char *a_record, unsigned long record_location); // Read the record at location or 0 if error int ReadNextRecord(char *a_record); // Read the next record from file or 0 if error int UnPackRecord(char *a_record, int &number_of_fields, char *fields[]); // UnPack the record into separate fields int PackRecord(char *a_record, char *fields[]); // Pack the Fields into a record void DumpDataFile(void); }; #endif