dataresource.h

00001 /*--License:
00002         Kyra Sprite Engine
00003         Copyright Lee Thomason (Grinning Lizard Software) 2001-2005
00004         www.grinninglizard.com/kyra
00005         www.sourceforge.net/projects/kyra
00006 
00007         Kyra is provided under the LGPL. 
00008         
00009         I kindly request you display a splash screen (provided in the HTML documentation)
00010         to promote Kyra and acknowledge the software and everyone who has contributed to it, 
00011         but it is not required by the license.
00012 
00013 --- LGPL License --
00014 
00015     This library is free software; you can redistribute it and/or
00016     modify it under the terms of the GNU Lesser General Public
00017     License as published by the Free Software Foundation; either
00018     version 2.1 of the License, or (at your option) any later version.
00019 
00020     This library is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00023     Lesser General Public License for more details.
00024 
00025     You should have received a copy of the GNU Lesser General Public
00026     License along with this library; if not, write to the Free Software
00027     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 
00029         The full text of the license can be found in lgpl.txt
00030 */
00031 
00032 #ifndef KYRA_DATASOURCE_INCLUDED
00033 #define KYRA_DATASOURCE_INCLUDED
00034 
00035 #ifdef _MSC_VER
00036 // Disable the no-exception handling warning.
00037 #pragma warning( disable : 4530 )
00038 #pragma warning( disable : 4786 )
00039 #endif
00040 
00041 #include "kyraresource.h"
00042 
00043 
00060 class KrTextDataResource : public KrResource
00061 {
00062   public:
00063         // Create by reading from a .dat file
00064         KrTextDataResource( U32 size, SDL_RWops* data );
00065         // Create from file
00066         KrTextDataResource( const std::string& resourceName );
00067 
00068         virtual ~KrTextDataResource()                                           {}
00069 
00070         virtual U32 Type()                                                                      { return KYRATAG_TEXTDATA; }
00071         virtual const std::string&      TypeName()                              { return textName; }
00072         virtual KrTextDataResource* ToTextDataResource()        { return this; }
00073 
00077         const char* Text()                                                                      { return text.c_str(); }
00078         const std::string& TextString()                                         { return text; }
00079 
00082         void Text( std::vector< std::string >* strings );
00083 
00084         // [internal]
00085         virtual void Save( KrEncoder* );
00086         bool LoadTextFile( const char* fname );
00087 
00088   private:
00089         const static std::string textName;
00090         std::string text;
00091 };
00092 
00093 
00104 class KrBinaryDataResource : public KrResource
00105 {
00106   public:
00107         // Create by reading from a .dat file
00108         KrBinaryDataResource( U32 size, SDL_RWops* data );
00109         KrBinaryDataResource( const std::string& resourceName );
00110         virtual ~KrBinaryDataResource()                                         { delete [] data; }
00111 
00112         virtual U32 Type()                                                                      { return KYRATAG_BINARYDATA; }
00113         virtual const std::string&      TypeName()                              { return binaryName; }
00114         virtual KrBinaryDataResource* ToBinaryDataResource()    { return this; }
00115 
00117         const U8* Data()                                                                        { return data; }
00119         int Length()                                                                    { return length; }
00120 
00121         // [internal]
00122         virtual void Save( KrEncoder* );
00123         bool LoadFile( const char* fname );
00124 
00125   private:
00126         const static std::string binaryName;
00127         U8* data;
00128         int length;
00129 };
00130 
00131 #endif

Generated on Thu Jul 20 20:45:31 2006 for Kyra by  doxygen 1.4.7