diff options
Diffstat (limited to 'src')
23 files changed, 1429 insertions, 731 deletions
diff --git a/src/kvilib/core/kvi_pointerhashtable.h b/src/kvilib/core/kvi_pointerhashtable.h index 61c5bd0bd..4d30257d9 100644 --- a/src/kvilib/core/kvi_pointerhashtable.h +++ b/src/kvilib/core/kvi_pointerhashtable.h @@ -277,7 +277,7 @@ inline void kvi_hash_key_destroy(QString &,bool) inline const QString & kvi_hash_key_default(QString *) { - return KviQString::empty; + return KviQString::Empty; } template<typename Key,typename T> class KviPointerHashTable; diff --git a/src/kvilib/core/kvi_qstring.cpp b/src/kvilib/core/kvi_qstring.cpp index 84e52bd6d..631d329bd 100644 --- a/src/kvilib/core/kvi_qstring.cpp +++ b/src/kvilib/core/kvi_qstring.cpp @@ -47,530 +47,767 @@ extern unsigned char iso88591_toUpper_map[256]; namespace KviQString { // The global empty (and null) string - const QString empty; + const QString Empty; + + static char cHexDigits[16] = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f' }; - bool equalCSN(const QString &sz1,const QString &sz2,unsigned int len) + bool equalCSN(const QString & sz1, const QString & sz2, unsigned int uLen) { - if(len == 0)return true; // assume equal - const QChar * c1 = sz1.unicode(); - const QChar * c2 = sz2.unicode(); - unsigned int lmin = MY_MIN(sz1.length(),sz2.length()); - if(lmin < len)return false; - const QChar * c1e = c1 + len; + if(uLen == 0) + { + // assume equal + return true; + } + const QChar * pC1 = sz1.unicode(); + const QChar * pC2 = sz2.unicode(); + unsigned int uLMin = MY_MIN(sz1.length(),sz2.length()); + if(uLMin < uLen) + { + return false; + } + const QChar * pC1e = pC1 + uLen; - if(!c1 || !c2)return (c1 == c2); + if(!pC1 || !pC2) + { + return (pC1 == pC2); + } - while(c1 < c1e) + while(pC1 < pC1e) { - if(c1->unicode() != c2->unicode())return false; - c1++; - c2++; + if(pC1->unicode() != pC2->unicode()) + { + return false; + } + pC1++; + pC2++; } - return (c1 == c1e); + return (pC1 == pC1e); } - bool equalCIN(const QString &sz1,const QString &sz2,unsigned int len) + bool equalCIN(const QString & sz1, const QString & sz2, unsigned int uLen) { - if(len == 0)return true; // assume equal - const QChar * c1 = sz1.unicode(); - const QChar * c2 = sz2.unicode(); - unsigned int lmin = MY_MIN(sz1.length(),sz2.length()); - if(lmin < len)return false; - const QChar * c1e = c1 + len; + if(uLen == 0) + { + // assume equal + return true; + } + const QChar * pC1 = sz1.unicode(); + const QChar * pC2 = sz2.unicode(); + unsigned int uLMin = MY_MIN(sz1.length(),sz2.length()); + if(uLMin < uLen) + { + return false; + } + const QChar * pC1e = pC1 + uLen; - if(!c1 || !c2)return (c1 == c2); + if(!pC1 || !pC2) + { + return (pC1 == pC2); + } - while(c1 < c1e) + while(pC1 < pC1e) { - if(c1->toLower().unicode() != c2->toLower().unicode())return false; - c1++; - c2++; + if(pC1->toLower().unicode() != pC2->toLower().unicode()) + { + return false; + } + pC1++; + pC2++; } - return (c1 == c1e); + return (pC1 == pC1e); } - bool equalCSN(const QString &sz1,const char * sz2,unsigned int len) + bool equalCSN(const QString & sz1, const char * pc2, unsigned int uLen) { - if(len == 0)return true; // assume equal - const QChar * c1 = sz1.unicode(); - if((unsigned)sz1.length() < len)return false; - const QChar * c1e = c1 + len; + if(uLen == 0) + { + // assume equal + return true; + } + const QChar * pC1 = sz1.unicode(); + if((unsigned)sz1.length() < uLen) + { + return false; + } + const QChar * pC1e = pC1 + uLen; - if(!sz2)return !c1; - if(!c1)return !sz2; + if(!pc2) + { + return !pC1; + } + if(!pC1) + { + return !pc2; + } - while((c1 < c1e) && (*sz2)) + while((pC1 < pC1e) && (*pc2)) { - if(c1->unicode() != *sz2)return false; - c1++; - sz2++; + if(pC1->unicode() != *pc2) + { + return false; + } + pC1++; + pc2++; } - return (c1 == c1e); + return (pC1 == pC1e); } - bool equalCIN(const QString &sz1,const char * sz2,unsigned int len) + bool equalCIN(const QString & sz1, const char * pc2, unsigned int uLen) { - if(len == 0)return true; // assume equal - const QChar * c1 = sz1.unicode(); - if((unsigned)sz1.length() < len)return false; - const QChar * c1e = c1 + len; + if(uLen == 0) + { + // assume equal + return true; + } + const QChar * pC1 = sz1.unicode(); + if((unsigned)sz1.length() < uLen) + { + return false; + } + const QChar * pC1e = pC1 + uLen; - if(!sz2)return !c1; - if(!c1)return !(*sz2); + if(!pc2) + { + return !pC1; + } + if(!pC1) + { + return !(*pc2); + } - while((c1 < c1e) && (*sz2)) + while((pC1 < pC1e) && (*pc2)) { - if(c1->toLower().unicode() != tolower(*sz2))return false; - c1++; - sz2++; + if(pC1->toLower().unicode() != tolower(*pc2)) + { + return false; + } + pC1++; + pc2++; } - return (c1 == c1e); + return (pC1 == pC1e); } - // sz2 is assumed to be null terminated, sz1 is not! - bool equalCIN(const QString &sz1,const QChar *sz2,unsigned int len) + // pC2 is assumed to be null terminated, sz1 is not! + bool equalCIN(const QString & sz1, const QChar * pC2, unsigned int uLen) { - if(len == 0)return true; // assume equal - const QChar * c1 = sz1.unicode(); - if((unsigned)sz1.length() < len)return false; - const QChar * c1e = c1 + len; + if(uLen == 0) + { + // assume equal + return true; + } + const QChar * pC1 = sz1.unicode(); + if((unsigned)sz1.length() < uLen) + { + return false; + } + const QChar * pC1e = pC1 + uLen; - if(!sz2)return !c1; - if(!c1)return !(sz2->unicode()); + if(!pC2) + { + return !pC1; + } + if(!pC1) + { + return !(pC2->unicode()); + } - while((c1 < c1e) && (sz2->unicode())) + while((pC1 < pC1e) && (pC2->unicode())) { - if(c1->toLower().unicode() != sz2->toLower().unicode())return false; - c1++; - sz2++; + if(pC1->toLower().unicode() != pC2->toLower().unicode()) + { + return false; + } + pC1++; + pC2++; } - return (c1 == c1e); + return (pC1 == pC1e); } QString makeSizeReadable(size_t bytes) { - double size = bytes; - if(size<1024) - return QString(__tr2qs("%1 bytes")).arg(size,0,'f',0); + double dSize = bytes; + if(dSize < 1024) + { + return QString(__tr2qs("%1 bytes")).arg(dSize,0,'f',0); + } - size/=1024; - if(size<1024) - return QString(__tr2qs("%1 KiB")).arg(size,0,'f',3); + dSize /= 1024; + if(dSize < 1024) + { + return QString(__tr2qs("%1 KiB")).arg(dSize,0,'f',3); + } - size/=1024; - if(size<1024) - return QString(__tr2qs("%1 MiB")).arg(size,0,'f',3); + dSize /= 1024; + if(dSize < 1024) + { + return QString(__tr2qs("%1 MiB")).arg(dSize,0,'f',3); + } //Pirated DVD?;) - size/=1024; - if(size<1024) - return QString(__tr2qs("%1 GiB")).arg(size,0,'f',3); + dSize /= 1024; + if(dSize < 1024) + { + return QString(__tr2qs("%1 GiB")).arg(dSize,0,'f',3); + } //Uhm.. We are downloading a whole internet:))) - size/=1024; - return QString(__tr2qs("%1 TiB")).arg(size,0,'f',3); + dSize /= 1024; + return QString(__tr2qs("%1 TiB")).arg(dSize,0,'f',3); } - bool equalCS(const QString &sz1,const QString &sz2) + bool equalCS(const QString & sz1, const QString & sz2) { - if(sz1.length() != sz2.length())return false; + if(sz1.length() != sz2.length()) + { + return false; + } - const QChar * c1 = sz1.unicode(); - const QChar * c2 = sz2.unicode(); - const QChar * c1e = c1 + sz1.length(); + const QChar * pC1 = sz1.unicode(); + const QChar * pC2 = sz2.unicode(); + const QChar * pC1e = pC1 + sz1.length(); - if(!c1 || !c2)return (c1 == c2); + if(!pC1 || !pC2) + { + return (pC1 == pC2); + } - while(c1 < c1e) + while(pC1 < pC1e) { - if(c1->unicode() != c2->unicode())return false; - c1++; - c2++; + if(pC1->unicode() != pC2->unicode()) + { + return false; + } + pC1++; + pC2++; } - return (c1 == c1e); + return (pC1 == pC1e); } - bool equalCI(const QString &sz1,const QString &sz2) + bool equalCI(const QString & sz1, const QString & sz2) { - if(sz1.length() != sz2.length())return false; + if(sz1.length() != sz2.length()) + { + return false; + } - const QChar * c1 = sz1.unicode(); - const QChar * c2 = sz2.unicode(); - const QChar * c1e = c1 + sz1.length(); + const QChar * pC1 = sz1.unicode(); + const QChar * pC2 = sz2.unicode(); + const QChar * pC1e = pC1 + sz1.length(); - if(!c1 || !c2)return (c1 == c2); + if(!pC1 || !pC2) + { + return (pC1 == pC2); + } - while(c1 < c1e) + while(pC1 < pC1e) { - if(c1->toLower().unicode() != c2->toLower().unicode())return false; - c1++; - c2++; + if(pC1->toLower().unicode() != pC2->toLower().unicode()) + { + return false; + } + pC1++; + pC2++; } - return (c1 == c1e); + return (pC1 == pC1e); } // sz2 is assumed to be null terminated, sz1 is not! - bool equalCI(const QString &sz1,const QChar *sz2) + bool equalCI(const QString & sz1, const QChar * pC2) { - const QChar * c1 = sz1.unicode(); - const QChar * c1e = c1 + sz1.length(); + const QChar * pC1 = sz1.unicode(); + const QChar * pC1e = pC1 + sz1.length(); - if(!c1 || !sz2)return (c1 == sz2); + if(!pC1 || !pC2) + { + return (pC1 == pC2); + } - while(c1 < c1e) + while(pC1 < pC1e) { - if(!sz2->unicode())return false; // sz1 has at least another character - if(c1->toLower().unicode() != sz2->toLower().unicode())return false; - c1++; - sz2++; + if(!pC2->unicode()) + { + // sz1 has at least another character + return false; + } + if(pC1->toLower().unicode() != pC2->toLower().unicode()) + { + return false; + } + pC1++; + pC2++; } - return (c1 == c1e) && (!sz2->unicode()); + return (pC1 == pC1e) && (!pC2->unicode()); } - bool equalCS(const QString &sz1,const char * sz2) + bool equalCS(const QString & sz1, const char * pc2) { - const QChar * c1 = sz1.unicode(); - const QChar * c1e = c1 + sz1.length(); + const QChar * pC1 = sz1.unicode(); + const QChar * pC1e = pC1 + sz1.length(); - if(!c1)return !sz2; + if(!pC1) + { + return !pc2; + } - while((c1 < c1e) && (*sz2)) + while((pC1 < pC1e) && (*pc2)) { - if(c1->unicode() != *sz2)return false; - c1++; - sz2++; + if(pC1->unicode() != *pc2) + { + return false; + } + pC1++; + pc2++; } - return ((c1 == c1e) && (*sz2 == '\0')); + return ((pC1 == pC1e) && (*pc2 == '\0')); } - bool equalCI(const QString &sz1,const char * sz2) + bool equalCI(const QString & sz1, const char * pc2) { - const QChar * c1 = sz1.unicode(); - const QChar * c1e = c1 + sz1.length(); + const QChar * pC1 = sz1.unicode(); + const QChar * pC1e = pC1 + sz1.length(); - if(!c1)return !sz2; + if(!pC1) + { + return !pc2; + } - while((c1 < c1e) && (*sz2)) + while((pC1 < pC1e) && (*pc2)) { - if(c1->toLower().unicode() != tolower(*sz2))return false; - c1++; - sz2++; + if(pC1->toLower().unicode() != tolower(*pc2)) + { + return false; + } + pC1++; + pc2++; } - return ((c1 == c1e) && (*sz2 == '\0')); + return ((pC1 == pC1e) && (*pc2 == '\0')); } - int cmpCS(const QString &sz1,const QString &sz2) + int cmpCS(const QString & sz1, const QString & sz2) { - const QChar * c1 = sz1.unicode(); - const QChar * c2 = sz2.unicode(); - const QChar * c1e = c1 + sz1.length(); - const QChar * c2e = c2 + sz2.length(); + const QChar * pC1 = sz1.unicode(); + const QChar * pC2 = sz2.unicode(); + const QChar * pC1e = pC1 + sz1.length(); + const QChar * pC2e = pC2 + sz2.length(); - if(!c1) + if(!pC1) { - if(!c2)return 0; + if(!pC2) + { + return 0; + } return -1; } - if(!c2)return 1; + if(!pC2) + { + return 1; + } for(;;) { - if(c1 >= c1e) + if(pC1 >= pC1e) { - if(c2 < c2e)return /* 0 */ - (c2->unicode()); + if(pC2 < pC2e) + { + return /* 0 */ - (pC2->unicode()); + } return 0; } - if(c2 >= c2e)return c1->unicode() /* - 0 */; + if(pC2 >= pC2e) + { + return pC1->unicode() /* - 0 */; + } - int diff = c1->unicode() - c2->unicode(); - if(diff)return diff; + int iDiff = pC1->unicode() - pC2->unicode(); + if(iDiff) + { + return iDiff; + } - c1++; - c2++; + pC1++; + pC2++; } return 0; // never here } - int cmpCI(const QString &sz1,const QString &sz2,bool nonAlphaGreater) + int cmpCI(const QString & sz1, const QString & sz2, bool bNonAlphaGreater) { - const QChar * c1 = sz1.unicode(); - const QChar * c2 = sz2.unicode(); - const QChar * c1e = c1 + sz1.length(); - const QChar * c2e = c2 + sz2.length(); + const QChar * pC1 = sz1.unicode(); + const QChar * pC2 = sz2.unicode(); + const QChar * pC1e = pC1 + sz1.length(); + const QChar * pC2e = pC2 + sz2.length(); - if(!c1) + if(!pC1) { - if(!c2)return 0; + if(!pC2) + { + return 0; + } return -1; } - if(!c2)return 1; + if(!pC2) + { + return 1; + } for(;;) { - if(nonAlphaGreater) { - if(c1->isLetterOrNumber() && !c2->isLetterOrNumber()) { + if(bNonAlphaGreater) + { + if(pC1->isLetterOrNumber() && !pC2->isLetterOrNumber()) + { return -1; - } else if(!c1->isLetterOrNumber() && c2->isLetterOrNumber()) { + } else if(!pC1->isLetterOrNumber() && pC2->isLetterOrNumber()) + { return 1; } } - if(c1 >= c1e) + if(pC1 >= pC1e) { - if(c2 < c2e)return /* 0 */ - (c2->toLower().unicode()); + if(pC2 < pC2e) + { + return /* 0 */ - (pC2->toLower().unicode()); + } return 0; } - if(c2 >= c2e)return c1->toLower().unicode() /* - 0 */; + if(pC2 >= pC2e) + { + return pC1->toLower().unicode() /* - 0 */; + } - int diff = c1->toLower().unicode() - c2->toLower().unicode(); + int iDiff = pC1->toLower().unicode() - pC2->toLower().unicode(); - if(diff)return diff; + if(iDiff) + { + return iDiff; + } - c1++; - c2++; + pC1++; + pC2++; } return 0; // never here } - int cmpCIN(const QString &sz1,const QString &sz2,unsigned int len) + int cmpCIN(const QString & sz1, const QString & sz2, unsigned int uLen) { - if(len == 0)return 0; // assume equal - unsigned int l1 = MY_MIN(len,(unsigned)sz1.length()); - unsigned int l = MY_MIN(l1,(unsigned)sz2.length()); // FIXME: THIS IS NOT OK + if(uLen == 0) + { + // assume equal + return 0; + } + unsigned int u1 = MY_MIN(uLen,(unsigned)sz1.length()); + unsigned int u2 = MY_MIN(u1,(unsigned)sz2.length()); // FIXME: THIS IS NOT OK - const QChar * c1 = sz1.unicode(); - const QChar * c2 = sz2.unicode(); - const QChar * c1e = c1 + l; + const QChar * pC1 = sz1.unicode(); + const QChar * pC2 = sz2.unicode(); + const QChar * pC1e = pC1 + u2; - if(!c1) + if(!pC1) { - if(!c2)return 0; + if(!pC2) + { + return 0; + } return -1; } - if(!c2)return 1; + if(!pC2) + { + return 1; + } - int diff = 0; + int iDiff = 0; - while((c1 < c1e) && !(diff = (c1->toLower().unicode() - c2->toLower().unicode()))) + while((pC1 < pC1e) && !(iDiff = (pC1->toLower().unicode() - pC2->toLower().unicode()))) { - c1++; - c2++; + pC1++; + pC2++; } - return diff; + return iDiff; } - void ensureLastCharIs(QString &szString,const QChar &c) + void ensureLastCharIs(QString & szSrc, const QChar & c) { - if(!lastCharIs(szString,c))szString.append(c); + if(!lastCharIs(szSrc,c)) + { + szSrc.append(c); + } } - QString getToken(QString &szString,const QChar &sep) + QString getToken(QString & szSrc, const QChar & sep) { - int i=0; - while(i < szString.length()) + int i = 0; + while(i < szSrc.length()) { - if(szString[i] == sep)break; + if(szSrc[i] == sep) + { + break; + } i++; } - QString ret; - if(i == szString.length()) + QString szRet; + if(i == szSrc.length()) { - ret = szString; - szString = ""; + szRet = szSrc; + szSrc = ""; } else { - ret = szString.left(i); - while(i < szString.length()) + szRet = szSrc.left(i); + while(i < szSrc.length()) { - if(szString[i] != sep)break; + if(szSrc[i] != sep) + { + break; + } i++; } - if(i == szString.length())szString = ""; - else szString.remove(0,i); + if(i == szSrc.length()) + { + szSrc = ""; + } else { + szSrc.remove(0,i); + } } - return ret; + return szRet; } - void stripRightWhiteSpace(QString &s) + void stripRightWhiteSpace(QString & szSrc) { int iRemove = 0; - while(iRemove < s.length()) + while(iRemove < szSrc.length()) { - if(s.at(s.length() - (iRemove + 1)).isSpace())iRemove++; - else break; + if(szSrc.at(szSrc.length() - (iRemove + 1)).isSpace()) + { + iRemove++; + } else { + break; + } + } + if(iRemove > 0) + { + szSrc.remove(szSrc.length() - iRemove,iRemove); } - if(iRemove > 0)s.remove(s.length() - iRemove,iRemove); } - void stripRight(QString &s,const QChar &c) + void stripRight(QString & szSrc, const QChar & c) { int iRemove = 0; - while(iRemove < s.length()) + while(iRemove < szSrc.length()) + { + if(szSrc.at(szSrc.length() - (iRemove + 1)) == c) + { + iRemove++; + } else { + break; + } + } + if(iRemove > 0) { - if(s.at(s.length() - (iRemove + 1)) == c)iRemove++; - else break; + szSrc.remove(szSrc.length() - iRemove,iRemove); } - if(iRemove > 0)s.remove(s.length() - iRemove,iRemove); } - - void stripLeft(QString &s,const QChar &c) + + void stripLeft(QString & szSrc, const QChar & c) { int iRemove = 0; - while(iRemove < s.length()) + while(iRemove < szSrc.length()) { - if(s[iRemove] == c) + if(szSrc[iRemove] == c) + { iRemove++; - else + } else { break; + } + } + if(iRemove > 0) + { + szSrc.remove(0,iRemove); } - if(iRemove > 0)s.remove(0,iRemove); } - void detach(QString &sz) + void detach(QString & szSrc) { - sz.resize(sz.length()); + szSrc.resize(szSrc.length()); } - const QChar * nullTerminatedArray(const QString &sz) + const QChar * nullTerminatedArray(const QString & szSrc) { - //sz.resize(sz.length()); // detach! - return sz.constData(); + //szSrc.resize(szSrc.length()); // detach! + return szSrc.constData(); } - void appendNumber(QString &s,double dReal) + void appendNumber(QString & szSrc, double dReal) { - char buffer[512]; - ::sprintf(buffer,"%f",dReal); - s.append(buffer); + char cBuffer[512]; + ::sprintf(cBuffer,"%f",dReal); + szSrc.append(cBuffer); } - void appendNumber(QString &s,int iInteger) + void appendNumber(QString & szSrc, int iInteger) { - char buffer[64]; - ::sprintf(buffer,"%d",iInteger); - s.append(buffer); + char cBuffer[64]; + ::sprintf(cBuffer,"%d",iInteger); + szSrc.append(cBuffer); } - void appendNumber(QString &s,kvi_i64_t iInteger) + void appendNumber(QString & szSrc, kvi_i64_t iInteger) { - char buffer[64]; - ::sprintf(buffer,"%lld", (long long int) iInteger); - s.append(buffer); + char cBuffer[64]; + ::sprintf(cBuffer,"%lld", (long long int)iInteger); + szSrc.append(cBuffer); } - void appendNumber(QString &s,kvi_u64_t uInteger) + void appendNumber(QString & szSrc, kvi_u64_t uInteger) { - char buffer[64]; - ::sprintf(buffer,"%llu", (long long unsigned int) uInteger); - s.append(buffer); + char cBuffer[64]; + ::sprintf(cBuffer,"%llu", (long long unsigned int)uInteger); + szSrc.append(cBuffer); } - void appendNumber(QString &s,unsigned int uInteger) + void appendNumber(QString & szSrc, unsigned int uInteger) { - char buffer[64]; - ::sprintf(buffer,"%u",uInteger); - s.append(buffer); + char cBuffer[64]; + ::sprintf(cBuffer,"%u",uInteger); + szSrc.append(cBuffer); } - void vsprintf(QString &s,const QString &szFmt,kvi_va_list list) + void vsprintf(QString & szSrc, const QString & szFmt, kvi_va_list list) { #define MEMINCREMENT 32 - int reallen = 0; - int allocsize = MEMINCREMENT; + int iRealLen = 0; + int iAllocSize = MEMINCREMENT; - //s.resize(allocsize); + //szSrc.resize(allocsize); - const QChar * fmt = nullTerminatedArray(szFmt); - if(!fmt) + const QChar * pFmt = nullTerminatedArray(szFmt); + if(!pFmt) { - s = QString(); + szSrc = QString(); return; } - QChar * buffer = (QChar *)kvi_malloc(sizeof(QChar) * allocsize); + QChar * pBuffer = (QChar *)kvi_malloc(sizeof(QChar) * iAllocSize); //QChar * p = (QChar *)s.unicode(); - char *argString; - long argValue; - unsigned long argUValue; + char * pcArgString; + long lArgValue; + unsigned long ulArgValue; //9999999999999999999999999999999\0 - char numberBuffer[32]; //enough ? 10 is enough for 32bit unsigned int... - char *pNumBuf; - unsigned int tmp; + char cNumberBuffer[32]; //enough ? 10 is enough for 32bit unsigned int... + char * pcNumBuf; + unsigned int iTmp; - QChar * p = buffer; + QChar * p = pBuffer; #define INCREMENT_MEM \ { \ - allocsize += MEMINCREMENT; \ - buffer = (QChar *)kvi_realloc(buffer,sizeof(QChar) * allocsize); \ - p = buffer + reallen; \ + iAllocSize += MEMINCREMENT; \ + pBuffer = (QChar *)kvi_realloc(pBuffer,sizeof(QChar) * iAllocSize); \ + p = pBuffer + iRealLen; \ } #define INCREMENT_MEM_BY(numchars) \ { \ - allocsize += numchars + MEMINCREMENT; \ - buffer = (QChar *)kvi_realloc(buffer,sizeof(QChar) * allocsize); \ - p = buffer + reallen; \ + iAllocSize += numchars + MEMINCREMENT; \ + pBuffer = (QChar *)kvi_realloc(pBuffer,sizeof(QChar) * iAllocSize); \ + p = pBuffer + iRealLen; \ } - - for(; fmt->unicode() ; ++fmt) + for(; pFmt->unicode() ; ++pFmt) { - if(reallen == allocsize)INCREMENT_MEM + if(iRealLen == iAllocSize)INCREMENT_MEM //copy up to a '%' - if(fmt->unicode() != '%') + if(pFmt->unicode() != '%') { - *p++ = *fmt; - reallen++; + *p++ = *pFmt; + iRealLen++; continue; } - ++fmt; //skip this '%' - switch(fmt->unicode()) + ++pFmt; //skip this '%' + switch(pFmt->unicode()) { case 's': // char * string { - argString = kvi_va_arg(list,char *); - if(!argString)argString = (char*) "[!NULL!]"; - QString str(argString); - if(str.isEmpty())continue; - int len = str.length(); - const QChar * ch = str.unicode(); - if(!ch)continue; - if((allocsize - reallen) < len)INCREMENT_MEM_BY(len) - while(len--)*p++ = *ch++; - reallen += str.length(); + pcArgString = kvi_va_arg(list,char *); + if(!pcArgString) + { + pcArgString = (char*) "[!NULL!]"; + } + QString szStr(pcArgString); + if(szStr.isEmpty()) + { + continue; + } + int iLen = szStr.length(); + const QChar * pCh = szStr.unicode(); + if(!pCh) + { + continue; + } + if((iAllocSize - iRealLen) < iLen) + { + INCREMENT_MEM_BY(iLen) + } + while(iLen--) + { + *p++ = *pCh++; + } + iRealLen += szStr.length(); continue; } case 'S': // KviStr * string { - KviStr * str = kvi_va_arg(list,KviStr *); - if(!str)continue; - if((allocsize - reallen) < str->len())INCREMENT_MEM_BY(str->len()) - argString = str->ptr(); - while(*argString)*p++ = QChar(*argString++); - reallen += str->len(); + KviStr * szStr = kvi_va_arg(list,KviStr *); + if(!szStr) + { + continue; + } + if((iAllocSize - iRealLen) < szStr->len()) + { + INCREMENT_MEM_BY(szStr->len()) + } + pcArgString = szStr->ptr(); + while(*pcArgString) + { + *p++ = QChar(*pcArgString++); + } + iRealLen += szStr->len(); continue; } case 'Q': // QString * string { - QString * str = kvi_va_arg(list,QString *); - if(!str)continue; - if(str->isEmpty())continue; - int len = str->length(); - const QChar * ch = str->unicode(); - if(!ch)continue; - if((allocsize - reallen) < len)INCREMENT_MEM_BY(len) - while(len--)*p++ = *ch++; - reallen += str->length(); + QString * szStr = kvi_va_arg(list,QString *); + if(!szStr) + { + continue; + } + if(szStr->isEmpty()) + { + continue; + } + int iLen = szStr->length(); + const QChar * pCh = szStr->unicode(); + if(!pCh) + { + continue; + } + if((iAllocSize - iRealLen) < iLen) + { + INCREMENT_MEM_BY(iLen) + } + while(iLen--) + { + *p++ = *pCh++; + } + iRealLen += szStr->length(); continue; } case 'c': //char @@ -584,7 +821,7 @@ namespace KviQString // Is this always true ? // *p++ = (char)kvi_va_arg(list,int); - reallen++; + iRealLen++; continue; } case 'q': // QChar * @@ -598,133 +835,159 @@ namespace KviQString // Is this always true ? // *p++ = *((QChar *)kvi_va_arg(list,QChar *)); - reallen++; + iRealLen++; continue; } case 'd': //signed integer { - argValue = kvi_va_arg(list,int); - if(argValue < 0) - { //negative integer + lArgValue = kvi_va_arg(list,int); + if(lArgValue < 0) + { + //negative integer *p++ = '-'; - reallen++; - argValue = -argValue; //need to have it positive - // most negative integer exception (avoid completely senseless (non digit) responses) - if(argValue < 0)argValue = 0; //we get -0 here + iRealLen++; + //need to have it positive. most negative integer exception (avoid completely senseless (non digit) responses) + lArgValue = -lArgValue; + if(lArgValue < 0) + { + //we get -0 here + lArgValue = 0; + } } //write the number in a temporary buffer - pNumBuf = numberBuffer; + pcNumBuf = cNumberBuffer; do { - tmp = argValue / 10; - *pNumBuf++ = argValue - (tmp * 10) + '0'; - } while((argValue = tmp)); + iTmp = lArgValue / 10; + *pcNumBuf++ = lArgValue - (iTmp * 10) + '0'; + } while((lArgValue = iTmp)); //copy now.... - argUValue = pNumBuf - numberBuffer; //length of the number string - if((allocsize - reallen) < (int)argUValue)INCREMENT_MEM_BY(argUValue) - do { *p++ = QChar(*--pNumBuf); } while(pNumBuf != numberBuffer); - reallen += argUValue; + ulArgValue = pcNumBuf - cNumberBuffer; //length of the number string + if((iAllocSize - iRealLen) < (int)ulArgValue) + { + INCREMENT_MEM_BY(ulArgValue) + } + do { + *p++ = QChar(*--pcNumBuf); + } while(pcNumBuf != cNumberBuffer); + iRealLen += ulArgValue; continue; } case 'u': //unsigned integer { - argUValue = kvi_va_arg(list,unsigned int); //many implementations place int here + ulArgValue = kvi_va_arg(list,unsigned int); //many implementations place int here //write the number in a temporary buffer - pNumBuf = numberBuffer; + pcNumBuf = cNumberBuffer; do { - tmp = argUValue / 10; - *pNumBuf++ = argUValue - (tmp * 10) + '0'; - } while((argUValue = tmp)); + iTmp = ulArgValue / 10; + *pcNumBuf++ = ulArgValue - (iTmp * 10) + '0'; + } while((ulArgValue = iTmp)); //copy now.... - argValue = pNumBuf - numberBuffer; //length of the number string - if((allocsize - reallen) < argValue)INCREMENT_MEM_BY(argValue) - do { *p++ = *--pNumBuf; } while(pNumBuf != numberBuffer); - reallen += argValue; + lArgValue = pcNumBuf - cNumberBuffer; //length of the number string + if((iAllocSize - iRealLen) < lArgValue) + { + INCREMENT_MEM_BY(lArgValue) + } + do { + *p++ = *--pcNumBuf; + } while(pcNumBuf != cNumberBuffer); + iRealLen += lArgValue; continue; } case 'h': case 'x': // hexadecimal unsigned integer { - static char hexsmalldigits[]="0123456789abcdef"; - argUValue = kvi_va_arg(list,unsigned int); //many implementations place int here + static char cHexSmallDigits[] = "0123456789abcdef"; + ulArgValue = kvi_va_arg(list,unsigned int); //many implementations place int here //write the number in a temporary buffer - pNumBuf = numberBuffer; + pcNumBuf = cNumberBuffer; do { - tmp = argUValue / 16; - *pNumBuf++ = hexsmalldigits[argUValue - (tmp * 16)]; - } while((argUValue = tmp)); + iTmp = ulArgValue / 16; + *pcNumBuf++ = cHexSmallDigits[ulArgValue - (iTmp * 16)]; + } while((ulArgValue = iTmp)); //copy now.... - argValue = pNumBuf - numberBuffer; //length of the number string - if((allocsize - reallen) < argValue)INCREMENT_MEM_BY(argValue) - do { *p++ = *--pNumBuf; } while(pNumBuf != numberBuffer); - reallen += argValue; + lArgValue = pcNumBuf - cNumberBuffer; //length of the number string + if((iAllocSize - iRealLen) < lArgValue) + { + INCREMENT_MEM_BY(lArgValue) + } + do { + *p++ = *--pcNumBuf; + } while(pcNumBuf != cNumberBuffer); + iRealLen += lArgValue; continue; } case 'H': case 'X': // hexadecimal unsigned integer { - static char hexbigdigits[]="0123456789ABCDEF"; - argUValue = kvi_va_arg(list,unsigned int); //many implementations place int here + static char cHexBigDigits[] = "0123456789ABCDEF"; + ulArgValue = kvi_va_arg(list,unsigned int); //many implementations place int here //write the number in a temporary buffer - pNumBuf = numberBuffer; + pcNumBuf = cNumberBuffer; do { - tmp = argUValue / 16; - *pNumBuf++ = hexbigdigits[argUValue - (tmp * 16)]; - } while((argUValue = tmp)); + iTmp = ulArgValue / 16; + *pcNumBuf++ = cHexBigDigits[ulArgValue - (iTmp * 16)]; + } while((ulArgValue = iTmp)); //copy now.... - argValue = pNumBuf - numberBuffer; //length of the number string - if((allocsize - reallen) < argValue)INCREMENT_MEM_BY(argValue) - do { *p++ = *--pNumBuf; } while(pNumBuf != numberBuffer); - reallen += argValue; + lArgValue = pcNumBuf - cNumberBuffer; //length of the number string + if((iAllocSize - iRealLen) < lArgValue) + { + INCREMENT_MEM_BY(lArgValue) + } + do { + *p++ = *--pcNumBuf; + } while(pcNumBuf != cNumberBuffer); + iRealLen += lArgValue; continue; } - default: //a normal percent followed by some char + default: { + // a normal percent followed by some char *p++ = '%'; //write it - reallen++; - if(fmt->unicode()) + iRealLen++; + if(pFmt->unicode()) { - if(reallen == allocsize)INCREMENT_MEM - *p++ = *fmt; - reallen++; + if(iRealLen == iAllocSize) + { + INCREMENT_MEM + } + *p++ = *pFmt; + iRealLen++; } continue; } } } - s.setUnicode(buffer,reallen); - kvi_free(buffer); - //s.squeeze(); + szSrc.setUnicode(pBuffer,iRealLen); + kvi_free(pBuffer); + //szSrc.squeeze(); } - - QString & sprintf(QString &s,const QString &szFmt,...) + QString & sprintf(QString & szSrc, const QString & szFmt, ...) { kvi_va_list list; kvi_va_start_by_reference(list,szFmt); //print...with max 256 chars - KviQString::vsprintf(s,szFmt,list); + KviQString::vsprintf(szSrc,szFmt,list); kvi_va_end(list); - return s; + return szSrc; } - void appendFormatted(QString &s,const QString &szFmt,...) + void appendFormatted(QString & szSrc, const QString & szFmt, ...) { - QString tmp; + QString szTmp; kvi_va_list list; kvi_va_start_by_reference(list,szFmt); //print...with max 256 chars - KviQString::vsprintf(tmp,szFmt,list); + KviQString::vsprintf(szTmp,szFmt,list); kvi_va_end(list); - s.append(tmp); + szSrc.append(szTmp); } - bool matchWildExpressionsCI(const QString &szM1,const QString &szM2) + bool matchWildExpressions(const QString & szM1, const QString & szM2) { - //Matches two regular expressions containging wildcards (* and ?) - // s1 - // m1 + // pM1 // mask1 : *xor // mask2 : xorand*xor // m2 @@ -737,286 +1000,303 @@ namespace KviQString // // *!*@*.net // | - // m1 + // pM1 // s1 // - const QChar * m1 = (const QChar *)szM1.constData(); - const QChar * m2 = (const QChar *)szM2.constData(); + const QChar * pM1 = (const QChar *)szM1.constData(); + const QChar * pM2 = (const QChar *)szM2.constData(); - if(!(m1 && m2 && (m1->unicode())))return false; - const QChar * savePos1 = 0; - const QChar * savePos2 = m2; - while(m1->unicode()) + if(!(pM1 && pM2 && (pM1->unicode()))) + { + return false; + } + + const QChar * pSavePos1 = 0; + const QChar * pSavePos2 = pM2; + while(pM1->unicode()) { - //loop managed by m1 (initially first mask) - if(m1->unicode()=='*') + //loop managed by pM1 (initially first mask) + if(pM1->unicode() == '*') + { + //Found a wildcard in pM1 + //move to the next char and save the position...this is our jolly + pSavePos1 = ++pM1; + if(!pSavePos1->unicode()) + { + //last was a wildcard , matches everything ahead... + return true; + } + //next return state for the second string + pSavePos2 = pM2 + 1; + //and return + continue; + } + if(!pM2->unicode()) { - //Found a wildcard in m1 - savePos1 = ++m1; //move to the next char and save the position...this is our jolly - if(!savePos1->unicode())return true; //last was a wildcard , matches everything ahead... - savePos2 = m2+1; //next return state for the second string - continue; //and return + //pM2 finished and we had something to match here! + return false; } - if(!m2->unicode())return false; //m2 finished and we had something to match here! - if(m1->toLower()==m2->toLower()) + if(pM1->toLower() == pM2->toLower()) { - //chars matched - m1++; //Go ahead in the two strings - m2++; // - if((!(m1->unicode())) && m2->unicode() && savePos1) + //chars matched. go ahead in the two strings + pM1++; + pM2++; + if((!(pM1->unicode())) && pM2->unicode() && pSavePos1) { - //m1 finished , but m2 not yet and we have a savePosition for m1 (there was a wildcard)... + //pM1 finished , but pM2 not yet and we have a savePosition for pM1 (there was a wildcard)... //retry matching the string following the * from the savePos2 (one char ahead last time) - m1 = savePos1; //back to char after wildcard - m2 = savePos2; //back to last savePos2 - savePos2++; //next savePos2 will be next char + //back to char after wildcard + pM1 = pSavePos1; + //back to last savePos2 + pM2 = pSavePos2; + //next savePos2 will be next char + pSavePos2++; } } else { - if(m2->unicode() == '*') + if(pM2->unicode() == '*') { //A wlidcard in the second string //Invert the game : mask1 <-> mask2 //mask2 now leads the game... - savePos1 = m1; //aux - m1 = m2; //...swap - m2 = savePos1; //...swap - savePos1 = m1; //sync save pos1 - savePos2 = m2 + 1; //sync save pos2 - continue; //...and again + //aux + pSavePos1 = pM1; + //...swap + pM1 = pM2; + //...swap + pM2 = pSavePos1; + //sync save pos1 + pSavePos1 = pM1; + //sync save pos2 + pSavePos2 = pM2 + 1; + //...and again + continue; } - // m1 != m2 , m1 != * , m2 != * - if((m1->unicode() == '?') || (m2->unicode() == '?')) + // pM1 != pM2 , pM1 != * , pM2 != * + if((pM1->unicode() == '?') || (pM2->unicode() == '?')) { - m1++; - m2++; - if((!(m1->unicode())) && m2->unicode() && savePos1) + pM1++; + pM2++; + if((!(pM1->unicode())) && pM2->unicode() && pSavePos1) { - //m1 finished , but m2 not yet and we have a savePosition for m1 (there was a wildcard)... - //retry matching the string following the * from the savePos2 (one char ahead last time) - m1 = savePos1; //back to char after wildcard - m2 = savePos2; //back to last savePos2 - savePos2++; //next savePos2 will be next char + //pM1 finished , but pM2 not yet and we have a savePosition for pM1 (there was a wildcard)... + //retry matching the string following the * from the pSavePos2 (one char ahead last time) + //back to char after wildcard + pM1 = pSavePos1; + //back to last pSavePos2 + pM2 = pSavePos2; + //next pSavePos2 will be next char + pSavePos2++; } } else { - if(savePos1) + if(pSavePos1) { //Have a jolly man...allow not matching... - m1 = savePos1; //go back to char after wildcard...need to rematch... - m2 = savePos2; //back to last savePos2 - savePos2++; //and set next savePos2 - } else return false; //No previous wildcards...not matched! + //go back to char after wildcard...need to rematch... + pM1 = pSavePos1; + //back to last pSavePos2 + pM2 = pSavePos2; + //and set next pSavePos2 + pSavePos2++; + } else { + //No previous wildcards...not matched! + return false; + } } } } - return (!(m2->unicode())); //m1 surely finished , so for the match , m2 must be finished too + //pM1 surely finished , so for the match , pM2 must be finished too + return (!(pM2->unicode())); } - bool matchStringCI(const QString &szExp,const QString &szStr,bool bIsRegExp,bool bExact) + bool matchString(const QString & szExp, const QString & szStr, bool bIsRegExp, bool bExact, bool bCs) { QString szWildcard; - QChar* ptr=(QChar*)szExp.constData(); + QChar * pPtr = (QChar*)szExp.constData(); - if(!ptr) return 0; - while(ptr->unicode()) + if(!pPtr) { - if((ptr->unicode()=='[') || (ptr->unicode()==']')) - { - szWildcard.append("["); - szWildcard.append(*ptr); - szWildcard.append("]"); - } else { - szWildcard.append(*ptr); - } - ptr++; + return 0; } - QRegExp re(szWildcard,Qt::CaseInsensitive,bIsRegExp ? QRegExp::RegExp : QRegExp::Wildcard); - - if(bExact) return re.exactMatch(szStr); - return re.indexIn(szStr) != -1; - } - - bool matchStringCS(const QString &szExp,const QString &szStr,bool bIsRegExp,bool bExact) - { - QString szWildcard; - QChar* ptr=(QChar*)szExp.constData(); - - if(!ptr) return 0; - while(ptr->unicode()) + while(pPtr->unicode()) { - if((ptr->unicode()=='[')) // <-- hum ? + if((pPtr->unicode() == '[') || (pPtr->unicode() == ']')) { szWildcard.append("["); - szWildcard.append(*ptr); + szWildcard.append(*pPtr); szWildcard.append("]"); } else { - szWildcard.append(*ptr); + szWildcard.append(*pPtr); } - ptr++; + pPtr++; } - QRegExp re(szWildcard,Qt::CaseSensitive,bIsRegExp ? QRegExp::RegExp : QRegExp::Wildcard); + QRegExp re(szWildcard,bCs ? Qt::CaseSensitive : Qt::CaseInsensitive,bIsRegExp ? QRegExp::RegExp : QRegExp::Wildcard); - if(bExact) return re.exactMatch(szStr); + if(bExact) + { + return re.exactMatch(szStr); + } return re.indexIn(szStr) != -1; } - void cutFromFirst(QString &s,const QChar &c,bool bIncluded) + void cutFromFirst(QString & szSrc, const QChar & c, bool bIncluded) { - int idx = s.indexOf(c); + int iIdx = szSrc.indexOf(c); - if(idx == -1)return; - s.truncate(bIncluded ? idx : idx + 1); + if(iIdx == -1) return; + szSrc.truncate(bIncluded ? iIdx : iIdx + 1); + } + + void cutFromFirst(QString & szSrc, const QString & szFind, bool bIncluded) + { + int iIdx = szSrc.indexOf(szFind); + if(iIdx == -1) return; + szSrc.truncate(bIncluded ? iIdx : iIdx + szFind.length()); } - void cutFromLast(QString &s,const QChar &c,bool bIncluded) + void cutFromLast(QString & szSrc, const QChar & c, bool bIncluded) { - int idx = s.lastIndexOf(c); + int iIdx = szSrc.lastIndexOf(c); - if(idx == -1)return; - s.truncate(bIncluded ? idx : idx + 1); + if(iIdx == -1) return; + szSrc.truncate(bIncluded ? iIdx : iIdx + 1); + } + + void cutFromLast(QString & szSrc, const QString & szFind, bool bIncluded) + { + int iIdx = szSrc.lastIndexOf(szFind); + if(iIdx == -1) return; + szSrc.truncate(bIncluded ? iIdx : iIdx + szFind.length()); } - void cutToFirst(QString &s,const QChar &c,bool bIncluded,bool bClearIfNotFound) + void cutToFirst(QString & szSrc, const QChar & c, bool bIncluded, bool bClearIfNotFound) { - int idx = s.indexOf(c); - if(idx == -1) + int iIdx = szSrc.indexOf(c); + if(iIdx == -1) { - if(bClearIfNotFound)s = ""; + if(bClearIfNotFound) szSrc = ""; return; } - s.remove(0,bIncluded ? idx + 1 : idx); + szSrc.remove(0,bIncluded ? iIdx + 1 : iIdx); } - - void cutToLast(QString &s,const QChar &c,bool bIncluded,bool bClearIfNotFound) + + void cutToFirst(QString & szSrc, const QString & szFind, bool bIncluded, bool bClearIfNotFound) { - int idx = s.lastIndexOf(c); - if(idx == -1) + int iIdx = szSrc.indexOf(szFind); + if(iIdx == -1) { - if(bClearIfNotFound)s = ""; + if(bClearIfNotFound) szSrc = ""; return; } - s.remove(0,bIncluded ? idx + 1 : idx); - } - - void cutFromFirst(QString &s,const QString &c,bool bIncluded) - { - int idx = s.indexOf(c); - if(idx == -1)return; - s.truncate(bIncluded ? idx : idx + c.length()); - } - - void cutFromLast(QString &s,const QString &c,bool bIncluded) - { - int idx = s.lastIndexOf(c); - if(idx == -1)return; - s.truncate(bIncluded ? idx : idx + c.length()); + szSrc.remove(0,bIncluded ? iIdx + szFind.length() : iIdx); } - void cutToFirst(QString &s,const QString &c,bool bIncluded,bool bClearIfNotFound) + void cutToLast(QString & szSrc, const QChar & c, bool bIncluded, bool bClearIfNotFound) { - int idx = s.indexOf(c); - if(idx == -1) + int iIdx = szSrc.lastIndexOf(c); + if(iIdx == -1) { - if(bClearIfNotFound)s = ""; + if(bClearIfNotFound) szSrc = ""; return; } - s.remove(0,bIncluded ? idx + c.length() : idx); + szSrc.remove(0,bIncluded ? iIdx + 1 : iIdx); } - - void cutToLast(QString &s,const QString &c,bool bIncluded,bool bClearIfNotFound) + + void cutToLast(QString & szSrc, const QString & szFind, bool bIncluded, bool bClearIfNotFound) { - int idx = s.lastIndexOf(c); - if(idx == -1) + int iIdx = szSrc.lastIndexOf(szFind); + if(iIdx == -1) { - if(bClearIfNotFound)s = ""; + if(bClearIfNotFound) szSrc = ""; return; } - s.remove(0,bIncluded ? idx + c.length() : idx); + szSrc.remove(0,bIncluded ? iIdx + szFind.length() : iIdx); } - QString upperISO88591(const QString &szSrc) + QString upperISO88591(const QString & szSrc) { - const QChar * c = nullTerminatedArray(szSrc); - if(!c) + const QChar * pC = nullTerminatedArray(szSrc); + if(!pC) { - QString ret; - return ret; + QString szRet; + return szRet; } - QChar * buffer = (QChar *)kvi_malloc(sizeof(QChar) * szSrc.length()); - QChar * b = buffer; - unsigned short us = c->unicode(); - while(us) + QChar * pBuffer = (QChar *)kvi_malloc(sizeof(QChar) * szSrc.length()); + QChar * pB = pBuffer; + unsigned short usX = pC->unicode(); + while(usX) { - if(us < 256) - *b=QChar((unsigned short)iso88591_toUpper_map[us]); + if(usX < 256) + *pB = QChar((unsigned short)iso88591_toUpper_map[usX]); else - *b = *c; - c++; - b++; - us = c->unicode(); + *pB = *pC; + pC++; + pB++; + usX = pC->unicode(); } - QString ret(buffer,szSrc.length()); - kvi_free(buffer); - return ret; + QString szRet(pBuffer,szSrc.length()); + kvi_free(pBuffer); + return szRet; } - QString lowerISO88591(const QString &szSrc) + QString lowerISO88591(const QString & szSrc) { - const QChar * c = nullTerminatedArray(szSrc); - if(!c) + const QChar * pC = nullTerminatedArray(szSrc); + if(!pC) { - QString ret; - return ret; + QString szRet; + return szRet; } - QChar * buffer = (QChar *)kvi_malloc(sizeof(QChar) * szSrc.length()); - QChar * b = buffer; - unsigned short us = c->unicode(); - while(us) + QChar * pBuffer = (QChar *)kvi_malloc(sizeof(QChar) * szSrc.length()); + QChar * pB = pBuffer; + unsigned short usX = pC->unicode(); + while(usX) { - if(us < 256) + if(usX < 256) { - *b=QChar((unsigned short)iso88591_toLower_map[us]); + *pB = QChar((unsigned short)iso88591_toLower_map[usX]); } else - *b = *c; - c++; - b++; - us = c->unicode(); + *pB = *pC; + pC++; + pB++; + usX = pC->unicode(); } - QString ret(buffer,szSrc.length()); - kvi_free(buffer); - return ret; + QString szRet(pBuffer,szSrc.length()); + kvi_free(pBuffer); + return szRet; } - void transliterate(QString &s,const QString &szToFind,const QString &szReplacement) + void transliterate(QString & szSrc, const QString & szToFind, const QString & szReplacement) { - int i=0; + int i = 0; int il = MY_MIN(szToFind.length(),szReplacement.length()); while(i < il) { - int k=0; - int kl = s.length(); + int k = 0; + int kl = szSrc.length(); while(k < kl) { - if(s[k] == szToFind[i])s[k] = szReplacement[i]; + if(szSrc[k] == szToFind[i]) + { + szSrc[k] = szReplacement[i]; + } k++; } i++; } } - static char hexdigits[16] = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f' }; - - void bufferToHex(QString &szRetBuffer,const unsigned char * buffer,unsigned int len) + void bufferToHex(QString & szRetBuffer, const unsigned char * pcBuffer, unsigned int uLen) { - szRetBuffer.resize(len * 2); - unsigned int i=0; - while(i < (len*2)) + szRetBuffer.resize(uLen * 2); + unsigned int u = 0; + while(u < (uLen * 2)) { - szRetBuffer[int(i)] = QChar( (unsigned int) hexdigits[(*buffer) / 16] ); - i++; - szRetBuffer[int(i)] = QChar( (unsigned int)hexdigits[(*buffer) % 16] ); - i++; - buffer++; + szRetBuffer[int(u)] = QChar((unsigned int)cHexDigits[(*pcBuffer) / 16] ); + u++; + szRetBuffer[int(u)] = QChar((unsigned int)cHexDigits[(*pcBuffer) % 16] ); + u++; + pcBuffer++; } } } diff --git a/src/kvilib/core/kvi_qstring.h b/src/kvilib/core/kvi_qstring.h index d6b3447ac..60c678479 100644 --- a/src/kvilib/core/kvi_qstring.h +++ b/src/kvilib/core/kvi_qstring.h @@ -46,170 +46,587 @@ */ namespace KviQString { + /** + * \brief A global empty string (note that this is ALSO NULL under Qt 3.x) + */ + extern KVILIB_API const QString Empty; + + /** + * \brief Returns a readable size in byte's multiples + * + * This will return strings like KiB, MiB, GiB, TiB and so on + * \param size The size of the file + * \return QString + */ extern KVILIB_API QString makeSizeReadable(size_t size); - extern KVILIB_API bool equalCS(const QString &sz1,const QString &sz2); - extern KVILIB_API bool equalCI(const QString &sz1,const QString &sz2); - extern KVILIB_API bool equalCS(const QString &sz1,const char * sz2); - extern KVILIB_API bool equalCI(const QString &sz1,const char * sz2); - // sz2 is assumed to be null terminated here! - extern KVILIB_API bool equalCI(const QString &sz1,const QChar * sz2); - inline bool equalCS(const char * sz1,const QString &sz2) - { return equalCS(sz2,sz1); } - inline bool equalCI(const char * sz1,const QString &sz2) - { return equalCI(sz2,sz1); } - // sz1 is assumed to be null terminated here! - inline bool equalCI(const QChar * sz1,const QString &sz2) - { return equalCI(sz2,sz1); } - - extern KVILIB_API bool equalCSN(const QString &sz1,const QString &sz2,unsigned int len); - extern KVILIB_API bool equalCIN(const QString &sz1,const QString &sz2,unsigned int len); - extern KVILIB_API bool equalCSN(const QString &sz1,const char * sz2,unsigned int len); - extern KVILIB_API bool equalCIN(const QString &sz1,const char * sz2,unsigned int len); - // sz2 is assumed to be null terminated here! - extern KVILIB_API bool equalCIN(const QString &sz1,const QChar * sz2,unsigned int len); - inline bool equalCSN(const char * sz1,const QString &sz2,unsigned int len) - { return equalCSN(sz2,sz1,len); } - inline bool equalCIN(const char * sz1,const QString &sz2,unsigned int len) - { return equalCIN(sz2,sz1,len); } - // sz1 is assumed to be null terminated here! - inline bool equalCIN(const QChar * sz1,const QString &sz2,unsigned int len) - { return equalCIN(sz2,sz1,len); } + + /** + * \brief Compares two strings with case sensitive + * + * It returns true if the strings are equal, false otherwise + * \param sz1 First string + * \param sz2 Second string + * \return bool + */ + extern KVILIB_API bool equalCS(const QString & sz1, const QString & sz2); + + /** + * \brief Compares two strings with case sensitive + * + * It returns true if the strings are equal, false otherwise + * \param sz1 First string + * \param pc2 Second string + * \return bool + */ + extern KVILIB_API bool equalCS(const QString & sz1, const char * pc2); + + /** + * \brief Compares two strings with case sensitive + * + * It returns true if the strings are equal, false otherwise + * \param pc1 First string + * \param sz2 Second string + * \return bool + */ + inline bool equalCS(const char * pc1, const QString & sz2) + { return equalCS(sz2,pc1); } + + /** + * \brief Compares two strings with case insensitive + * + * It returns true if the strings are equal, false otherwise + * \param sz1 First string + * \param sz2 Second string + * \return bool + */ + extern KVILIB_API bool equalCI(const QString & sz1, const QString & sz2); + + /** + * \brief Compares two strings with case insensitive + * + * It returns true if the strings are equal, false otherwise + * \param sz1 First string + * \param pc2 Second string + * \return bool + */ + extern KVILIB_API bool equalCI(const QString & sz1, const char * pc2); + + /** + * \brief Compares two strings with case insensitive + * + * It returns true if the strings are equal, false otherwise. + * The parameter pC2 is assumed to be null terminated here! + * \param sz1 First string + * \param pC2 Second string + * \return bool + */ + extern KVILIB_API bool equalCI(const QString & sz1, const QChar * pC2); + + /** + * \brief Compares two strings with case insensitive + * + * It returns true if the strings are equal, false otherwise. + * \param pc1 First string + * \param sz2 Second string + * \return bool + */ + inline bool equalCI(const char * pc1, const QString & sz2) + { return equalCI(sz2,pc1); } + + /** + * \brief Compares two strings with case insensitive + * + * It returns true if the strings are equal, false otherwise. + * The parameter pC1 is assumed to be null terminated here! + * \param pC1 First string + * \param sz2 Second string + * \return bool + */ + inline bool equalCI(const QChar * pC1, const QString & sz2) + { return equalCI(sz2,pC1); } + + /** + * \brief Compares two strings with case sensitive up to N chars + * + * It returns true if the strings are equal, false otherwise + * \param sz1 First string + * \param sz2 Second string + * \param uLen The length of the string to check + * \return bool + */ + extern KVILIB_API bool equalCSN(const QString & sz1, const QString & sz2, unsigned int uLen); + + /** + * \brief Compares two strings with case sensitive up to N chars + * + * It returns true if the strings are equal, false otherwise + * \param sz1 First string + * \param pc2 Second string + * \param uLen The length of the string to check + * \return bool + */ + extern KVILIB_API bool equalCSN(const QString & sz1, const char * pc2, unsigned int uLen); + + /** + * \brief Compares two strings with case sensitive up to N chars + * + * It returns true if the strings are equal, false otherwise + * \param pc1 First string + * \param sz2 Second string + * \param uLen The length of the string to check + * \return bool + */ + inline bool equalCSN(const char * pc1, const QString & sz2, unsigned int uLen) + { return equalCSN(sz2,pc1,uLen); } + + /** + * \brief Compares two strings with case insensitive up to N chars + * + * It returns true if the strings are equal, false otherwise + * \param sz1 First string + * \param sz2 Second string + * \param uLen The length of the string to check + * \return bool + */ + extern KVILIB_API bool equalCIN(const QString & sz1, const QString & sz2, unsigned int uLen); + + /** + * \brief Compares two strings with case insensitive up to N chars + * + * It returns true if the strings are equal, false otherwise + * \param sz1 First string + * \param pc2 Second string + * \param uLen The length of the string to check + * \return bool + */ + extern KVILIB_API bool equalCIN(const QString & sz1, const char * pc2, unsigned int uLen); + + /** + * \brief Compares two strings with case insensitive up to N chars + * + * It returns true if the strings are equal, false otherwise + * pC2 is assumed to be null terminated here! + * \param sz1 First string + * \param pC2 Second string + * \param uLen The length of the string to check + * \return bool + */ + extern KVILIB_API bool equalCIN(const QString & sz1, const QChar * pC2, unsigned int uLen); + + /** + * \brief Compares two strings with case insensitive up to N chars + * + * It returns true if the strings are equal, false otherwise + * \param pc1 First string + * \param sz2 Second string + * \param uLen The length of the string to check + * \return bool + */ + inline bool equalCIN(const char * pc1, const QString & sz2, unsigned int uLen) + { return equalCIN(sz2,pc1,uLen); } + + /** + * \brief Compares two strings with case insensitive up to N chars + * + * It returns true if the strings are equal, false otherwise + * pC1 is assumed to be null terminated here! + * \param pC1 First string + * \param sz2 Second string + * \param uLen The length of the string to check + * \return bool + */ + inline bool equalCIN(const QChar * pC1, const QString & sz2, unsigned int uLen) + { return equalCIN(sz2,pC1,uLen); } - //note that greater here means that come AFTER in the alphabetic order - // return < 0 ---> str1 < str2 - // return = 0 ---> str1 = str2 - // return > 0 ---> str1 > str2 - extern KVILIB_API int cmpCI(const QString &sz1,const QString &sz2,bool nonAlphaGreater = false); - extern KVILIB_API int cmpCIN(const QString &sz1,const QString &sz2,unsigned int len); - extern KVILIB_API int cmpCS(const QString &sz1,const QString &sz2); + /** + * \brief Compares two strings with case insensitive + * + * Note that greater here means that come AFTER in the alphabetic order + * return < 0 ---> str1 < str2 + * return = 0 ---> str1 = str2 + * return > 0 ---> str1 > str2 + * \param sz1 The first string + * \param sz2 The second string + * \param bNonAlphaGreater Wheter to check if strings are not alphabetics + * \return int + */ + extern KVILIB_API int cmpCI(const QString & sz1, const QString & sz2, bool bNonAlphaGreater = false); + + /** + * \brief Compares two strings with case insensitive up to N chars + * + * Note that greater here means that come AFTER in the alphabetic order + * return < 0 ---> str1 < str2 + * return = 0 ---> str1 = str2 + * return > 0 ---> str1 > str2 + * \param sz1 The first string + * \param sz2 The second string + * \param uLen The number of chars to check + * \return int + */ + extern KVILIB_API int cmpCIN(const QString & sz1, const QString & sz2, unsigned int uLen); + + /** + * \brief Compares two strings with case sensitive + * + * Note that greater here means that come AFTER in the alphabetic order + * return < 0 ---> str1 < str2 + * return = 0 ---> str1 = str2 + * return > 0 ---> str1 > str2 + * \param sz1 The first string + * \param sz2 The second string + * \return int + */ + extern KVILIB_API int cmpCS(const QString & sz1, const QString & sz2); - extern KVILIB_API void detach(QString &sz); + /** + * \brief Resets the size of the string + * \param szSrc The source string + * \return void + */ + extern KVILIB_API void detach(QString & szSrc); - // this makes the QString sz appear as a null terminated array - // it MAY RETURN 0 when the QString is null! - extern KVILIB_API const QChar * nullTerminatedArray(const QString &sz); + /** + * \brief Returns a pointer to the data stored in the string. + * + * This makes the string szSrc appear as a null terminated array. + * It MAY RETURN 0 when the string is null! + * \param szSrc The source string + * \return QChar * + */ + extern KVILIB_API const QChar * nullTerminatedArray(const QString & szSrc); /** - * \brief Returns true if the string ends with character c - * \param szString The source string + * \brief Returns true if the string ends with the given character + * \param szSrc The source string * \param c The char to check * \return bool */ - inline bool lastCharIs(QString & szString, const QChar & c) - { return szString.endsWith(c); } + inline bool lastCharIs(QString & szSrc, const QChar & c) + { return szSrc.endsWith(c); } - extern KVILIB_API void ensureLastCharIs(QString &szString,const QChar &c); - - // wild expression matching - extern KVILIB_API bool matchWildExpressionsCI(const QString &szM1,const QString &szM2); - // wild or regexp matching - extern KVILIB_API bool matchStringCI(const QString &szExp,const QString &szStr,bool bIsRegExp = false,bool bExact = false); - extern KVILIB_API bool matchStringCS(const QString &szExp,const QString &szStr,bool bIsRegExp = false,bool bExact = false); + /** + * \brief Ensures the last char of a string is the given char + * + * If the string does not end with the given char, it appends it + * \param szSrc The source string + * \param c The char to check + * \return void + */ + extern KVILIB_API void ensureLastCharIs(QString & szSrc, const QChar & c); - extern KVILIB_API void vsprintf(QString &s,const QString &szFmt,kvi_va_list list); - extern KVILIB_API QString & sprintf(QString &s,const QString &szFmt,...); - extern KVILIB_API void stripRightWhiteSpace(QString &s); - extern KVILIB_API void stripLeft(QString &s,const QChar &c); - extern KVILIB_API void stripRight(QString &s,const QChar &c); - extern KVILIB_API void appendFormatted(QString &s,const QString &szFmt,...); - extern KVILIB_API void appendNumber(QString &s,double dReal); - extern KVILIB_API void appendNumber(QString &s,kvi_i64_t iInteger); - extern KVILIB_API void appendNumber(QString &s,int iInteger); - extern KVILIB_API void appendNumber(QString &s,unsigned int uInteger); - extern KVILIB_API void appendNumber(QString &s,kvi_u64_t uInteger); + /** + * \brief Matches two strings containging wildcards (* and ?) + * \param szM1 The first string to match + * \param szM2 The second string to match + * \return bool + */ + extern KVILIB_API bool matchWildExpressions(const QString & szM1, const QString & szM2); + + /** + * \brief Matches two string containging wildcards (* and ?) or regular expressions + * \param szExp The regular expression to match + * \param szStr The source string + * \param bIsRegExp Wheter to use a wildcard or regexp matching + * \param bExact Wheter to match the whole string + * \param bCs Wheter to match with case sensitive + * \return bool + */ + extern KVILIB_API bool matchString(const QString & szExp, const QString & szStr, bool bIsRegExp = false, bool bExact = false, bool bCs = false); - extern KVILIB_API void cutFromFirst(QString &s,const QChar &c,bool bIncluded = true); - extern KVILIB_API void cutFromLast(QString &s,const QChar &c,bool bIncluded = true); - extern KVILIB_API void cutToFirst(QString &s,const QChar &c,bool bIncluded = true,bool bClearIfNotFound = false); - extern KVILIB_API void cutToLast(QString &s,const QChar &c,bool bIncluded = true,bool bClearIfNotFound = false); - extern KVILIB_API void cutFromFirst(QString &s,const QString &c,bool bIncluded = true); - extern KVILIB_API void cutFromLast(QString &s,const QString &c,bool bIncluded = true); - extern KVILIB_API void cutToFirst(QString &s,const QString &c,bool bIncluded = true,bool bClearIfNotFound = false); - extern KVILIB_API void cutToLast(QString &s,const QString &c,bool bIncluded = true,bool bClearIfNotFound = false); + /** + * \brief Writes to the character string + * \param szSrc The source string + * \param szFmt The format string + * \param list The list of format parameters + * \return void + */ + extern KVILIB_API void vsprintf(QString & szSrc, const QString & szFmt, kvi_va_list list); + + /** + * \brief Writes to the character string + * \param szSrc The source string + * \param szFmt The format string + * \param ... The list of format parameters + * \return QString + */ + extern KVILIB_API QString & sprintf(QString & szSrc, const QString & szFmt, ...); + + /** + * \brief Trims all the whitespaces at the end of the given string + * \param szSrc The source string + * \return void + */ + extern KVILIB_API void stripRightWhiteSpace(QString & szSrc); + + /** + * \brief Trims all c chars at the start of the given string + * \param szSrc The source string + * \param c The char to trim + * \return void + */ + extern KVILIB_API void stripLeft(QString & szSrc, const QChar & c); + + /** + * \brief Trims all c chars at the end of the given string + * \param szSrc The source string + * \param c The char to trim + * \return void + */ + extern KVILIB_API void stripRight(QString & szSrc, const QChar & c); + + /** + * \brief Appends a formatted string + * \param szSrc The source string + * \param szFmt The format string + * \param ... Format string parameters + * \return void + */ + extern KVILIB_API void appendFormatted(QString & szSrc, const QString & szFmt, ...); + + /** + * \brief Appends the given number to the source string + * \param szSrc The source string + * \param dReal Number in double format + * \return void + */ + extern KVILIB_API void appendNumber(QString & szSrc, double dReal); + + /** + * \brief Appends the given number to the source string + * \param szSrc The source string + * \param iInteger Number in kvi_i64_t format + * \return void + */ + extern KVILIB_API void appendNumber(QString & szSrc, kvi_i64_t iInteger); + + /** + * \brief Appends the given number to the source string + * \param szSrc The source string + * \param iInteger Number in int format + * \return void + */ + extern KVILIB_API void appendNumber(QString & szSrc, int iInteger); + + /** + * \brief Appends the given number to the source string + * \param szSrc The source string + * \param uInteger Number in unsigned int format + * \return void + */ + extern KVILIB_API void appendNumber(QString & szSrc, unsigned int uInteger); + + /** + * \brief Appends the given number to the source string + * \param szSrc The source string + * \param uInteger Number in kvi_i64_t format + * \return void + */ + extern KVILIB_API void appendNumber(QString & szSrc, kvi_u64_t uInteger); - extern KVILIB_API QString upperISO88591(const QString &szSrc); - extern KVILIB_API QString lowerISO88591(const QString &szSrc); - extern KVILIB_API QString getToken(QString &szString,const QChar &sep); + /** + * \brief Cuts the string after the first occurrence of the given char + * + * If the char is not found, the string is returned as it is. + * \param szSrc The source string + * \param c The char to search for + * \param bIncluded Wheter to include the given char + * \return void + */ + extern KVILIB_API void cutFromFirst(QString & szSrc, const QChar & c, bool bIncluded = true); + + /** + * \brief Cuts the string after the first occurrence of the given char + * + * If the char is not found, the string is returned as it is. + * \param szSrc The source string + * \param szFind The string to search for + * \param bIncluded Wheter to include the given string + * \return void + */ + extern KVILIB_API void cutFromFirst(QString & szSrc, const QString & szFind, bool bIncluded = true); + + /** + * \brief Cuts the string after the last occurrence of the given char + * + * If the char is not found, the string is returned as it is. + * \param szSrc The source string + * \param c The char to search for + * \param bIncluded Wheter to include the given char + * \return void + */ + extern KVILIB_API void cutFromLast(QString & szSrc, const QChar & c, bool bIncluded = true); + + /** + * \brief Cuts the string after the last occurrence of the given char + * + * If the char is not found, the string is returned as it is. + * \param szSrc The source string + * \param szFind The string to search for + * \param bIncluded Wheter to include the given string + * \return void + */ + extern KVILIB_API void cutFromLast(QString & szSrc, const QString & szFind, bool bIncluded = true); + + /** + * \brief Cuts the string until the first occurrence of the given char is found + * + * If the char is not found, the string is returned as it is. + * \param szSrc The source string + * \param c The char to search for + * \param bIncluded Wheter to include the given char in the cut + * \param bClearIfNotFound Wheter to cut the whole string if the char is not found + * \return void + */ + extern KVILIB_API void cutToFirst(QString & szSrc, const QChar & c, bool bIncluded = true, bool bClearIfNotFound = false); + + /** + * \brief Cuts the string until the first occurrence of the given char is found + * + * If the char is not found, the string is returned as it is. + * \param szSrc The source string + * \param szFind The string to search for + * \param bIncluded Wheter to include the given string in the cut + * \param bClearIfNotFound Wheter to cut the whole string if the string is not found + * \return void + */ + extern KVILIB_API void cutToFirst(QString & szSrc, const QString & szFind, bool bIncluded = true, bool bClearIfNotFound = false); + + /** + * \brief Cuts the string until the last occurrence of the given char is found + * + * If the char is not found, the string is returned as it is. + * \param szSrc The source string + * \param c The char to search for + * \param bIncluded Wheter to include the given char in the cut + * \param bClearIfNotFound Wheter to cut the whole string if the char is not found + * \return void + */ + extern KVILIB_API void cutToLast(QString & szSrc, const QChar & c, bool bIncluded = true, bool bClearIfNotFound = false); + + /** + * \brief Cuts the string until the last occurrence of the given char is found + * + * If the char is not found, the string is returned as it is. + * \param szSrc The source string + * \param szFind The string to search for + * \param bIncluded Wheter to include the given string in the cut + * \param bClearIfNotFound Wheter to cut the whole string if the string is not found + * \return void + */ + extern KVILIB_API void cutToLast(QString & szSrc, const QString & szFind, bool bIncluded = true, bool bClearIfNotFound = false); - extern KVILIB_API void transliterate(QString &s,const QString &szToFind,const QString &szReplacement); + /** + * \brief Returns an ISO-8859-1 upper case string + * \param szSrc The source string + * \return QString + */ + extern KVILIB_API QString upperISO88591(const QString & szSrc); + + /** + * \brief Returns an ISO-8859-1 lower case string + * \param szSrc The source string + * \return QString + */ + extern KVILIB_API QString lowerISO88591(const QString & szSrc); + + /** + * \brief Returns a token from a string + * \param szSrc The source string + * \param sep The token to find + * \return QString + */ + extern KVILIB_API QString getToken(QString & szSrc, const QChar & sep); - extern KVILIB_API void bufferToHex(QString &szRetBuffer,const unsigned char * buffer,unsigned int len); + /** + * \brief Replaces a string with another + * \param szSrc The source string + * \param szToFind The string to replace + * \param szReplacement The string to replace with + * \return void + */ + extern KVILIB_API void transliterate(QString & szSrc, const QString & szToFind, const QString & szReplacement); - // a global empty string (note that this is ALSO NULL under Qt 3.x) - extern KVILIB_API const QString empty; + /** + * \brief Returns an hexadecimal converted string starting from a buffer + * \param szRetBuffer The buffer to hold the hexadecimal string + * \param pcBuffer The buffer containing the string to convert + * \param uLen The max length of the original string + */ + extern KVILIB_API void bufferToHex(QString & szRetBuffer, const unsigned char * pcBuffer, unsigned int uLen); /** * \brief Returns the index position of the last occurrence of the character * * The search is made forward starting from index. - * \param s The source string + * \param szSrc The source string * \param c The character to find - * \param index The index to start from - * \param cs Case sensitive search + * \param iIndex The index to start from + * \param bCs Case sensitive search * \return int */ - inline int find(const QString & s, QChar c, int index = 0, bool cs = true) + inline int find(const QString & szSrc, QChar c, int iIndex = 0, bool bCs = true) { - return s.indexOf(c,index,cs ? Qt::CaseSensitive : Qt::CaseInsensitive); + return szSrc.indexOf(c,iIndex,bCs ? Qt::CaseSensitive : Qt::CaseInsensitive); } /** * \brief Returns the index position of the last occurrence of the character * * The search is made forward starting from index. - * \param s The source string + * \param szSrc The source string * \param c The character to find - * \param index The index to start from - * \param cs Case sensitive search + * \param iIndex The index to start from + * \param bCs Case sensitive search * \return int */ - inline int find(const QString & s, char c, int index = 0, bool cs = true) + inline int find(const QString & szSrc, char c, int iIndex = 0, bool bCs = true) { - return s.indexOf(c,index,cs ? Qt::CaseSensitive : Qt::CaseInsensitive); + return szSrc.indexOf(c,iIndex,bCs ? Qt::CaseSensitive : Qt::CaseInsensitive); } /** * \brief Returns the index position of the last occurrence of the string * * The search is made forward starting from index. - * \param s The source string - * \param str The string to find - * \param index The index to start from - * \param cs Case sensitive search + * \param szSrc The source string + * \param szStr The string to find + * \param iIndex The index to start from + * \param bCs Case sensitive search * \return int */ - inline int find(const QString & s, const QString & str, int index = 0, bool cs = true) + inline int find(const QString & szSrc, const QString & szStr, int iIndex = 0, bool bCs = true) { - return s.indexOf(str,index,cs ? Qt::CaseSensitive : Qt::CaseInsensitive); + return szSrc.indexOf(szStr,iIndex,bCs ? Qt::CaseSensitive : Qt::CaseInsensitive); } /** * \brief Returns the index position of the last occurrence of the string * * The search is made forward starting from index. - * \param s The source string - * \param str The string to find - * \param index The index to start from - * \param cs Case sensitive search + * \param szSrc The source string + * \param pcStr The string to find + * \param iIndex The index to start from + * \param bCs Case sensitive search * \return int */ - inline int find(const QString & s, const char * str, int index = 0, bool cs = true) + inline int find(const QString & szSrc, const char * pcStr, int iIndex = 0, bool bCs = true) { - return s.indexOf(QString(str),index,cs ? Qt::CaseSensitive : Qt::CaseInsensitive); + return szSrc.indexOf(QString(pcStr),iIndex,bCs ? Qt::CaseSensitive : Qt::CaseInsensitive); } /** * \brief Returns the index position of the last occurrence of the string * * The search is made forward starting from index. - * \param s The source string + * \param szSrc The source string * \param rx The regexp to match - * \param index The index to start from + * \param iIndex The index to start from * \return int */ - inline int find(const QString & s, const QRegExp & rx, int index = 0) + inline int find(const QString & szSrc, const QRegExp & rx, int iIndex = 0) { - return s.indexOf(rx,index); + return szSrc.indexOf(rx,iIndex); } /** @@ -217,15 +634,15 @@ namespace KviQString * * The search is made backward. * If index is -1 the search starts at the last character. - * \param s The source string + * \param szSrc The source string * \param c The character to find - * \param index The index to start from - * \param cs Case sensitive search + * \param iIndex The index to start from + * \param bCs Case sensitive search * \return int */ - inline int findRev(const QString & s ,QChar c, int index = -1, bool cs = true) + inline int findRev(const QString & szSrc, QChar c, int iIndex = -1, bool bCs = true) { - return s.lastIndexOf(c,index,cs ? Qt::CaseSensitive : Qt::CaseInsensitive); + return szSrc.lastIndexOf(c,iIndex,bCs ? Qt::CaseSensitive : Qt::CaseInsensitive); } /** @@ -233,47 +650,47 @@ namespace KviQString * * The search is made backward. * If index is -1 the search starts at the last character. - * \param s The source string + * \param szSrc The source string * \param c The character to find - * \param index The index to start from - * \param cs Case sensitive search + * \param iIndex The index to start from + * \param bCs Case sensitive search * \return int */ - inline int findRev(const QString & s, char c, int index = -1, bool cs = true) + inline int findRev(const QString & szSrc, char c, int iIndex = -1, bool bCs = true) { - return s.lastIndexOf(c,index,cs ? Qt::CaseSensitive : Qt::CaseInsensitive); + return szSrc.lastIndexOf(c,iIndex,bCs ? Qt::CaseSensitive : Qt::CaseInsensitive); } /** - * \brief Returns the index position of the last occurrence of the string str + * \brief Returns the index position of the last occurrence of the given string * * The search is made backward. * If index is -1 the search starts at the last character. - * \param s The source string - * \param str The string to find - * \param index The index to start from - * \param cs Case sensitive search + * \param szSrc The source string + * \param szStr The string to find + * \param iIndex The index to start from + * \param bCs Case sensitive search * \return int */ - inline int findRev(const QString & s, const QString & str, int index = -1, bool cs = true) + inline int findRev(const QString & szSrc, const QString & szStr, int iIndex = -1, bool bCs = true) { - return s.lastIndexOf(str,index,cs ? Qt::CaseSensitive : Qt::CaseInsensitive); + return szSrc.lastIndexOf(szStr,iIndex,bCs ? Qt::CaseSensitive : Qt::CaseInsensitive); } /** - * \brief Returns the index position of the last occurrence of the string str + * \brief Returns the index position of the last occurrence of the given string * * The search is made backward. * If index is -1 the search starts at the last character. - * \param s The source string - * \param str The string to find - * \param index The index to start from - * \param cs Case sensitive search + * \param szSrc The source string + * \param pcStr The string to find + * \param iIndex The index to start from + * \param bCs Case sensitive search * \return int */ - inline int findRev(const QString & s, const char * str, int index = -1, bool cs = true) + inline int findRev(const QString & szSrc, const char * pcStr, int iIndex = -1, bool bCs = true) { - return s.lastIndexOf(QString(str),index,cs ? Qt::CaseSensitive : Qt::CaseInsensitive); + return szSrc.lastIndexOf(QString(pcStr),iIndex,bCs ? Qt::CaseSensitive : Qt::CaseInsensitive); } /** @@ -281,31 +698,31 @@ namespace KviQString * * The search is made backward. * If index is -1 the search starts at the last character. - * \param s The source string + * \param szSrc The source string * \param rx The regexp to match - * \param index The index to start from + * \param iIndex The index to start from * \return int */ - inline int findRev(const QString & s, const QRegExp & rx, int index = -1) + inline int findRev(const QString & szSrc, const QRegExp & rx, int iIndex = -1) { - return s.lastIndexOf(rx,index); + return szSrc.lastIndexOf(rx,iIndex); } /** * \brief Return a whitespace-trimmed string * * Spaces are trimmed at start and end of the string - * \param s The source string + * \param szSrc The source string * \return QString */ - inline QString trimmed(const QString & s) + inline QString trimmed(const QString & szSrc) { - return s.trimmed(); + return szSrc.trimmed(); } /** * \brief Return a UTF-8 formatted string - * \param s The source string + * \param szSrc The source string * \return QByteArray * \warning: DO NOT USE CONSTRUCTS LIKE char * c = KviQString::toUtf8(something).data(); * They are dangerous since with many compilers the returned string @@ -317,24 +734,24 @@ namespace KviQString * instead. Yes, I know that it sucks, but it's the only way to * transit to Qt 4.x more or less cleanly... */ - inline QByteArray toUtf8(const QString & s) + inline QByteArray toUtf8(const QString & szSrc) { - return s.toUtf8(); + return szSrc.toUtf8(); } /** * \brief Return the local 8-bit representation of the string - * \param s The source string + * \param szSrc The source string * \return QByteArray */ - inline QByteArray toLocal8Bit(const QString & s) + inline QByteArray toLocal8Bit(const QString & szSrc) { - return s.toLocal8Bit(); + return szSrc.toLocal8Bit(); } /** * \brief Return the string converted to a long - * \param s The source string + * \param szNumber The source number * \param bOk The conversion error handling * \return kvi_i64_t */ @@ -349,7 +766,7 @@ namespace KviQString /** * \brief Return the string converted to an unsigned long - * \param s The source string + * \param szNumber The source number * \param bOk The conversion error handling * \return kvi_u64_t */ @@ -363,6 +780,4 @@ namespace KviQString } } -// QT4SUX: Because QString::null is gone. QString() is SLOWER than QString::null since it invokes a constructor and destructor. - #endif //_KVI_QSTRING_H_ diff --git a/src/kvilib/ext/kvi_osinfo.cpp b/src/kvilib/ext/kvi_osinfo.cpp index 47f84756e..19fd7e699 100644 --- a/src/kvilib/ext/kvi_osinfo.cpp +++ b/src/kvilib/ext/kvi_osinfo.cpp @@ -444,7 +444,7 @@ namespace KviOsInfo struct utsname uts; if(uname(&uts) == 0) return QString::fromLocal8Bit(uts.sysname); - return KviQString::empty; + return KviQString::Empty; #endif #endif } @@ -457,7 +457,7 @@ namespace KviOsInfo struct utsname uts; if(uname(&uts) == 0) return QString::fromLocal8Bit(uts.version); - return KviQString::empty; + return KviQString::Empty; #endif } @@ -469,7 +469,7 @@ namespace KviOsInfo struct utsname uts; if(uname(&uts) == 0) return QString::fromLocal8Bit(uts.release); - return KviQString::empty; + return KviQString::Empty; #endif } @@ -482,7 +482,7 @@ namespace KviOsInfo struct utsname uts; if(uname(&uts) == 0) return QString::fromLocal8Bit(uts.machine); - return KviQString::empty; + return KviQString::Empty; #endif } @@ -494,7 +494,7 @@ namespace KviOsInfo struct utsname uts; if(uname(&uts) == 0) return QString::fromLocal8Bit(uts.nodename); - return KviQString::empty; + return KviQString::Empty; #endif } @@ -504,6 +504,6 @@ namespace KviOsInfo if(gethostname(hbuffer,1024) == 0) return QString::fromLocal8Bit(hbuffer); else - return KviQString::empty; + return KviQString::Empty; } } diff --git a/src/kvilib/ext/kvi_regusersdb.cpp b/src/kvilib/ext/kvi_regusersdb.cpp index 4d91ea34a..c34bc26e8 100644 --- a/src/kvilib/ext/kvi_regusersdb.cpp +++ b/src/kvilib/ext/kvi_regusersdb.cpp @@ -253,11 +253,11 @@ bool KviRegisteredUser::getProperty(const QString & name,QString &value) const QString & KviRegisteredUser::getProperty(const QString & name) { - if(!m_pPropertyDict)return KviQString::empty; - if(name.isEmpty())return KviQString::empty; + if(!m_pPropertyDict)return KviQString::Empty; + if(name.isEmpty())return KviQString::Empty; QString * pValue = m_pPropertyDict->find(name); if(pValue)return *pValue; - return KviQString::empty; + return KviQString::Empty; } bool KviRegisteredUser::getBoolProperty(const QString & name,bool def) diff --git a/src/kvilib/irc/kvi_avatarcache.cpp b/src/kvilib/irc/kvi_avatarcache.cpp index e31cf9a1c..9add20d8d 100644 --- a/src/kvilib/irc/kvi_avatarcache.cpp +++ b/src/kvilib/irc/kvi_avatarcache.cpp @@ -116,7 +116,7 @@ const QString & KviAvatarCache::lookup(const KviIrcMask &mask,const QString &szN szKey.append(szNetwork); KviAvatarCacheEntry * e = m_pAvatarDict->find(szKey); - if(!e)return KviQString::empty; + if(!e)return KviQString::Empty; e->tLastAccess = kvi_unixTime(); return e->szIdString; } diff --git a/src/kvilib/irc/kvi_identityprofile.cpp b/src/kvilib/irc/kvi_identityprofile.cpp index cdcaed8e8..004e119f5 100644 --- a/src/kvilib/irc/kvi_identityprofile.cpp +++ b/src/kvilib/irc/kvi_identityprofile.cpp @@ -148,7 +148,7 @@ KviIdentityProfile * KviIdentityProfileSet::findName(const QString & szName) KviIdentityProfile * pProfile; for(pProfile = m_pProfiles->first(); pProfile; pProfile = m_pProfiles->next()) { - if(KviQString::matchStringCI(pProfile->name(),szName,false,true)) + if(KviQString::matchString(pProfile->name(),szName,false,true)) return pProfile; } @@ -162,7 +162,7 @@ KviIdentityProfile * KviIdentityProfileSet::findNetwork(const QString & szNetwor KviIdentityProfile * pProfile; for(pProfile = m_pProfiles->first(); pProfile; pProfile = m_pProfiles->next()) { - if(KviQString::matchStringCI(pProfile->network(),szNetwork,false,true)) + if(KviQString::matchString(pProfile->network(),szNetwork,false,true)) return pProfile; } diff --git a/src/kvilib/irc/kvi_ircmask.cpp b/src/kvilib/irc/kvi_ircmask.cpp index 5c27dc6ea..7020b5deb 100644 --- a/src/kvilib/irc/kvi_ircmask.cpp +++ b/src/kvilib/irc/kvi_ircmask.cpp @@ -557,11 +557,11 @@ bool KviIrcMask::matchedBy(const QString &szMask) const bool KviIrcMask::matches(const KviIrcMask &mask) const { - if(KviQString::matchWildExpressionsCI(m_szNick,mask.m_szNick)) + if(KviQString::matchWildExpressions(m_szNick,mask.m_szNick)) { - if(KviQString::matchWildExpressionsCI(m_szUser,mask.m_szUser)) + if(KviQString::matchWildExpressions(m_szUser,mask.m_szUser)) { - if(KviQString::matchWildExpressionsCI(m_szHost,mask.m_szHost))return true; + if(KviQString::matchWildExpressions(m_szHost,mask.m_szHost))return true; } } return false; @@ -569,11 +569,14 @@ bool KviIrcMask::matches(const KviIrcMask &mask) const bool KviIrcMask::matchesFixed(const KviIrcMask &mask) const { - if(KviQString::matchStringCI(m_szNick,mask.m_szNick,0,1)) + if(KviQString::matchString(m_szNick,mask.m_szNick,false,true)) { - if(KviQString::matchStringCI(m_szUser,mask.m_szUser,0,1)) + if(KviQString::matchString(m_szUser,mask.m_szUser,false,true)) { - if(KviQString::matchStringCI(m_szHost,mask.m_szHost,0,1))return true; + if(KviQString::matchString(m_szHost,mask.m_szHost,false,true)) + { + return true; + } } } return false; @@ -602,9 +605,9 @@ bool KviIrcMask::matches(const char * nick,const char * user,const char * host) bool KviIrcMask::matchesFixed(const QString &nick,const QString &user,const QString &host) const { - if(!KviQString::matchStringCI(m_szNick,nick,0,1))return false; - if(!KviQString::matchStringCI(m_szUser,user,0,1))return false; - if(!KviQString::matchStringCI(m_szHost,host,0,1))return false; + if(!KviQString::matchString(m_szNick,nick,false,true)) return false; + if(!KviQString::matchString(m_szUser,user,false,true)) return false; + if(!KviQString::matchString(m_szHost,host,false,true)) return false; return true; } diff --git a/src/kvilib/irc/kvi_nickserv.cpp b/src/kvilib/irc/kvi_nickserv.cpp index a7222fbe0..401ac555e 100644 --- a/src/kvilib/irc/kvi_nickserv.cpp +++ b/src/kvilib/irc/kvi_nickserv.cpp @@ -199,7 +199,7 @@ KviNickServRule * KviNickServRuleSet::matchRule(const QString &szNick,const KviI if(!m_pRules)return 0; for(KviNickServRule *r = m_pRules->first();r;r = m_pRules->next()) { - if(!KviQString::matchStringCI(r->registeredNick(),szNick,false,true)) continue; + if(!KviQString::matchString(r->registeredNick(),szNick,false,true)) continue; if(!szServer.isEmpty()) { QRegExp res(r->serverMask(),Qt::CaseInsensitive,QRegExp::Wildcard); diff --git a/src/kvilib/net/kvi_dns.cpp b/src/kvilib/net/kvi_dns.cpp index 2911524ab..25fed2a8a 100644 --- a/src/kvilib/net/kvi_dns.cpp +++ b/src/kvilib/net/kvi_dns.cpp @@ -413,14 +413,14 @@ const QString & KviDns::firstHostname() { QString * pStr = result()->hostnameList()->first(); if(pStr)return *pStr; - return KviQString::empty; + return KviQString::Empty; } const QString & KviDns::firstIpAddress() { QString * pStr = result()->ipAddressList()->first(); if(pStr)return *pStr; - return KviQString::empty; + return KviQString::Empty; } const QString & KviDns::query() diff --git a/src/kvilib/tal/kvi_tal_popupmenu.h b/src/kvilib/tal/kvi_tal_popupmenu.h index edb497e74..644b6fa6d 100644 --- a/src/kvilib/tal/kvi_tal_popupmenu.h +++ b/src/kvilib/tal/kvi_tal_popupmenu.h @@ -40,7 +40,7 @@ protected: QHash<QAction*, QSignalMapper*> signalMapper; int identifier; public: - KviTalPopupMenu(QWidget * pParent=0,const QString &szName = KviQString::empty); + KviTalPopupMenu(QWidget * pParent=0,const QString &szName = KviQString::Empty); virtual ~KviTalPopupMenu() ; int insertItem(const QString &szText); int insertItem(const QPixmap &pix,const QString &szText); diff --git a/src/kvirc/kernel/kvi_ircconnectionserverinfo.cpp b/src/kvirc/kernel/kvi_ircconnectionserverinfo.cpp index 9a739112a..d6286ff25 100644 --- a/src/kvirc/kernel/kvi_ircconnectionserverinfo.cpp +++ b/src/kvirc/kernel/kvi_ircconnectionserverinfo.cpp @@ -213,14 +213,14 @@ const QString & KviBasicIrcServerInfo::getChannelModeDescription(QChar mode) { QString tmp=getCustomChannelModeDescription(mode); if(tmp.isNull()) return getBasicChannelModeDescription(mode); - return KviQString::empty; + return KviQString::Empty; } const QString & KviBasicIrcServerInfo::getUserModeDescription(QChar mode) { QString tmp=getCustomUserModeDescription(mode); if(tmp.isNull()) return getBasicUserModeDescription(mode); - return KviQString::empty; + return KviQString::Empty; } const QString & KviBasicIrcServerInfo::getBasicChannelModeDescription(QChar mode) @@ -260,7 +260,7 @@ const QString & KviBasicIrcServerInfo::getBasicChannelModeDescription(QChar mode case '7': return __tr2qs("Only 7-bit letters in nicknames allowed"); break; case 'x': return __tr2qs("Impossible to use both 7-bit and 8-bit letters in nicknames"); break; } - return KviQString::empty; + return KviQString::Empty; } const QString & KviBasicIrcServerInfo::getBasicUserModeDescription(QChar mode) @@ -281,5 +281,5 @@ const QString & KviBasicIrcServerInfo::getBasicUserModeDescription(QChar mode) case 'd': return __tr2qs("d: Obscure 'DEBUG' flag"); break; case 'n': return __tr2qs("n: Recipient for nick changes"); break; } - return KviQString::empty; + return KviQString::Empty; } diff --git a/src/kvirc/kernel/kvi_ircconnectionserverinfo.h b/src/kvirc/kernel/kvi_ircconnectionserverinfo.h index 460373561..108c542b2 100644 --- a/src/kvirc/kernel/kvi_ircconnectionserverinfo.h +++ b/src/kvirc/kernel/kvi_ircconnectionserverinfo.h @@ -33,11 +33,11 @@ class KVIRC_API KviBasicIrcServerInfo protected: QString m_szServerVersion; public: - KviBasicIrcServerInfo(const QString & version = KviQString::empty); + KviBasicIrcServerInfo(const QString & version = KviQString::Empty); virtual ~KviBasicIrcServerInfo(); protected: - virtual const QString & getCustomChannelModeDescription(QChar) { return KviQString::empty; }; - virtual const QString & getCustomUserModeDescription(QChar) { return KviQString::empty; }; + virtual const QString & getCustomChannelModeDescription(QChar) { return KviQString::Empty; }; + virtual const QString & getCustomUserModeDescription(QChar) { return KviQString::Empty; }; private: const QString & getBasicChannelModeDescription(QChar mode); const QString & getBasicUserModeDescription(QChar mode); @@ -50,7 +50,7 @@ public: class KVIRC_API KviUnrealIrcServerInfo : public KviBasicIrcServerInfo { public: - KviUnrealIrcServerInfo(const QString & version = KviQString::empty) + KviUnrealIrcServerInfo(const QString & version = KviQString::Empty) :KviBasicIrcServerInfo(version) {;}; virtual char getRegisterModeChar() { return 'r'; }; }; @@ -58,7 +58,7 @@ public: class KVIRC_API KviBahamutIrcServerInfo : public KviBasicIrcServerInfo { public: - KviBahamutIrcServerInfo(const QString & version = KviQString::empty) + KviBahamutIrcServerInfo(const QString & version = KviQString::Empty) :KviBasicIrcServerInfo(version) {;}; virtual char getRegisterModeChar() { return 'r'; }; }; @@ -66,7 +66,7 @@ public: class KVIRC_API KviHyperionIrcServerInfo : public KviBasicIrcServerInfo { public: - KviHyperionIrcServerInfo(const QString & version = KviQString::empty) + KviHyperionIrcServerInfo(const QString & version = KviQString::Empty) :KviBasicIrcServerInfo(version) {;}; virtual char getRegisterModeChar() { return 'e'; }; }; diff --git a/src/kvirc/kernel/kvi_userinput.h b/src/kvirc/kernel/kvi_userinput.h index 263eb6d8d..d3a059752 100644 --- a/src/kvirc/kernel/kvi_userinput.h +++ b/src/kvirc/kernel/kvi_userinput.h @@ -49,7 +49,7 @@ namespace KviUserInput * \return bool * \warning May destroy szData */ - KVIRC_API bool parse(QString & szData, KviWindow * pWindow, const QString & szContext = KviQString::empty, bool bUserFriendlyCommandline = false); + KVIRC_API bool parse(QString & szData, KviWindow * pWindow, const QString & szContext = KviQString::Empty, bool bUserFriendlyCommandline = false); /** * \brief Returns true if the command run @@ -59,7 +59,7 @@ namespace KviUserInput * \param bUserFriendlyCommandline Whether the commandline is in user friendly mode * \return bool */ - KVIRC_API bool parseCommand(const QString & szData, KviWindow * pWindow, const QString & szContext = KviQString::empty, bool bUserFriendlyCommandline = false); + KVIRC_API bool parseCommand(const QString & szData, KviWindow * pWindow, const QString & szContext = KviQString::Empty, bool bUserFriendlyCommandline = false); /** * \brief Parses the non command input data @@ -69,7 +69,7 @@ namespace KviUserInput */ KVIRC_API void parseNonCommand(QString & szData, KviWindow * pWindow); - //bool parseCommandWithSingleArgument(const QString & szData, KviWindow * pWindow, const QString & szContext = KviQString::empty); + //bool parseCommandWithSingleArgument(const QString & szData, KviWindow * pWindow, const QString & szContext = KviQString::Empty); } #endif //_KVI_USERINPUT_H_ diff --git a/src/kvirc/kvs/kvi_kvs_scriptaddonmanager.cpp b/src/kvirc/kvs/kvi_kvs_scriptaddonmanager.cpp index 3a6114705..58009889a 100644 --- a/src/kvirc/kvs/kvi_kvs_scriptaddonmanager.cpp +++ b/src/kvirc/kvs/kvi_kvs_scriptaddonmanager.cpp @@ -116,13 +116,13 @@ const QString & KviKvsScriptAddon::uninstallCallbackCode() const QString & KviKvsScriptAddon::configureCallbackCode() { if(m_pConfigureCallback)return m_pConfigureCallback->code(); - return KviQString::empty; + return KviQString::Empty; } const QString & KviKvsScriptAddon::helpCallbackCode() { if(m_pHelpCallback)return m_pHelpCallback->code(); - return KviQString::empty; + return KviQString::Empty; } bool KviKvsScriptAddon::load(KviConfig * cfg,const QString &szName) diff --git a/src/kvirc/kvs/kvi_kvs_variant.h b/src/kvirc/kvs/kvi_kvs_variant.h index ffc505e41..99298b729 100644 --- a/src/kvirc/kvs/kvi_kvs_variant.h +++ b/src/kvirc/kvs/kvi_kvs_variant.h @@ -163,7 +163,7 @@ public: kvs_int_t integer() const { return m_pData ? m_pData->m_u.iInteger : 0; }; kvs_real_t real() const { return m_pData ? *(m_pData->m_u.pReal) : 0.0; }; - const QString & string() const { return m_pData ? *(m_pData->m_u.pString) : KviQString::empty; }; + const QString & string() const { return m_pData ? *(m_pData->m_u.pString) : KviQString::Empty; }; KviKvsArray * array() const { return m_pData ? m_pData->m_u.pArray : 0; }; KviKvsHash * hash() const { return m_pData ? m_pData->m_u.pHash : 0; }; bool boolean() const { return m_pData ? m_pData->m_u.bBoolean : false; }; diff --git a/src/kvirc/ui/kvi_ircview_loghandling.cpp b/src/kvirc/ui/kvi_ircview_loghandling.cpp index 4604a7607..78536f504 100644 --- a/src/kvirc/ui/kvi_ircview_loghandling.cpp +++ b/src/kvirc/ui/kvi_ircview_loghandling.cpp @@ -145,12 +145,12 @@ const QString & KviIrcView::lastMessageText() } pCur=pCur->pPrev; } - return KviQString::empty; + return KviQString::Empty; } const QString & KviIrcView::lastLineOfText() { - if(!m_pLastLine)return KviQString::empty; + if(!m_pLastLine)return KviQString::Empty; return m_pLastLine->szText; } diff --git a/src/kvirc/ui/kvi_window.cpp b/src/kvirc/ui/kvi_window.cpp index 06601252b..1f140bf1b 100644 --- a/src/kvirc/ui/kvi_window.cpp +++ b/src/kvirc/ui/kvi_window.cpp @@ -424,14 +424,14 @@ const QString & KviWindow::lastLineOfText() { if(m_pIrcView) return m_pIrcView->lastLineOfText(); - return KviQString::empty; + return KviQString::Empty; } const QString & KviWindow::lastMessageText() { if(m_pIrcView) return m_pIrcView->lastMessageText(); - return KviQString::empty; + return KviQString::Empty; } // The following three have to be here even if the crypt support is disabled...moc does not support conditional compilations @@ -561,7 +561,7 @@ void KviWindow::saveProperties(KviConfig *cfg) QTextCodec * c = defaultTextCodec(); if(c && m_pTextCodec) { - if(KviQString::equalCI(szCodec,c->name().data()))szCodec = KviQString::empty; // store "default" + if(KviQString::equalCI(szCodec,c->name().data()))szCodec = KviQString::Empty; // store "default" } QString szKey = "TextEncoding_"; szKey += m_szName; @@ -582,7 +582,7 @@ void KviWindow::loadProperties(KviConfig *cfg) { QString szKey = "TextEncoding_"; szKey += m_szName; - setTextEncoding(cfg->readQStringEntry(szKey,KviQString::empty).toUtf8().data()); + setTextEncoding(cfg->readQStringEntry(szKey,KviQString::Empty).toUtf8().data()); if(m_pInput) { m_pInput->setButtonsHidden(cfg->readBoolEntry("inputToolButtonsHidden",KVI_OPTION_BOOL(KviOption_boolHideInputToolButtons))); m_pInput->setUserFriendly(cfg->readBoolEntry("commandLineIsUserFriendly",KVI_OPTION_BOOL(KviOption_boolCommandlineInUserFriendlyModeByDefault))); diff --git a/src/kvirc/ui/kvi_window.h b/src/kvirc/ui/kvi_window.h index 697c0a2c0..a55faeeb7 100644 --- a/src/kvirc/ui/kvi_window.h +++ b/src/kvirc/ui/kvi_window.h @@ -219,9 +219,9 @@ public: inline KviInput * input(){ return m_pInput; }; // The target of this window: empty when it makes no sense :D - virtual const QString & target(){ return KviQString::empty; }; + virtual const QString & target(){ return KviQString::Empty; }; // The local nickname bound to this window: might be empty when a local nickname makes no sense - virtual const QString & localNick(){ return KviQString::empty; }; + virtual const QString & localNick(){ return KviQString::Empty; }; #ifdef COMPILE_CRYPT_SUPPORT KviCryptSessionInfo * cryptSessionInfo(){ return m_pCryptSessionInfo; }; diff --git a/src/modules/chan/libkvichan.cpp b/src/modules/chan/libkvichan.cpp index ed51151ff..7f72a9459 100644 --- a/src/modules/chan/libkvichan.cpp +++ b/src/modules/chan/libkvichan.cpp @@ -1343,7 +1343,7 @@ static bool chan_kvs_fnc_matchban(KviKvsModuleFunctionCall * c) for(KviMaskEntry * e = l->first();e;e = l->next()) { - if(KviQString::matchStringCI(e->szMask,szMask)) + if(KviQString::matchString(e->szMask,szMask)) { c->returnValue()->setString(e->szMask); return true; @@ -1392,7 +1392,7 @@ static bool chan_kvs_fnc_matchbanexception(KviKvsModuleFunctionCall * c) for(KviMaskEntry * e = l->first();e;e = l->next()) { - if(KviQString::matchStringCI(e->szMask,szMask)) + if(KviQString::matchString(e->szMask,szMask)) { c->returnValue()->setString(e->szMask); return true; @@ -1441,7 +1441,7 @@ static bool chan_kvs_fnc_matchinvite(KviKvsModuleFunctionCall * c) for(KviMaskEntry * e = l->first();e;e = l->next()) { - if(KviQString::matchStringCI(e->szMask,szMask)) + if(KviQString::matchString(e->szMask,szMask)) { c->returnValue()->setString(e->szMask); return true; @@ -1494,7 +1494,7 @@ static bool chan_kvs_fnc_matchqban(KviKvsModuleFunctionCall * c) for(KviMaskEntry * e = l->first();e;e = l->next()) { - if(KviQString::matchStringCI(e->szMask,szMask)) + if(KviQString::matchString(e->szMask,szMask)) { c->returnValue()->setString(e->szMask); return true; diff --git a/src/modules/logview/logviewmdiwindow.cpp b/src/modules/logview/logviewmdiwindow.cpp index 194743da2..9252730e5 100644 --- a/src/modules/logview/logviewmdiwindow.cpp +++ b/src/modules/logview/logviewmdiwindow.cpp @@ -273,13 +273,13 @@ void KviLogViewMDIWindow::setupItemList() continue; if(enableNameFilter) - if(!KviQString::matchStringCI(nameFilterText,pFile->name())) + if(!KviQString::matchString(nameFilterText,pFile->name())) continue; if(enableContentFilter) { pFile->getText(textBuffer,m_szLogDirectory); - if(!KviQString::matchStringCI(contentFilterText,textBuffer)) + if(!KviQString::matchString(contentFilterText,textBuffer)) continue; } diff --git a/src/modules/regchan/libkviregchan.cpp b/src/modules/regchan/libkviregchan.cpp index 2201fd1e5..356103582 100644 --- a/src/modules/regchan/libkviregchan.cpp +++ b/src/modules/regchan/libkviregchan.cpp @@ -264,8 +264,8 @@ static bool regchan_kvs_fnc_list(KviKvsModuleFunctionCall * c) while(KviRegisteredChannelList * l = it.current()) { for(KviRegisteredChannel * ch = l->first();ch;ch = l->next()) - if(KviQString::matchWildExpressionsCI(ch->name().ptr(),szChan) && - KviQString::matchWildExpressionsCI(ch->netMask().ptr(),szNetmask)) + if(KviQString::matchWildExpressions(ch->name().ptr(),szChan) && + KviQString::matchWildExpressions(ch->netMask().ptr(),szNetmask)) { // FIXME: WE NEED TO RETURN AN ARRAY OF 2-ELEMENT ARRAYS (chan name, netmask) pArray->set(aid,new KviKvsVariant(QString(ch->name()+"@"+ch->netMask()))); diff --git a/src/modules/str/libkvistr.cpp b/src/modules/str/libkvistr.cpp index a735b1e1c..d23eb67c0 100644 --- a/src/modules/str/libkvistr.cpp +++ b/src/modules/str/libkvistr.cpp @@ -1309,7 +1309,7 @@ static bool str_kvs_fnc_match(KviKvsModuleFunctionCall * c) KVSM_PARAMETERS_END(c) bool bRegExp = (szFlags.indexOf(QChar('r')) != -1) || (szFlags.indexOf(QChar('R')) != -1); bool bExact = (szFlags.indexOf(QChar('e')) != -1) || (szFlags.indexOf(QChar('E')) != -1); - c->returnValue()->setBoolean(KviQString::matchStringCS(szWildcard,szString,bRegExp,bExact)); + c->returnValue()->setBoolean(KviQString::matchString(szWildcard,szString,bRegExp,bExact,true)); return true; } @@ -1355,7 +1355,7 @@ static bool str_kvs_fnc_matchnocase(KviKvsModuleFunctionCall * c) KVSM_PARAMETERS_END(c) bool bRegExp = (szFlags.indexOf(QChar('r')) != -1) || (szFlags.indexOf(QChar('R')) != -1); bool bExact = (szFlags.indexOf(QChar('e')) != -1) || (szFlags.indexOf(QChar('E')) != -1); - c->returnValue()->setBoolean(KviQString::matchStringCI(szWildcard,szString,bRegExp,bExact)); + c->returnValue()->setBoolean(KviQString::matchString(szWildcard,szString,bRegExp,bExact)); return true; } |
