K3dReadFile.h

Go to the documentation of this file.
00001 
00015 /***************************************************************************
00016  *   Copyright (C) 2007 by Jan Koci   *
00017  *   honza.koci@email.cz   *
00018  *   http://kengine.sourceforge.net/tutorial/
00019  *                                                                         *
00020  *   This program is free software; you can redistribute it and/or modify  *
00021  *   it under the terms of the GNU General Public License as published by  *
00022  *   the Free Software Foundation; either version 2 of the License, or     *
00023  *   (at your option) any later version.                                   *
00024  *                                                                         *
00025  *   This program is distributed in the hope that it will be useful,       *
00026  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00027  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00028  *   GNU General Public License for more details.                          *
00029  *                                                                         *
00030  *   You should have received a copy of the GNU General Public License     *
00031  *   along with this program; if not, write to the                         *
00032  *   Free Software Foundation, Inc.,                                       *
00033  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00034  ***************************************************************************/
00035 
00036 #pragma once
00037 
00038 class K3dReaderFile : public K3dFile
00039 {
00040         public:
00041                 K3dReaderFile() {}
00042                 K3dReaderFile ( const std::string& _rFileName )
00043                 {
00044                         Open ( _rFileName );
00045                 }
00049                 bool Open ( const std::string& _rFileName )
00050                 {
00051                         return OpenForRead ( _rFileName );
00052                 }
00058                 int Read ( char* _strBuf, size_t _tLen )
00059                 {
00060                         assert ( Good() );
00061                         return fread ( reinterpret_cast<void*> ( _strBuf ), sizeof ( char ), _tLen, GetFile() );
00062                 }
00066                 int Read ( std::string& _rStr )
00067                 {
00068                         long lLen;
00069                         int iVal = Read ( lLen );
00070                         _rStr.resize ( lLen );
00071                         iVal += Read ( &_rStr[0], lLen );
00072                         return lLen;
00073                 }
00077                 int Read ( char& _rcVal )
00078                 {
00079                         return Read ( reinterpret_cast<char*> ( &_rcVal ), sizeof ( char ) );
00080                 }
00084                 int Read ( unsigned char& _rucVal )
00085                 {
00086                         return Read ( reinterpret_cast<char*> ( &_rucVal ), sizeof ( unsigned char ) );
00087                 }
00091                 int Read ( short& _rsVal )
00092                 {
00093                         return Read ( reinterpret_cast<char*> ( &_rsVal ), sizeof ( short ) );
00094                 }
00098                 int Read ( unsigned short& _rusVal )
00099                 {
00100                         return Read ( reinterpret_cast<char*> ( &_rusVal ), sizeof ( unsigned short ) );
00101                 }
00105                 int Read ( long& _rlVal )
00106                 {
00107                         return Read ( reinterpret_cast<char*> ( &_rlVal ), sizeof ( long ) );
00108                 }
00112                 int Read ( unsigned long& _rulVal )
00113                 {
00114                         return Read ( reinterpret_cast<char*> ( &_rulVal ), sizeof ( unsigned long ) );
00115                 }
00119                 int Read ( size_t& _tVal )
00120                 {
00121                         return Read ( reinterpret_cast<char*> ( &_tVal ), sizeof ( size_t ) );
00122                 }
00126                 int Read ( float& _rfVal )
00127                 {
00128                         return Read ( reinterpret_cast<char*> ( &_rfVal ), sizeof ( float ) );
00129                 }
00133                 int Read ( double& _rdVal )
00134                 {
00135                         return Read ( reinterpret_cast<char*> ( &_rdVal ), sizeof ( double ) );
00136                 }
00137 };
00138 

Generated on Thu Aug 16 23:53:28 2007 for K3dEngine by  doxygen 1.5.0