PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: BufferedReader.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_H__ 00024 #define __PLCORE_BUFFEREDREADER_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLCore/String/String.h" 00032 00033 00034 //[-------------------------------------------------------] 00035 //[ Namespace ] 00036 //[-------------------------------------------------------] 00037 namespace PLCore { 00038 00039 00040 //[-------------------------------------------------------] 00041 //[ Classes ] 00042 //[-------------------------------------------------------] 00043 /** 00044 * @brief 00045 * Abstract buffered reader base class 00046 * 00047 * @remarks 00048 * A buffered reader is used to access a buffer or stream directly without the need to seek within the 00049 * stream too often. Therefore the reader stores the read data inside a buffer until it is no longer needed. 00050 */ 00051 class BufferedReader { 00052 00053 00054 //[-------------------------------------------------------] 00055 //[ Public virtual BufferedReader functions ] 00056 //[-------------------------------------------------------] 00057 public: 00058 /** 00059 * @brief 00060 * Destructor 00061 */ 00062 virtual ~BufferedReader() {}; 00063 00064 /** 00065 * @brief 00066 * Closes the reader 00067 */ 00068 virtual void Close() = 0; 00069 00070 /** 00071 * @brief 00072 * Check if the end of the stream has been reached 00073 * 00074 * @return 00075 * 'true' if the end of the buffer has been reached 00076 */ 00077 virtual bool IsEof() const = 0; 00078 00079 /** 00080 * @brief 00081 * Returns the string encoding format to use when dealing with string functions 00082 * 00083 * @return 00084 * String encoding format to use when dealing with string functions 00085 */ 00086 virtual String::EFormat GetStringFormat() const = 0; 00087 00088 /** 00089 * @brief 00090 * Returns a character read at the current position 00091 * 00092 * @return 00093 * Character that has been read, '\0' on error 00094 */ 00095 virtual int GetChar() = 0; 00096 00097 /** 00098 * @brief 00099 * Returns a string of a given size read at the current position 00100 * 00101 * @param[in] nSize 00102 * Number of characters to read 00103 * 00104 * @return 00105 * String that has been read, "" on error 00106 */ 00107 virtual String GetString(uint32 nSize) = 0; 00108 00109 /** 00110 * @brief 00111 * Reads a character at the current position and moves to the position after that 00112 * 00113 * @return 00114 * Character that has been read, '\0' on error 00115 */ 00116 virtual int ReadChar() = 0; 00117 00118 /** 00119 * @brief 00120 * Reads a string at the current position and moves to the position after that 00121 * 00122 * @param[in] nSize 00123 * Number of characters to read 00124 * 00125 * @return 00126 * String that has been read, "" on error 00127 */ 00128 virtual String ReadString(uint32 nSize) = 0; 00129 00130 /** 00131 * @brief 00132 * Checks if the next string equals the given one (case sensitive) 00133 * 00134 * @param[in] sString 00135 * String to compare with (length of this string is used to compare) 00136 * 00137 * @return 00138 * 'true' if the next string equals the given one, else 'false' 00139 */ 00140 virtual bool IsString(const String &sString) = 0; 00141 00142 /** 00143 * @brief 00144 * Checks if the next string equals the given one (not case sensitive) 00145 * 00146 * @param[in] sString 00147 * String to compare with (length of this string is used to compare) 00148 * 00149 * @return 00150 * 'true' if the next string equals the given one, else 'false' 00151 */ 00152 virtual bool IsStringNoCase(const String &sString) = 0; 00153 00154 /** 00155 * @brief 00156 * Returns the current position 00157 * 00158 * @return 00159 * Current position 00160 */ 00161 virtual uint32 Tell() const = 0; 00162 00163 /** 00164 * @brief 00165 * Set the current position 00166 * 00167 * @param[in] nPos 00168 * New position 00169 * 00170 * @return 00171 * 'true' if the seek has been successful 00172 */ 00173 virtual bool Seek(uint32 nPos) = 0; 00174 00175 00176 //[-------------------------------------------------------] 00177 //[ Protected functions ] 00178 //[-------------------------------------------------------] 00179 protected: 00180 /** 00181 * @brief 00182 * Constructor 00183 */ 00184 BufferedReader() {}; 00185 00186 /** 00187 * @brief 00188 * Copy constructor 00189 * 00190 * @param[in] cSource 00191 * Source to copy from 00192 */ 00193 PLCORE_API BufferedReader(const BufferedReader &cSource) {}; 00194 00195 /** 00196 * @brief 00197 * Copy operator 00198 * 00199 * @param[in] cSource 00200 * Source to copy from 00201 * 00202 * @return 00203 * Reference to this instance 00204 */ 00205 PLCORE_API BufferedReader &operator =(const BufferedReader &cSource) { return *this; }; 00206 00207 00208 }; 00209 00210 00211 //[-------------------------------------------------------] 00212 //[ Namespace ] 00213 //[-------------------------------------------------------] 00214 } // PLCore 00215 00216 00217 #endif // __PLCORE_BUFFEREDREADER_H__
|