From 9e85e4d8f31fcfa97cc95e43fa8c3b51434dcb7b Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 28 Feb 2007 07:40:56 +0000 Subject: Made updates to the staticstring, it works better with const situations now... --- src/staticstring.cpp | 14 +++++++++++++- src/staticstring.h | 4 +++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/staticstring.cpp b/src/staticstring.cpp index 4d60b8d..60f130f 100644 --- a/src/staticstring.cpp +++ b/src/staticstring.cpp @@ -46,6 +46,13 @@ StaticString::StaticString( StaticString &xSrcStr ) setString( xSrcStr, -1 ); } +StaticString::StaticString( const StaticString &xSrcStr ) +{ + nLen = xSrcStr.getLength(); + lpStr = new char[nLen]; + memcpy( lpStr, xSrcStr.getString(), nLen ); +} + StaticString::~StaticString() { if( lpStr != NULL ) delete[] lpStr; @@ -56,7 +63,12 @@ char *StaticString::getString() return lpStr; } -int StaticString::getLength() +const char *StaticString::getString() const +{ + return lpStr; +} + +int StaticString::getLength() const { return nLen; } diff --git a/src/staticstring.h b/src/staticstring.h index 0d155c4..4c3f7b8 100644 --- a/src/staticstring.h +++ b/src/staticstring.h @@ -20,11 +20,13 @@ public: StaticString( const char *lpNewStr ); StaticString( StaticString &xSrcStr, int nNewLen ); StaticString( StaticString &xSrcStr ); + StaticString( const StaticString &xSrcStr ); StaticString( int nLength ); virtual ~StaticString(); char *getString(); - int getLength(); + const char *getString() const; + int getLength() const; void setLength( int nNewLength ); void setString( const char *lpNewStr, int nNewLen=-1 ); -- cgit v1.2.3