added functions strLen strCpy and strCat

This commit is contained in:
darkeye 2000-11-09 22:04:33 +00:00
parent d365bb7cf5
commit fef3c01532
2 changed files with 74 additions and 5 deletions

View File

@ -76,6 +76,55 @@ static const char fileid[] = "$Id$";
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Calculate the length of a zero-terminated C string,
* w/o the zero-termination
*----------------------------------------------------------------------------*/
unsigned int
Util :: strLen( const char * str ) throw ( Exception )
{
size_t len;
if ( !str ) {
throw Exception( __FILE__, __LINE__, "no str");
}
len = strlen( str);
return len;
}
/*------------------------------------------------------------------------------
* Copy the contents of a string into another
*----------------------------------------------------------------------------*/
void
Util :: strCpy ( char * dest,
const char * src ) throw ( Exception )
{
if ( !dest || !src ) {
throw Exception( __FILE__, __LINE__, "no src or dest");
}
strcpy( dest, src);
}
/*------------------------------------------------------------------------------
* Concatenate the contents of a string onto another
*----------------------------------------------------------------------------*/
void
Util :: strCat ( char * dest,
const char * src ) throw ( Exception )
{
if ( !dest || !src ) {
throw Exception( __FILE__, __LINE__, "no src or dest");
}
strcat( dest, src);
}
/*------------------------------------------------------------------------------
* Duplicate a string by allocating space with new[]
* The returned string must be freed with delete[]
@ -142,6 +191,9 @@ Util :: strToL( const char * str,
$Source$
$Log$
Revision 1.4 2000/11/09 22:04:33 darkeye
added functions strLen strCpy and strCat
Revision 1.3 2000/11/09 06:44:21 darkeye
added strEq and strToL functions

View File

@ -93,6 +93,20 @@ class Util
public:
static unsigned int
strLen ( const char * str ) throw ( Exception );
static void
strCpy ( char * dest,
const char * src ) throw ( Exception );
static void
strCat ( char * dest,
const char * src ) throw ( Exception );
static char *
strDup ( const char * str ) throw ( Exception );
@ -123,6 +137,9 @@ class Util
$Source$
$Log$
Revision 1.3 2000/11/09 22:04:33 darkeye
added functions strLen strCpy and strCat
Revision 1.2 2000/11/09 06:44:21 darkeye
added strEq and strToL functions