51 #ifdef _KVI_STRING_CPP_
54 #define __KVI_EXTERN extern
68 #define kvi_strEqualNoLocaleCI(str1, str2) kvi_strEqualCI(str1, str2)
69 #define kvi_strEqualNoLocaleCIN(str1, str2, len) kvi_strEqualCIN(str1, str2, len)
70 #define kvi_strLen(str) strlen(str)
132 KviCString(
const char * bg,
const char * end);
138 KviCString(KviFormatConstructorTag tag,
const char * fmt, ...);
172 char *
ptr()
const {
return m_ptr; };
174 int len()
const {
return m_len; };
178 operator const char *()
const {
return m_ptr; };
180 bool isEmpty()
const {
return (m_len == 0); };
181 bool hasData()
const {
return (m_len != 0); };
187 bool hasNonWhiteSpaceData()
const;
190 char &
at(
int idx)
const {
return ((idx < m_len) ? m_ptr[idx] : m_ptr[m_len]); };
193 bool lastCharIs(
char ch)
const {
return (m_len > 0) ? (*(m_ptr + m_len - 1) == ch) :
false; };
220 KviCString & setStr(
const char * str,
int len = -1);
222 void extractFromString(
const char * begin,
const char * end);
232 void append(
const QString & str);
234 void append(
const char * str);
235 void append(
const char * str,
int len);
236 void append(KviFormatConstructorTag dummy,
const char * fmt, ...);
240 void prepend(
const char * str);
241 void prepend(
const char * str,
int len);
251 void toUpperISO88591();
253 void toLowerISO88591();
261 KviCString & operator=(
const QByteArray & str);
288 if(m_len != other.
m_len)
294 if(m_len != other.
m_len)
313 int hexToBuffer(
char ** buffer,
bool bNullToNewlines =
false);
315 void bufferToBase64(
const char * buffer,
int len);
317 int base64ToBuffer(
char ** buffer,
bool bNullToNewlines =
false);
320 static void freeBuffer(
char * buffer);
339 KviCString & insert(
int idx,
const char * data);
342 KviCString & replaceAll(
const char c,
const char * str);
344 KviCString & replaceAll(
const char * toFind,
const char * str,
bool bCaseS =
true);
363 KviCString & padRight(
int iLen,
const char c =
'\0');
382 KviCString ** splitToArray(
char sep,
int max,
int * realCount)
const;
389 void joinFromArray(
KviCString ** strings,
const char * sep = 0,
bool bLastSep =
false);
397 KviCString & hexEncodeWithTable(
const unsigned char table[256]);
407 bool contains(
const char * str,
bool caseS =
true)
const;
409 bool contains(
char c,
bool caseS =
true)
const;
412 int occurrences(
const char * str,
bool caseS =
true)
const;
414 int occurrences(
char c,
bool caseS =
true)
const;
423 int findFirstIdx(
char c)
const;
427 int findFirstIdx(
const char * str,
bool caseS =
true)
const;
430 int findLastIdx(
char c)
const;
434 int findLastIdx(
const char * str,
bool caseS =
true)
const;
436 int find(
char c,
int startIdx)
const;
437 int find(
const char * str,
int startIdx,
bool caseS =
true)
const;
438 int findRev(
const char * str,
int startIdx,
bool caseS =
true)
const;
445 long toLong(
bool * bOk = 0)
const;
446 unsigned long toULong(
bool * bOk = 0)
const;
447 long long toLongLong(
bool * bOk = 0)
const;
448 unsigned long long toULongLong(
bool * bOk = 0)
const;
449 char toChar(
bool * bOk = 0)
const {
return (
char)toLong(bOk); };
450 unsigned char toUChar(
bool * bOk = 0)
const {
return (
unsigned char)toULong(bOk); };
451 int toInt(
bool * bOk = 0)
const {
return (
int)toLong(bOk); };
452 unsigned int toUInt(
bool * bOk = 0)
const {
return (
unsigned int)toULong(bOk); };
453 short toShort(
bool * bOk = 0)
const {
return (
short)toLong(bOk); };
454 unsigned short toUShort(
bool * bOk = 0)
const {
return (
unsigned short)toLong(bOk); };
471 bool isUnsignedNum()
const;
474 long toLongExt(
bool * bOk = 0,
int base = 0);
495 static bool ext_contains(
const char * data,
const char * item,
bool caseS =
true);
531 const char ** r1,
const char ** r2);
535 #define kvi_matchString kvi_matchStringCI
613 #endif //_KVI_STRING_H_
__KVI_EXTERN KVILIB_API int kvi_strMatchRevCS(const char *str1, const char *str2, int index=-1)
Definition: KviCString.cpp:932
__KVI_EXTERN bool operator==(const KviCString &left, const KviCString &right)
Definition: KviCString.h:552
__KVI_EXTERN KVILIB_API bool kvi_matchWildExpr(register const char *m1, register const char *m2)
Definition: KviHeapObject.h:124
__KVI_EXTERN KVILIB_API int kvi_strcmpCI(const char *str1, const char *str2)
Definition: KviCString.cpp:891
Definition: KviCString.h:105
int toInt(bool *bOk=0) const
Definition: KviCString.h:451
KviCString & setNum(char num)
Definition: KviCString.h:463
int m_len
Definition: KviCString.h:164
char s char s char s s s s s char char c s *s c s s s d c s *s d c d d d d c
Definition: KviIrcNumericCodes.h:391
void ensureLastCharIs(char ch)
Definition: KviCString.h:244
__KVI_EXTERN KVILIB_API bool kvi_qstringEqualCI(const QString &s1, const QString &s2)
Definition: KviCString.cpp:42
__KVI_EXTERN KVILIB_API int kvi_vsnprintf(char *buffer, int len, const char *fmt, kvi_va_list list)
Definition: KviCString.cpp:535
__KVI_EXTERN KVILIB_API bool kvi_strEqualCI(const char *str1, const char *str2)
Definition: KviCString.cpp:873
unsigned int toUInt(bool *bOk=0) const
Definition: KviCString.h:452
__KVI_EXTERN KVILIB_API bool kvi_matchStringWithTerminator(register const char *exp, register const char *str, char terminator, const char **r1, const char **r2)
__KVI_EXTERN KVILIB_API bool kvi_strEqualCIN(const char *str1, const char *str2, int len)
Definition: KviCString.cpp:858
int kvi_compare(const KviCString *p1, const KviCString *p2)
Definition: KviCString.h:608
KviCString & setNum(unsigned char num)
Definition: KviCString.h:464
char & at(int idx) const
Definition: KviCString.h:190
bool firstCharIs(char ch) const
Definition: KviCString.h:194
__KVI_EXTERN KVILIB_API kvi_wslen_t kvi_wstrlen(const kvi_wchar_t *str)
Definition: KviCString.cpp:34
void stripRight(QString &szSrc, const QChar &c)
Trims all c chars at the end of the given string.
Definition: KviQString.cpp:553
bool equalsCSN(const char *other, int len) const
Definition: KviCString.h:301
KviFormatConstructorTag
Definition: KviCString.h:111
__KVI_EXTERN KVILIB_API int kvi_wvsnprintcf(kvi_wchar_t *buffer, kvi_wslen_t len, const char *fmt, kvi_va_list list)
kvi_u16_t kvi_wchar_t
Definition: KviCString.h:87
#define kvi_va_list
Definition: kvi_stdarg.h:31
bool isEmpty() const
Definition: KviCString.h:180
void cutToLast(QString &szSrc, const QChar &c, bool bIncluded, bool bClearIfNotFound)
Cuts the string until the last occurrence of the given char is found.
Definition: KviQString.cpp:1172
void vsprintf(QString &szSrc, const QString &szFmt, kvi_va_list list)
Writes to the character string.
Definition: KviQString.cpp:634
QString lowerISO88591(const QString &szSrc)
Returns an ISO-8859-1 lower case string.
Definition: KviQString.cpp:1254
bool hasData() const
Definition: KviCString.h:181
bool equalsCS(const KviCString &other) const
Definition: KviCString.h:292
void stripRightWhiteSpace(QString &szSrc)
Trims all the whitespaces at the end of the given string.
Definition: KviQString.cpp:533
short toShort(bool *bOk=0) const
Definition: KviCString.h:453
__KVI_EXTERN KVILIB_API bool kvi_strEqualCS(const char *str1, const char *str2)
Definition: KviCString.cpp:827
void transliterate(QString &szSrc, const QString &szToFind, const QString &szReplacement)
Replaces a string with another.
Definition: KviQString.cpp:1282
KviCString & operator+=(char c)
Definition: KviCString.h:274
unsigned char toUChar(bool *bOk=0) const
Definition: KviCString.h:450
void cutToFirst(QString &szSrc, const QChar &c, bool bIncluded, bool bClearIfNotFound)
Cuts the string until the first occurrence of the given char is found.
Definition: KviQString.cpp:1148
unsigned short toUShort(bool *bOk=0) const
Definition: KviCString.h:454
void cutFromFirst(QString &szSrc, const QChar &c, bool bIncluded)
Cuts the string after the first occurrence of the given char.
Definition: KviQString.cpp:1114
__KVI_EXTERN bool operator!=(const KviCString &left, const KviCString &right)
Definition: KviCString.h:564
#define __KVI_EXTERN
Definition: KviCString.h:54
KviCString & setNum(unsigned int num)
Definition: KviCString.h:460
QString leftToFirst(QString &szSrc, const QChar &c, bool bIncluded, bool bReturnFullStringIfNotFound)
Returns the string up to the the first occurrence of the given char.
Definition: KviQString.cpp:1196
KviCString & setNum(int num)
Definition: KviCString.h:459
bool equalsCI(const char *other) const
Definition: KviCString.h:298
void stripLeft(QString &szSrc, const QChar &c)
Trims all c chars at the start of the given string.
Definition: KviQString.cpp:573
KviCString & operator+=(const char *str)
Definition: KviCString.h:269
__KVI_EXTERN KVILIB_API const char * kvi_extractUpTo(KviCString &str, const char *aux_ptr, char sep= ' ')
Definition: KviCString.cpp:522
__KVI_EXTERN KviCString operator+(const KviCString &left, const KviCString &right)
Definition: KviCString.h:577
__KVI_EXTERN KVILIB_API int kvi_strcmpCS(const char *str1, const char *str2)
Definition: KviCString.cpp:916
__KVI_EXTERN KVILIB_API bool kvi_matchStringCI(register const char *exp, register const char *str)
kvi_u32_t kvi_wslen_t
Definition: KviCString.h:88
void bufferToHex(QString &szRetBuffer, const unsigned char *pcBuffer, unsigned int uLen)
Returns an hexadecimal converted string starting from a buffer.
Definition: KviQString.cpp:1302
int len() const
Definition: KviCString.h:174
QString getToken(QString &szSrc, const QChar &sep)
Returns a token from a string.
Definition: KviQString.cpp:493
__KVI_EXTERN KVILIB_API bool kvi_matchStringCS(register const char *exp, register const char *str)
QString leftToLast(QString &szSrc, const QChar &c, bool bIncluded, bool bReturnFullStringIfNotFound)
Returns the string up to the last occurrence of the given char.
Definition: KviQString.cpp:1212
bool equalsCS(const char *other) const
Definition: KviCString.h:299
__KVI_EXTERN KVILIB_API bool kvi_matchWildExprWithTerminator(register const char *m1, register const char *m2, char terminator, const char **r1, const char **r2)
void cutFromLast(QString &szSrc, const QChar &c, bool bIncluded)
Cuts the string after the last occurrence of the given char.
Definition: KviQString.cpp:1131
KviCString & operator+=(const KviCString &str)
Definition: KviCString.h:264
KviCString & setNum(short num)
Definition: KviCString.h:461
Definition: KviCString.h:113
KviCString & setNum(unsigned short num)
Definition: KviCString.h:462
bool equalsCIN(const char *other, int len) const
Definition: KviCString.h:300
bool lastCharIs(char ch) const
Definition: KviCString.h:193
bool equalsCI(const KviCString &other) const
Definition: KviCString.h:286
KviCString & operator+=(const QString &str)
Definition: KviCString.h:279
__KVI_EXTERN KVILIB_API const char * kvi_extractToken(KviCString &str, const char *aux_ptr, char sep= ' ')
Definition: KviCString.cpp:505
__KVI_EXTERN KVILIB_API bool kvi_strEqualCSN(const char *str1, const char *str2, int len)
Definition: KviCString.cpp:841
This file contains compile time settings.
KviCString & hexDecode()
Definition: KviCString.h:400
char * m_ptr
Definition: KviCString.h:163
QString upperISO88591(const QString &szSrc)
Returns an ISO-8859-1 upper case string.
Definition: KviQString.cpp:1228
char * ptr() const
Definition: KviCString.h:172
__KVI_EXTERN KVILIB_API int kvi_irc_vsnprintf(char *buffer, const char *fmt, kvi_va_list list, bool *bTruncated)
Definition: KviCString.cpp:694
char toChar(bool *bOk=0) const
Definition: KviCString.h:449
#define KVILIB_API
Definition: kvi_settings.h:125
__KVI_EXTERN KVILIB_API int kvi_wvsnprintf(kvi_wchar_t *buffer, kvi_wslen_t len, const kvi_wchar_t *fmt, kvi_va_list list)