Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

lkstring.h

00001 /* liblookdb: lkstring.h - String that inherits from looktypebase Mmmm... multiple inheritance It gains some useful methods over string 
00002     Copyright (C) 1998-2001 LOOK Systems
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Lesser General Public
00006     License as published by the Free Software Foundation; either
00007     version 2.1 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Lesser General Public License for more details.
00013 
00014     You should have received a copy of the GNU Lesser General Public
00015     License along with this library; if not, write to the Free Software
00016     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 */
00018 #ifndef LIBLOOKDB_LKSTRING_H
00019 #define LIBLOOKDB_LKSTRING_H
00020 
00021 // $Id: lkstring.h,v 1.6 2001/07/04 15:53:20 clive Exp $
00022 
00023 #include "looktypes.h"
00024 #include "lktypebase.h"
00025 #include <string>
00026 
00027 namespace look {
00028 
00029 // *****************************************************
00030 // LookString class
00031 // *****************************************************
00032 
00033 // now the base class depends on which compiler we're using
00034 // microsoft can't cope with eg LookString() : std::string {}
00035 // so have to use string on it's own and a using directive
00036 // g++ works properly
00037 // i don't want too many using directives in the standard classes
00038 
00039 #ifdef WIN32
00040 #define stringBaseType string
00041 using std::string;
00042 #else
00043 #define stringBaseType std::string
00044 #endif
00045 
00047 
00056 class LOOKTYPES_DLL LookString : public stringBaseType, public LookTypeBase
00057 {
00058 public:
00059 
00060         // enums
00062         enum StripType
00063         {
00064                 leading = 1,
00065                 trailing,
00066                 both
00067         };
00068 
00069         // Lots of constructors (based on std::string)
00070         LookString( const char* theString );
00071         LookString( const char* theString, stringBaseType::size_type theSize );
00072         LookString( const LookString& theString );
00073         LookString( const LookString& theString, stringBaseType::size_type theStart, stringBaseType::size_type theSize );
00074 
00075         LookString( const stringBaseType& theString );
00076 
00077         // note this is the opposite to the RW one which is char, size
00078         LookString( stringBaseType::size_type theSize, char theChar );
00079         LookString();
00080 
00081 // Destructor.
00082         ~LookString( void );
00083 
00084 // Assignment operators
00085         LookString &operator=( const LookString &theOther );
00086         LookString &operator=( const char* theString );
00087         LookString &operator=( stringBaseType theString );
00088         // assign from char not implemented - a bit too like
00089         // aString = 4; ie nonsense
00090 
00091 // [] op
00092         char& operator[]( int position );
00093         char operator[]( int position ) const;
00094 
00095 // cast to const char*
00096         operator const char*( void ) const;
00097 
00098 // get a copy
00099         LookTypeBase* GetNewCopy( void ) const;
00100 
00101 // get my id
00102         long GetTypeID( void ) const;
00103 
00104 // other methods
00105 
00106         // like RWCString::strip 'cept strips self, no default parameters
00107         // the second one is used for stripping multiple stuff,
00108         // eg whitespace ( use " \t\n" )
00109         // the third one does the opposite of the second (strips where not in
00110         // theChars )
00111         void Strip( StripType theStripType, char theChar );
00112         void Strip( StripType theStripType, const LookString& theChars );
00113         void StripNotIn( StripType theStripType, const LookString& theChars );
00114 
00115         void ToLower( void );
00116         void ToUpper( void );
00117 
00118         // replace strings, return a count of how many we did
00119         int ReplaceStrings( const LookString& theFromString,
00120                 const LookString& theToString );
00121 
00122 protected:
00123 
00124 };
00125 
00126 
00127 } // end of "look" namespace
00128 #endif

Generated at Thu Jan 17 12:53:06 2002 for liblookdb by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001