libStatGen Software
1
|
00001 /* 00002 * Copyright (C) 2010 Regents of the University of Michigan 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef __GLF_HEADER_H__ 00019 #define __GLF_HEADER_H__ 00020 00021 #include <stdint.h> 00022 00023 #include "InputFile.h" 00024 #include "CharBuffer.h" 00025 00026 /// This class allows a user to easily get/set the fields in a GLF header. 00027 /// The GlfHeader contains: 00028 /// - Variable length text string 00029 class GlfHeader 00030 { 00031 public: 00032 GlfHeader(); 00033 ~GlfHeader(); 00034 00035 /// Copy Constructor 00036 /// \param header glfheader to copy into this one. 00037 GlfHeader(const GlfHeader& header); 00038 00039 /// Overload operator= to copy the passed in header into this header. 00040 /// \param header glfheader to copy into this one. 00041 GlfHeader & operator = (const GlfHeader& header); 00042 00043 /// Copy the passed in header into this header. 00044 /// \param header glfheader to copy into this one. 00045 bool copy(const GlfHeader& header); 00046 00047 /// Clear this header back to the default setting. 00048 void resetHeader(); 00049 00050 /// Read the header from the specified file (file MUST be in 00051 /// the correct position for reading the header). 00052 /// \param filePtr file to read from that is in the correct position. 00053 /// \return true if the header was successfully read from the 00054 /// file, false if not. 00055 bool read(IFILE filePtr); 00056 00057 /// Write the header to the specified file. 00058 /// \param filePtr file to write to that is in the correct position. 00059 /// \return true if the header was successfully written to the 00060 /// file, false if not. 00061 bool write(IFILE filePtr) const; 00062 00063 /// Set the passed in string to the text string stored in this header. 00064 /// \param text string to populate with the header text string. 00065 /// \return true if text was successfully returned, false if not. 00066 bool getHeaderTextString(std::string& text); 00067 00068 /// Set the header to the passed in string. 00069 /// \param text header text to assign to this header. 00070 /// \return true if the text was successfully set, false if not. 00071 bool setHeaderTextString(const std::string& text); 00072 00073 private: 00074 int32_t myTextLen; 00075 CharBuffer myText; 00076 00077 static const std::string GLF_MAGIC; 00078 static const int GLF_MAGIC_LEN = 4; 00079 }; 00080 00081 #endif 00082