Main Page   Class Hierarchy   Compound List   File List   Compound Members  

glstring.h

00001 /*--License:
00002         Kyra Sprite Engine
00003         Copyright Lee Thomason (Grinning Lizard Software) 2001-2002
00004         www.grinninglizard.com/kyra
00005         www.sourceforge.net/projects/kyra
00006 
00007         Kyra is provided under 2 licenses:
00008 
00009         - The GPL, with no additional restrictions.
00010         - The LGPL, provided you display the Kyra splash screen, described below.
00011 
00012 
00013 --- GPL License --
00014         This program is free software; you can redistribute it and/or
00015         modify it under the terms of the GNU General Public License
00016         as published by the Free Software Foundation; either version 2
00017         of the License, or (at your option) any later version.
00018 
00019         This program is distributed in the hope that it will be useful,
00020         but WITHOUT ANY WARRANTY; without even the implied warranty of
00021         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022         GNU General Public License for more details.
00023 
00024         You should have received a copy of the GNU General Public License
00025         along with this program; if not, write to the Free Software
00026         Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00027 
00028         The full text of the license can be found in license.txt
00029 
00030 
00031 --- LGPL License --
00032   **Provided you kindly display the Kyra splash screen (details below), 
00033         you     may use the LGPL license:**
00034 
00035     This library is free software; you can redistribute it and/or
00036     modify it under the terms of the GNU Lesser General Public
00037     License as published by the Free Software Foundation; either
00038     version 2.1 of the License, or (at your option) any later version.
00039 
00040     This library is distributed in the hope that it will be useful,
00041     but WITHOUT ANY WARRANTY; without even the implied warranty of
00042     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00043     Lesser General Public License for more details.
00044 
00045     You should have received a copy of the GNU Lesser General Public
00046     License along with this library; if not, write to the Free Software
00047     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00048 
00049         The full text of the license can be found in lgpl.txt
00050 
00051 
00052 --- Kyra Splash Screen.
00053 
00054         It would be appreciate if you display the Kyra splash screen when using
00055         either license, however it is only required for the LGPL. All the
00056         resources for the splash are compiled into the library, and it can be
00057         accessed through the following API:
00058 
00059                 KrEngine::StartSplash
00060                 KrEngine::UpdateSplash
00061                 KrEngine::EndSplash
00062 
00063         Full documentation is provided with the KrEngine class. The splash screen
00064         should be displayed for 2 seconds.
00065 
00066         Thank you.
00067 */
00068 
00069 #ifndef KYRA_STRING16_INCLUDED
00070 #define KYRA_STRING16_INCLUDED
00071 
00072 // Disable the no-exception handling warning.
00073 #pragma warning( disable : 4530 )
00074 #pragma warning( disable : 4786 )
00075 
00076 #include "gltypes.h"
00077 #include "gldynarray.h"
00078 #include <string>
00079 
00080 
00081 class GlString
00082 {
00083   public:
00084 
00085         static bool IsSpace( char p, const char* delimiter, bool useIsSpace );
00086 
00087         static const char* SkipWhiteSpace(      const char* p,
00088                                                                                 const char* delimiter,
00089                                                                                 bool useIsSpace );
00090 
00091         static bool IEqual( const std::string& s1, const std::string& s2 );
00092         static void AppendInt( std::string* s, int i );
00093 
00094         // Removes all white space in the given string.
00095         static void RemoveWhiteSpace( std::string* s );
00096 
00097         /* Creates an array of strings by splitting 'this' by
00098                 the specified delimeters. 'this' will remain unchanged.
00099                 The returned DynArray will need to be delete'd
00100 
00101                 @param delimeter        An array of characters, any of which
00102                                                         signals a split point.
00103                 @param useIsSpace       Use the ctype 'isspace' call to determine
00104                                                         if a character is a delimeter.
00105         */
00106         static void Split(      GlDynArray<std::string>* output,
00107                                                 const std::string& input, 
00108                                                 const char* delimiter, 
00109                                                 bool useIsSpace );
00110 
00111         /* Assuming 'this' is a filename or url, changes (or adds)
00112                 the extension. The extension can be any number of letters,
00113                 and should be passed in without the leading period.
00114         */
00115         static void SetExtension( std::string*, const char* extension );
00116 
00117   private:
00118         static const char* ReadWord(    const char* p, 
00119                                                                         std::string* word, 
00120                                                                         const char* delimiter,
00121                                                                         bool useIsSpace );
00122 };
00123 
00124 inline bool StrEqual( const char* s1, const char* s2 )
00125 {
00126         return ( s1 && s2 && strcmp( s1, s2 ) == 0 );
00127 }
00128 
00129 #endif

Generated on Fri Feb 7 20:44:20 2003 for Kyra by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001