cmText.h/c : Added cmTextSysIsStored() and cmTsIsStored().
This commit is contained in:
parent
5464cbf4e4
commit
f9f9873eaf
22
cmText.c
22
cmText.c
@ -148,6 +148,12 @@ void cmTextSysFreeStr( cmTextSysH_t h, const cmChar_t* s )
|
||||
cmLhFree(p->lhH,(cmChar_t*)s);
|
||||
}
|
||||
|
||||
bool cmTextSysIsStored(cmTextSysH_t h, const cmChar_t* s )
|
||||
{
|
||||
cmTextSys_t* p = _cmTextSysHandleToPtr(h);
|
||||
return cmLHeapIsPtrInHeap(p->lhH,s);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Global interface
|
||||
@ -203,6 +209,8 @@ cmChar_t* cmTsPrintf( const cmChar_t* fmt, ... )
|
||||
void cmTsFreeStr( const cmChar_t* s )
|
||||
{ cmTextSysFreeStr(_cmTextSysGlobalH,s); }
|
||||
|
||||
bool cmTsIsStored( const cmChar_t* s )
|
||||
{ return cmTextSysIsStored(_cmTextSysGlobalH,s); }
|
||||
|
||||
cmChar_t* cmTsVPrintfP( cmChar_t* s, const cmChar_t* fmt, va_list vl )
|
||||
{
|
||||
@ -615,6 +623,20 @@ bool cmTextIsEmpty( const cmChar_t* s )
|
||||
bool cmTextIsNotEmpty( const cmChar_t* s )
|
||||
{ return !cmTextIsEmpty(s); }
|
||||
|
||||
int cmTextCmp( const cmChar_t* s0, const cmChar_t* s1 )
|
||||
{
|
||||
if( s0 == NULL && s1 == NULL )
|
||||
return 0;
|
||||
|
||||
if( s0 == NULL || s1 == NULL )
|
||||
{
|
||||
if( s0 == NULL )
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return strcmp(s0,s1);
|
||||
}
|
||||
|
||||
cmChar_t* cmTextLine( cmChar_t* s, unsigned line )
|
||||
{
|
||||
|
7
cmText.h
7
cmText.h
@ -52,6 +52,8 @@ extern "C" {
|
||||
cmChar_t* cmTextSysVPrintf( cmTextSysH_t h, const cmChar_t* fmt, va_list vl );
|
||||
cmChar_t* cmTextSysPrintf( cmTextSysH_t h, const cmChar_t* fmt, ... );
|
||||
void cmTextSysFreeStr( cmTextSysH_t h, const cmChar_t* s );
|
||||
// Return true if 's' is stored in the text systems internal heap,
|
||||
bool cmTextSysIsStored(cmTextSysH_t h, const cmChar_t* s );
|
||||
|
||||
//
|
||||
// Global interface:
|
||||
@ -71,6 +73,7 @@ extern "C" {
|
||||
cmChar_t* cmTsVPrintf( const cmChar_t* fmt, va_list vl );
|
||||
cmChar_t* cmTsPrintf( const cmChar_t* fmt, ... );
|
||||
void cmTsFreeStr( const cmChar_t* s );
|
||||
bool cmTsIsStored(const cmChar_t* s );
|
||||
|
||||
// Print a formatted string into s[]. s[] is reallocated as necessary to
|
||||
// hold the string. s must be freed by the caller via cmMemFree().
|
||||
@ -196,6 +199,10 @@ extern "C" {
|
||||
bool cmTextIsEmpty( const cmChar_t* s );
|
||||
bool cmTextIsNotEmpty( const cmChar_t* s );
|
||||
|
||||
// Same as strcmp() but handles NULL. Note that if both s0 and s1 are NULL
|
||||
// then return is 0.
|
||||
int cmTextCmp( const cmChar_t* s0, const cmChar_t* s1 );
|
||||
|
||||
// Returns NULL if string contains fewer than lineIdx lines.
|
||||
// Note: first line == 1.
|
||||
cmChar_t* cmTextLine( cmChar_t* s, unsigned line );
|
||||
|
Loading…
Reference in New Issue
Block a user