PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: BufferedReaderFile.h * 00003 * 00004 * Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLCORE_BUFFEREDREADER_FILE_H__ 00024 #define __PLCORE_BUFFEREDREADER_FILE_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLCore/String/BufferedReader.h" 00032 00033 00034 //[-------------------------------------------------------] 00035 //[ Namespace ] 00036 //[-------------------------------------------------------] 00037 namespace PLCore { 00038 00039 00040 //[-------------------------------------------------------] 00041 //[ Forward declarations ] 00042 //[-------------------------------------------------------] 00043 class File; 00044 00045 00046 //[-------------------------------------------------------] 00047 //[ Classes ] 00048 //[-------------------------------------------------------] 00049 /** 00050 * @brief 00051 * Buffered reader that reads from a file 00052 */ 00053 class BufferedReaderFile : public BufferedReader { 00054 00055 00056 //[-------------------------------------------------------] 00057 //[ Public functions ] 00058 //[-------------------------------------------------------] 00059 public: 00060 /** 00061 * @brief 00062 * Constructor 00063 * 00064 * @param[in] cFile 00065 * File to read from, released automatically 00066 */ 00067 BufferedReaderFile(File &cFile); 00068 00069 /** 00070 * @brief 00071 * Destructor 00072 */ 00073 virtual ~BufferedReaderFile(); 00074 00075 00076 //[-------------------------------------------------------] 00077 //[ Public virtual BufferedReader functions ] 00078 //[-------------------------------------------------------] 00079 public: 00080 virtual void Close() override; 00081 virtual bool IsEof() const override; 00082 virtual String::EFormat GetStringFormat() const override; 00083 virtual int GetChar() override; 00084 virtual String GetString(uint32 nSize) override; 00085 virtual int ReadChar() override; 00086 virtual String ReadString(uint32 nSize) override; 00087 virtual bool IsString(const String &sString) override; 00088 virtual bool IsStringNoCase(const String &sString) override; 00089 virtual uint32 Tell() const override; 00090 virtual bool Seek(uint32 nPos) override; 00091 00092 00093 //[-------------------------------------------------------] 00094 //[ Private functions ] 00095 //[-------------------------------------------------------] 00096 private: 00097 /** 00098 * @brief 00099 * Copy constructor 00100 * 00101 * @param[in] cSource 00102 * Source to copy from 00103 */ 00104 BufferedReaderFile(const BufferedReaderFile &cSource); 00105 00106 /** 00107 * @brief 00108 * Copy operator 00109 * 00110 * @param[in] cSource 00111 * Source to copy from 00112 * 00113 * @return 00114 * Reference to this instance 00115 */ 00116 BufferedReaderFile &operator =(const BufferedReaderFile &cSource); 00117 00118 /** 00119 * @brief 00120 * Reads bytes from the stream 00121 * 00122 * @param[in] nSize 00123 * Number of bytes to read 00124 * 00125 * @return 00126 * 'true' if all went fine, else 'true' 00127 */ 00128 bool ReadFromStream(uint32 nSize); 00129 00130 00131 //[-------------------------------------------------------] 00132 //[ Private data ] 00133 //[-------------------------------------------------------] 00134 private: 00135 File *m_pFile; /**< File to read from, can be a null pointer */ 00136 String m_sBuffer; /**< Buffer that is used to store characters read from the file */ 00137 00138 00139 }; 00140 00141 00142 //[-------------------------------------------------------] 00143 //[ Namespace ] 00144 //[-------------------------------------------------------] 00145 } // PLCore 00146 00147 00148 #endif // __PLCORE_BUFFEREDREADER_FILE_H__
|