added functions strLen strCpy and strCat
This commit is contained in:
parent
d365bb7cf5
commit
fef3c01532
|
@ -76,6 +76,55 @@ static const char fileid[] = "$Id$";
|
||||||
|
|
||||||
/* ============================================================= module code */
|
/* ============================================================= 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[]
|
* Duplicate a string by allocating space with new[]
|
||||||
* The returned string must be freed with delete[]
|
* The returned string must be freed with delete[]
|
||||||
|
@ -142,6 +191,9 @@ Util :: strToL( const char * str,
|
||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
$Log$
|
$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
|
Revision 1.3 2000/11/09 06:44:21 darkeye
|
||||||
added strEq and strToL functions
|
added strEq and strToL functions
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,20 @@ class Util
|
||||||
|
|
||||||
public:
|
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 *
|
static char *
|
||||||
strDup ( const char * str ) throw ( Exception );
|
strDup ( const char * str ) throw ( Exception );
|
||||||
|
|
||||||
|
@ -123,6 +137,9 @@ class Util
|
||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
$Log$
|
$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
|
Revision 1.2 2000/11/09 06:44:21 darkeye
|
||||||
added strEq and strToL functions
|
added strEq and strToL functions
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue