Main Page   Class Hierarchy   Compound List   File List   Compound Members  

glstring.h

00001 /*
00002 Copyright (c) 2000-2003 Lee Thomason (www.grinninglizard.com)
00003 
00004 Grinning Lizard Utilities. Note that software that uses the 
00005 utility package (including Lilith3D and Kyra) have more restrictive
00006 licences which applies to code outside of the utility package.
00007 
00008 
00009 This software is provided 'as-is', without any express or implied 
00010 warranty. In no event will the authors be held liable for any 
00011 damages arising from the use of this software.
00012 
00013 Permission is granted to anyone to use this software for any 
00014 purpose, including commercial applications, and to alter it and 
00015 redistribute it freely, subject to the following restrictions:
00016 
00017 1. The origin of this software must not be misrepresented; you must 
00018 not claim that you wrote the original software. If you use this 
00019 software in a product, an acknowledgment in the product documentation 
00020 would be appreciated but is not required.
00021 
00022 2. Altered source versions must be plainly marked as such, and 
00023 must not be misrepresented as being the original software.
00024 
00025 3. This notice may not be removed or altered from any source 
00026 distribution.
00027 */
00028 
00029 #ifndef KYRA_STRING16_INCLUDED
00030 #define KYRA_STRING16_INCLUDED
00031 
00032 // Disable the no-exception handling warning.
00033 #pragma warning( disable : 4530 )
00034 #pragma warning( disable : 4786 )
00035 
00036 #include "gltypes.h"
00037 #include "gldynarray.h"
00038 #include <string>
00039 
00040 
00041 class GlString
00042 {
00043   public:
00044 
00045         static bool IsSpace( char p, const char* delimiter, bool useIsSpace );
00046 
00047         static const char* SkipWhiteSpace(      const char* p,
00048                                                                                 const char* delimiter,
00049                                                                                 bool useIsSpace );
00050 
00051         static bool IEqual( const std::string& s1, const std::string& s2 );
00052         static void AppendInt( std::string* s, int i );
00053 
00054         // Removes all white space in the given string.
00055         static void RemoveWhiteSpace( std::string* s );
00056 
00057         /* Creates an array of strings by splitting 'this' by
00058                 the specified delimeters. 'this' will remain unchanged.
00059                 The returned DynArray will need to be delete'd
00060 
00061                 @param delimeter        An array of characters, any of which
00062                                                         signals a split point.
00063                 @param useIsSpace       Use the ctype 'isspace' call to determine
00064                                                         if a character is a delimeter.
00065         */
00066         static void Split(      GlDynArray<std::string>* output,
00067                                                 const std::string& input, 
00068                                                 const char* delimiter, 
00069                                                 bool useIsSpace );
00070 
00071         /* Assuming 'this' is a filename or url, changes (or adds)
00072                 the extension. The extension can be any number of letters,
00073                 and should be passed in without the leading period.
00074         */
00075         static void SetExtension( std::string*, const char* extension );
00076 
00077   private:
00078         static const char* ReadWord(    const char* p, 
00079                                                                         std::string* word, 
00080                                                                         const char* delimiter,
00081                                                                         bool useIsSpace );
00082 };
00083 
00084 inline bool StrEqual( const char* s1, const char* s2 )
00085 {
00086         return ( s1 && s2 && strcmp( s1, s2 ) == 0 );
00087 }
00088 
00089 #endif

Generated on Mon Sep 15 12:01:10 2003 for Kyra by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001