K3dWriteFile.h

Go to the documentation of this file.
00001 
00016 /***************************************************************************
00017  *   Copyright (C) 2007 by Jan Koci   *
00018  *   honza.koci@email.cz   *
00019  *   http://kengine.sourceforge.net/tutorial/
00020  *                                                                         *
00021  *   This program is free software; you can redistribute it and/or modify  *
00022  *   it under the terms of the GNU General Public License as published by  *
00023  *   the Free Software Foundation; either version 2 of the License, or     *
00024  *   (at your option) any later version.                                   *
00025  *                                                                         *
00026  *   This program is distributed in the hope that it will be useful,       *
00027  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00028  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00029  *   GNU General Public License for more details.                          *
00030  *                                                                         *
00031  *   You should have received a copy of the GNU General Public License     *
00032  *   along with this program; if not, write to the                         *
00033  *   Free Software Foundation, Inc.,                                       *
00034  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00035  ***************************************************************************/
00036 
00037 #pragma once
00038 
00039 class K3dWriterFile : public K3dFile
00040 {
00041         public:
00042                 K3dWriterFile() {}
00043                 K3dWriterFile ( const std::string& _rFileName )
00044                 {
00045                         Open ( _rFileName );
00046                 }
00047                 K3dWriterFile ( const std::string& _rFileName, bool _bAppend )
00048                 {
00049                         Open ( _rFileName, _bAppend );
00050                 }
00053                 bool Open ( const std::string& _rFileName )
00054                 {
00055                         return OpenForWriteTrunc ( _rFileName );
00056                 }
00060                 bool Open ( const std::string& _rFileName, bool _bAppend )
00061                 {
00062                         if ( _bAppend )
00063                         {
00064                                 return OpenForWriteAppend ( _rFileName );
00065                         }
00066                         else
00067                         {
00068                                 return OpenForWriteTrunc ( _rFileName );
00069                         }
00070                 }
00075                 int Write ( const char* _strBuf, size_t _tLen )
00076                 {
00077                         assert ( Good() );
00078                         return fwrite ( reinterpret_cast<const void*> ( _strBuf ), sizeof ( char ), _tLen, GetFile() );
00079                 }
00082                 int Write ( const std::string& _str )
00083                 {
00084                         long lLen = _str.length();
00085                         int iVal = Write ( lLen );
00086                         return ( iVal+Write ( _str.data(), lLen ) );
00087                 }
00091                 int Write ( char _cVal )
00092                 {
00093                         return Write ( reinterpret_cast<const char*> ( &_cVal ), sizeof ( char ) );
00094                 }
00098                 int Write ( unsigned char _ucVal )
00099                 {
00100                         return Write ( reinterpret_cast<const char*> ( &_ucVal ), sizeof ( unsigned char ) );
00101                 }
00105                 int Write ( short _sVal )
00106                 {
00107                         return Write ( reinterpret_cast<const char*> ( &_sVal ), sizeof ( short ) );
00108                 }
00112                 int Write ( unsigned short _usVal )
00113                 {
00114                         return Write ( reinterpret_cast<const char*> ( &_usVal ), sizeof ( unsigned short ) );
00115                 }
00119                 int Write ( long _lVal )
00120                 {
00121                         return Write ( reinterpret_cast<const char*> ( &_lVal ), sizeof ( long ) );
00122                 }
00126                 int Write ( unsigned long _ulVal )
00127                 {
00128                         return Write ( reinterpret_cast<const char*> ( &_ulVal ), sizeof ( unsigned long ) );
00129                 }
00133                 int Write ( size_t _tVal )
00134                 {
00135                         return Write ( reinterpret_cast<const char*> ( &_tVal ), sizeof ( size_t ) );
00136                 }
00140                 int Write ( float _fVal )
00141                 {
00142                         return Write ( reinterpret_cast<const char*> ( &_fVal ), sizeof ( float ) );
00143                 }
00147                 int Write ( double _dVal )
00148                 {
00149                         return Write ( reinterpret_cast<const char*> ( &_dVal ), sizeof ( double ) );
00150                 }
00151 };
00152 

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