From 58d5ac863b8f94f74b20edee7604f33cca186b2f Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 25 Mar 2007 21:13:52 +0000 Subject: Some more updates to Hash and FString. --- src/fstring.h | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/hash.h | 10 +++++++++ 2 files changed, 77 insertions(+) (limited to 'src') diff --git a/src/fstring.h b/src/fstring.h index 2f7dc67..f0462cb 100644 --- a/src/fstring.h +++ b/src/fstring.h @@ -76,6 +76,33 @@ public: //copyFrom( rSrc ); } + FBasicString( const MyType &rSrc, long nLength ) : + nLength( 0 ), + pnRefs( NULL ), + pFirst( NULL ), + pLast( NULL ) + { + append( rSrc.pFirst->pData, nLength ); + } + + FBasicString( const MyType &rSrc, long nStart, long nLength ) : + nLength( 0 ), + pnRefs( NULL ), + pFirst( NULL ), + pLast( NULL ) + { + append( rSrc.pFirst->pData+nStart, nLength ); + } + + FBasicString( long nSize ) : + nLength( nSize ), + pnRefs( NULL ), + pFirst( NULL ), + pLast( NULL ) + { + pFirst = pLast = newChunk( nSize ); + } + virtual ~FBasicString() { clear(); @@ -190,6 +217,14 @@ public: return (*this); } + + MyType &operator +=( const MyType &rSrc ) + { + rSrc.flatten(); + append( rSrc.pFirst->pData, rSrc.nLength ); + + return (*this); + } MyType &operator +=( const chr pData ) { @@ -294,6 +329,38 @@ public: || pFirst->pData[nIndex]=='\r' || pFirst->pData[nIndex]=='\n'; } + bool isAlpha( long nIndex ) const + { + flatten(); + + return (pFirst->pData[nIndex] >= 'a' && pFirst->pData[nIndex] <= 'z') + || (pFirst->pData[nIndex] >= 'A' && pFirst->pData[nIndex] <= 'Z'); + } + + void toLower() + { + flatten(); + unShare(); + + for( long j = 0; j < nLength; j++ ) + { + if( pFirst->pData[j] >= 'A' && pFirst->pData[j] <= 'Z' ) + pFirst->pData[j] -= 'A'-'a'; + } + } + + void toUpper() + { + flatten(); + unShare(); + + for( long j = 0; j < nLength; j++ ) + { + if( pFirst->pData[j] >= 'a' && pFirst->pData[j] <= 'z' ) + pFirst->pData[j] += 'A'-'a'; + } + } + void serialize( class Serializer &ar ) { if( ar.isLoading() ) diff --git a/src/hash.h b/src/hash.h index aa02960..e819379 100644 --- a/src/hash.h +++ b/src/hash.h @@ -119,6 +119,16 @@ public: return nval; } + + _value *operator->() + { + if( bFilled == false ) + throw HashException( + excodeNotFilled, + "No data assosiated with that key." + ); + return pValue; + } }; template -- cgit v1.2.3