00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _FLU_SIMPLE_STRING_H
00017 #define _FLU_SIMPLE_STRING_H
00018
00019 #include <stdio.h>
00020 #include <string.h>
00021 #include <stdlib.h>
00022 #include <ctype.h>
00023
00024 #include "FLU/Flu_Enumerations.h"
00025
00027 class FLU_EXPORT FluSimpleString
00028 {
00029
00030 public:
00031
00033 FluSimpleString();
00034
00036 FluSimpleString( unsigned int len );
00037
00039 FluSimpleString( const char *s );
00040
00042 FluSimpleString( const FluSimpleString& s );
00043
00045 ~FluSimpleString();
00046
00048 inline const char* c_str() const { return str; }
00049
00051 inline int size() const { return strlen(str); }
00052
00054 inline char& operator [](int i) { return str[i]; }
00055
00057 inline char operator [](int i) const { return str[i]; }
00058
00060 FluSimpleString substr( int pos, int len ) const;
00061
00063 void upcase();
00064
00066 void downcase();
00067
00069 int find( char c ) const;
00070
00072 int rfind( char c ) const;
00073
00075 int compare( const FluSimpleString &s ) const;
00076
00078 int casecompare( const FluSimpleString &s ) const;
00079
00081 inline friend int compare( const FluSimpleString &s1, const FluSimpleString &s2 )
00082 { return s1.compare( s2 ); }
00083
00085 inline friend int casecompare( const FluSimpleString &s1, const FluSimpleString &s2 )
00086 { return s1.casecompare( s2 ); }
00087
00089 inline void push_back( char c )
00090 { char s[2] = { c, '\0' }; *this += s; }
00091
00093 inline void copy( const FluSimpleString& s )
00094 { *this = s; }
00095
00097 inline void copy( const char *s )
00098 { *this = s; }
00099
00101 inline void copy( const FluSimpleString& s, unsigned int start, unsigned int len )
00102 { copy( s.c_str(), start, len ); }
00103
00105 void copy( const char *s, unsigned int start, unsigned int len );
00106
00108 FluSimpleString& operator =( const char *s );
00109
00111 inline FluSimpleString& operator =( FluSimpleString s ) { return( *this = s.str ); }
00112
00114 inline bool operator <( const FluSimpleString& s ) const { return( strcmp( str, s.str ) < 0 ); }
00115
00117 inline bool operator >( const FluSimpleString& s ) const { return( strcmp( str, s.str ) > 0 ); }
00118
00120 inline bool operator ==( const FluSimpleString& s ) const { return( strcmp( str, s.str ) == 0 ); }
00121
00123 inline bool operator !=( const FluSimpleString& s ) const { return( strcmp( str, s.str ) != 0 ); }
00124
00126 inline friend FluSimpleString operator +( const char *s1, FluSimpleString s2 ) { FluSimpleString s = s1; s += s2; return s; }
00127
00129 inline friend FluSimpleString operator +( FluSimpleString s1, const char *s2 ) { FluSimpleString s = s1; s += s2; return s; }
00130
00132 inline friend FluSimpleString operator +( FluSimpleString s1, FluSimpleString s2 ) { FluSimpleString s = s1; s += s2; return s; }
00133
00135 inline FluSimpleString& operator +=( const FluSimpleString& s ) { *this += s.str; return *this; }
00136
00138 FluSimpleString& operator +=( const char *s );
00139
00140 private:
00141
00142 char *str;
00143
00144 };
00145
00146 #endif
00147