00001 /* 00002 * Copyright (C) 2009, Edmundo Albuquerque de Souza e Silva. 00003 * 00004 * This file may be distributed under the terms of the Q Public License 00005 * as defined by Trolltech AS of Norway and appearing in the file 00006 * LICENSE.QPL included in the packaging of this file. 00007 * 00008 * THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING 00009 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00010 * PURPOSE. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, 00011 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 00012 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00013 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 00014 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00015 * 00016 */ 00017 00018 #ifndef __TSTRING_H__ 00019 #define __TSTRING_H__ 00020 00021 #include <stdlib.h> 00022 #include <stdio.h> 00023 #include <stdarg.h> 00024 #include <string.h> 00025 00026 class TString 00027 { 00028 private: 00029 char *actual_string; 00030 00031 public: 00032 // Construction & Deconstruction 00033 TString ( const char * = NULL ); 00034 TString ( const TString & ); 00035 ~TString( void ); 00036 00037 // General purpose access methods 00038 inline operator const char * ( void ) const { return actual_string; }; 00039 int Length( void ) const; 00040 00041 int IndexOf( const char ) const; 00042 int IndexOf( const char * ) const; 00043 00044 int LastIndexOf( const char ) const; 00045 int LastIndexOf( const char * ) const; 00046 00047 const TString Substring( int ) const; 00048 const TString Substring( int, int ) const; 00049 00050 bool BeginsWith( const char * ) const; 00051 00052 void Format( const char *, ... ); 00053 00054 // Assignment methods 00055 const TString & operator = ( const char * ); 00056 const TString & operator = ( const TString & ); 00057 00058 const TString & operator += ( const char * ); 00059 const TString & operator += ( const TString & ); 00060 00061 friend const TString operator + ( const TString &, const TString & ); 00062 00063 friend bool operator == ( const TString &, const TString & ); 00064 friend bool operator != ( const TString &, const TString & ); 00065 }; 00066 00067 #endif /* __TSTRING_H__ */