K3dTextWriteFile.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 K3dTextWriteFile : public K3dFile
00039 {
00040         public:
00041                 K3dTextWriteFile()      {}
00042                 K3dTextWriteFile ( const std::string& _rFileName )
00043                 {
00044                         Open ( _rFileName );
00045                 }
00046                 K3dTextWriteFile ( const std::string& _rFileName, bool _bAppend )
00047                 {
00048                         Open ( _rFileName, _bAppend );
00049                 }
00053                 bool Open ( const std::string &_rFileName )
00054                 {
00055                         return OpenForWriteTextTrunc ( _rFileName );
00056                 }
00061                 bool Open ( const std::string& _rFileName, bool _bAppend )
00062                 {
00063                         if ( _bAppend )
00064                         {
00065                                 return OpenForWriteTextAppend ( _rFileName );
00066                         }
00067                         else
00068                         {
00069                                 return OpenForWriteTextTrunc ( _rFileName );
00070                         }
00071                 }
00076                 int Write ( const char* _str )
00077                 {
00078                         size_t tLen = strlen ( _str );
00079                         return fwrite ( reinterpret_cast<const void*> ( _str ), sizeof ( char ), tLen, GetFile() );
00080                 }
00085                 int Write ( const std::string& _str )
00086                 {
00087                         return fwrite ( reinterpret_cast<const void*> ( _str.data() ), sizeof ( char ), _str.length(), GetFile() );
00088                 }
00089 };
00090 

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