36 # ifdef USE_SECURE_FUNCS
37 strcpy_s (dest, destSize, src);
51 # ifdef USE_SECURE_FUNCS
52 strcpy_s (dest, destSize, src);
64 # ifdef USE_SECURE_FUNCS
79 # ifdef USE_SECURE_FUNCS
80 strcat_s (dest, destSize, src);
106 kkint32 zed = (toupper (*left)) - (toupper (*right));
108 while ((zed == 0) && (*left != 0))
111 zed = (toupper (*left)) - (toupper (*right));
145 kkint32 zed = (toupper (*left)) - (toupper (*right));
146 while ((zed == 0) && (*left != 0) && (x < len))
148 ++left; ++right; ++x;
149 zed = (toupper (*left)) - (toupper (*right));
164 const char* formatSpec,
168 # ifdef USE_SECURE_FUNCS
169 return sprintf_s (buff, buffSize, formatSpec, right);
171 return sprintf (buff, formatSpec, right);
179 const char* formatSpec,
183 # ifdef USE_SECURE_FUNCS
184 return sprintf_s (buff, buffSize, formatSpec, right);
186 return sprintf (buff, formatSpec, right);
195 const char* formatSpec,
199 # ifdef USE_SECURE_FUNCS
200 return sprintf_s (buff, buffSize, formatSpec, right);
202 return sprintf (buff, formatSpec, right);
210 const char* formatSpec,
214 # ifdef USE_SECURE_FUNCS
215 return sprintf_s (buff, buffSize, formatSpec, right);
217 return sprintf (buff, formatSpec, right);
225 const char* formatSpec,
230 # ifdef USE_SECURE_FUNCS
231 return sprintf_s (buff, buffSize, formatSpec, right);
233 return sprintf (buff, formatSpec, right);
241 const char* formatSpec,
246 # ifdef USE_SECURE_FUNCS
247 return sprintf_s (buff, buffSize, formatSpec, right);
249 return sprintf (buff, formatSpec, right);
257 const char* formatSpec,
262 #ifdef USE_SECURE_FUNCS
263 return sprintf_s (buff, buffSize, formatSpec, precision, d);
265 return sprintf (buff, formatSpec, precision, d);
273 char const* formatSpec,
277 #ifdef USE_SECURE_FUNCS
278 return sprintf_s (buff, buffSize, formatSpec, d);
280 return sprintf (buff, formatSpec, d);
312 return strchr (str, ch);
333 while ((*s1) && (*s2) && (toupper (*s1) == toupper (*s2)))
383 return (strcmp (s1, s2) == 0);
418 size_t l1 = strlen (s1);
419 size_t l2 = strlen (s2);
425 for (size_t i = 0; i < l1; i++)
427 if (toupper (s1[i]) != toupper (s2[i]))
447 for (kkuint32 x = 0; x < len; ++x)
448 if (toupper (s1[x]) != toupper (s2[x]))
467 spaceNeeded = (kkint32)strlen (src) + 1;
468 *dest =
new char[spaceNeeded];
472 KKStr errMsg =
"KKStr::StrReplace ***ERROR*** Failed to allocate SpaceNeeded[" + StrFormatInt (spaceNeeded
, "#####0") + "].";
473 cerr << errMsg << std::endl << std::endl;
485 KKStr errMsg =
"StrReplace ***ERROR*** Failed to allocate Empty KKStr.";
486 cerr << std::endl << errMsg << std::endl;
505 char* s1Ptr = (
char*)s1
.Str ();
506 char* s2Ptr = (
char*)s2
.Str ();
509 return (s2Ptr != NULL);
514 while ((*s1Ptr != 0) && (tolower (*s1Ptr) == tolower (*s2Ptr)))
520 return (*s1Ptr) < (*s2Ptr);
530 AllocateStrSpace (10);
542 AllocateStrSpace (1);
548 kkuint32 newLen = (kkuint32)strlen (str);
549 AllocateStrSpace (newLen + 1);
566 AllocateStrSpace (1);
571 if (str.val[str.len] != 0)
573 std::cerr << std::endl
574 <<
"KKStr::KKStr ***ERROR*** Missing terminating NULL" << std::endl
579 if (neededSpace > str.allocatedSize)
581 KKStr errMsg =
"KKStr::KKStr (const KKStr& str) AllocatedSize[" + ::StrFromUint16(str.allocatedSize
) + "] on Source KKStr is to Short";
582 std::cerr << endl << errMsg <<
" ***ERROR***" << std::endl << std::endl;
586 AllocateStrSpace (str.allocatedSize);
588 std::cerr << std::endl <<
"KKStr::KKStr ***ERROR*** Allocation Failed." << std::endl << std::endl;
589 throw KKException("KKStr::KKStr ***ERROR*** Allocation Failed.");
592 std::memcpy (val, str.val, str.len);
600 allocatedSize (str.allocatedSize),
604 str.allocatedSize = 0;
624 if ((precision < 0) || (precision > 10))
633 kkuint16 newLen = (kkuint16)strlen (buff);
634 AllocateStrSpace (newLen + 1);
661 else if ((
kkuint32)size >= KKStrIntMax)
664 <<
"KKStr::KKStr ***WARNNING*** Trying to allocate Size[" << size <<
"] which is >= KKStrIntMax[" << KKStrIntMax <<
"]." << std::endl
666 size = KKStrIntMax - 1;
669 AllocateStrSpace (size);
682 AllocateStrSpace ((kkint32)(s.size () + 1));
684 len = (kkuint16)s.size ();
685 for (kkint32 x = 0; x < len; ++x)
701 if (startPos > endPos)
703 AllocateStrSpace (1);
707 kkuint32 subStrLen = 1 + endPos - startPos;
708 if (subStrLen > (KKStrIntMax - 1))
710 cerr <<
"KKStr::KKStr ***ERROR*** requested SubStr[" << startPos <<
", " << endPos <<
"] len[" << subStrLen <<
"] is greater than KKStrIntMax[" << (KKStrIntMax - 1) <<
"]" << std::endl;
711 endPos = (startPos + KKStrIntMax - 2);
712 subStrLen = 1 + endPos - startPos;
715 AllocateStrSpace (1 + subStrLen);
719 memcpy (val, src + startPos, subStrLen);
734 <<
"KKStr::AllocateStrSpace ***ERROR*** Previous val was not deleted." 738 if (size >= KKStrIntMax)
741 cerr <<
"KKStr::AllocateStrSpace ***ERROR*** Size[" << size <<
"] is larger than KKStrIntMax[" << KKStrIntMax <<
"]" << std::endl;
743 errStr <<
"KKStr::AllocateStrSpace ***ERROR*** Size[" << size <<
"] is larger than KKStrIntMax[" << KKStrIntMax <<
"]";
747 val =
new char[size];
751 cerr <<
"KKStr::AllocateStrSpace ***ERROR***" << std::endl;
752 cerr <<
"Could not allocate Memory for KKStr, size[" << size <<
"]." << std::endl;
753 throw "KKStr::AllocateStrSpace Allocation of memory failed.";
756 memset (val, 0, size);
768 return sizeof (
char*) + 2 *
sizeof (
kkuint16) + allocatedSize;
773 void KKStr::GrowAllocatedStrSpace (
kkuint32 newAllocatedSize)
775 if (newAllocatedSize < allocatedSize)
778 errMsg <<
"KKStr::GrowAllocatedStrSpace ***ERROR*** newAllocatedSize[" << newAllocatedSize <<
"] is smaller than allocatedSize[" << allocatedSize <<
"]";
779 cerr << std::endl << std::endl << errMsg << std::endl << std::endl;
783 if (newAllocatedSize >= (KKStrIntMax - 5))
787 errMsg <<
"KKStr::GrowAllocatedStrSpace ***ERROR*** NewAllocatedSize[" << newAllocatedSize <<
"] is larger than KKStrIntMax[" << (KKStrIntMax - 5) <<
"]";
791 newAllocatedSize += 5;
794 kkuint32 newAllocatedWithExtraRoomForGrowth = Min ((kkuint32)(len + (len / 4)), (KKStrIntMax - 1));
795 if ((newAllocatedWithExtraRoomForGrowth > newAllocatedSize) && (newAllocatedSize < KKStrIntMax))
796 newAllocatedSize = newAllocatedWithExtraRoomForGrowth;
801 val =
new char[newAllocatedSize];
805 errMsg <<
"KKStr::GrowAllocatedStrSpace ***ERROR*** Allocation of NewAllocatedSize[" << newAllocatedSize <<
"] characters failed.";
806 cerr << endl << errMsg << endl <<endl;
809 memset (val, 0, newAllocatedSize);
810 allocatedSize = (
kkuint16)newAllocatedSize;
814 char* newVal =
new char[newAllocatedSize];
818 errMsg <<
"KKStr::GrowAllocatedStrSpace ***ERROR*** Allocation of NewAllocatedSize[" << newAllocatedSize <<
"] characters failed.";
819 cerr << endl << errMsg << endl << endl;
823 memset (newVal, 0, newAllocatedSize);
824 memcpy (newVal, val, allocatedSize);
827 allocatedSize = (
kkuint16)newAllocatedSize;
846 kkint32 zed = Min (len, s2.len);
848 const char* s1Ptr = val;
849 const char* s2Ptr = s2.val;
851 for (
kkint32 x = 0; x < zed; x++)
853 if ((*s1Ptr) < (*s2Ptr))
856 else if ((*s1Ptr) > (*s2Ptr))
866 else if (len < s2.len)
883 kkuint16 s2Len = (kkuint16)s2.size ();
884 kkint32 zed = Min (len, s2Len);
886 const char* s1Ptr = val;
887 const char* s2Ptr = s2.c_str ();
889 for (
kkint32 x = 0; x < zed; x++)
891 if ((*s1Ptr) < (*s2Ptr))
894 else if ((*s1Ptr) > (*s2Ptr))
904 else if (len < s2Len)
921 kkint32 zed = Min (len, s2.len);
923 const char* s1Ptr = val;
924 const char* s2Ptr = s2.val;
926 for (
kkint32 x = 0; x < zed; x++)
928 if (toupper (*s1Ptr) < toupper (*s2Ptr))
931 else if (toupper (*s1Ptr) > toupper (*s2Ptr))
941 else if (len < s2.len)
967 s2Len = (kkuint32)strlen (s2);
968 kkuint32 zed = Min ((kkuint32)len, s2Len);
970 const char* s1Ptr = val;
971 const char* s2Ptr = s2;
975 if (toupper (*s1Ptr) < toupper (*s2Ptr))
978 else if (toupper (*s1Ptr) > toupper (*s2Ptr))
988 else if (len < s2Len)
1000 kkuint16 s2Len = (kkuint16)s2.size ();
1001 kkint32 zed = Min (len, s2Len);
1003 const char* s1Ptr = val;
1004 const char* s2Ptr = s2.c_str ();
1006 for (
kkint32 x = 0; x < zed; x++)
1008 if (toupper (*s1Ptr) < toupper (*s2Ptr))
1011 else if (toupper (*s1Ptr) > toupper (*s2Ptr))
1021 else if (len < s2Len)
1038 while (values[x] != NULL)
1040 len += (kkuint32)strlen (values[x]);
1046 while (values[x] != NULL)
1062 for (x = 0; x < values.size (); x++)
1063 len += (kkint32)values.size ();
1067 for (x = 0; x < values.size (); x++)
1069 result.Append (values[x]);
1087 for (x = 0; x < values.size (); x++)
1088 len += (kkint32)values.size ();
1092 for (x = 0; x < values.size (); x++)
1094 result.Append (values[x]);
1114 if ((value == NULL) || (*value == 0))
1117 return (
Find (value
, 0
) >= 0);
1127 for (
kkint32 x = 0; x < len; ++x)
1157 if (value.len > len)
1176 kkint32 valueLen = (kkint32)strlen (value);
1230 kkint32 valueLen = (kkint32)strlen (value);
1232 kkint32 startPos = 1 + len - valueLen;
1276 w =
new wchar_t[len + 1];
1277 for (x = 0; x < len; x++)
1278 w[x] = (
wchar_t) val[x];
1285 void KKStr::ValidateLen ()
const 1298 <<
" *** ERROR ***" << std::endl
1300 <<
"'KKStr::ValidateLen' Something has gone very Wrong with the KKStr Library." << std::endl
1302 <<
"len[" << len <<
"]" << std::endl
1303 <<
"strlen (val)[" << strlen (val) <<
"]" << std::endl
1306 <<
"Press Enter to Continue." << std::endl;
1317 <<
"'KKStr::ValidateLen' Something has gone very Wrong with the KKStr Library." << std::endl
1319 <<
"len[" << len <<
"]" << std::endl
1320 <<
"strlen (val)[" << strlen (val) <<
"]" << std::endl
1323 <<
"Press Enter to Continue." << std::endl;
1378 allocatedSize = src.allocatedSize;
1381 src.allocatedSize = 0;
1403 kkuint16 spaceNeeded = src.len + 1;
1404 if ((spaceNeeded > allocatedSize) || (!val))
1409 AllocateStrSpace (spaceNeeded);
1415 memset (val, 0, allocatedSize);
1419 memcpy (val, src.val, src.len);
1453 AllocateStrSpace (10);
1458 kkuint16 newLen = (kkuint16)strlen (src);
1461 if (spaceNeeded > allocatedSize)
1466 AllocateStrSpace (spaceNeeded);
1487 kkuint16 newLen = (kkuint16)strlen (buff);
1491 if (spaceNeeded > allocatedSize)
1496 AllocateStrSpace (spaceNeeded);
1499 memset (val, 0, allocatedSize);
1513 for (x = 0; x < right.size (); x++)
1514 spaceNeeded += right[x].Len ();
1516 if (spaceNeeded > allocatedSize)
1521 AllocateStrSpace (spaceNeeded);
1526 KKStr errMsg =
"KKStr::operator= (const std::vector<KKStr>& right) ***ERROR*** Space for string not allocatd!";
1527 cerr << endl << errMsg << endl <<endl;
1532 kkint32 allocatedSpaceNotUsed = allocatedSize - 1;
1533 for (x = 0; x < right.size (); x++)
1535 kkint32 rightLen = right[x].Len ();
1536 #ifdef USE_SECURE_FUNCS
1537 strncpy_s (ptr, allocatedSpaceNotUsed, right[x].Str (), rightLen);
1539 strncpy (ptr, right[x].Str (), rightLen);
1541 ptr = ptr + rightLen;
1542 allocatedSpaceNotUsed -= rightLen;
1605 return (Compare (right) == 0);
1613 return (Compare (right) != 0);
1659 for (
int x = 0; x < len; ++x)
1660 val[x] = val[x + 1];
1703 AllocateStrSpace (1);
1709 while ((len > 0) && (strchr (whiteSpaceChars, val[x])))
1731 AllocateStrSpace (1);
1754 AllocateStrSpace (1);
1761 while ((strchr (whiteSpaceChars, val[x])) && (val[x] != 0))
1792 kkuint32 buffLen = (kkuint32)strlen (buff);
1796 if (neededSpace > allocatedSize)
1798 if (neededSpace >= KKStrIntMax)
1801 <<
"KKStr::Append ***ERROR*** Size of buffer can not fit into String." << std::endl
1802 <<
" buffLen[" << buffLen <<
"]" << std::endl
1803 <<
" neededSpace[" << neededSpace <<
"]" << std::endl
1807 GrowAllocatedStrSpace (neededSpace);
1811 for (x = 0; x < buffLen; x++)
1835 if (neededSpace > allocatedSize)
1837 if (neededSpace >= KKStrIntMax)
1840 <<
"KKStr::Append ***ERROR*** Size of buffer can not fit into String." << std::endl
1841 <<
" buffLen[" << buffLen <<
"]" << std::endl
1842 <<
" neededSpace[" << neededSpace <<
"]" << std::endl
1846 GrowAllocatedStrSpace (neededSpace);
1850 for (x = 0; x < buffLen; x++)
1866 if (neededSpace > allocatedSize)
1868 if (neededSpace >= KKStrIntMax)
1871 <<
"KKStr::Append ***ERROR*** Size of buffer can not fit into String." << std::endl
1872 <<
" neededSpace[" << neededSpace <<
"]" << std::endl
1876 GrowAllocatedStrSpace (neededSpace);
1896 Append (str.c_str ());
1910 kkint16 bi =
sizeof (buff) - 1;
1913 bool negative =
false;
1925 buff[bi] =
'0' + (
char)digit;
1949 kkint16 bi =
sizeof (buff) - 1;
1957 buff[bi] =
'0' + (
char)digit;
1982 kkuint32 unUsedSpace = allocatedSize - (len + 1);
1983 kkuint32 acceptableWaist = allocatedSize / 5;
1984 if (unUsedSpace > acceptableWaist)
1987 char* newVal =
new char[neededSpace];
1991 errMsg <<
"KKStr::FreeUpUnUsedSpace ***ERROR*** Allocation of NeededSpace[" << neededSpace <<
"] characters failed.";
1992 cerr << endl << errMsg << endl << endl;
1996 memcpy(newVal, val, len);
2000 allocatedSize = (
kkuint16)neededSpace;
2015 return val[len - 1];
2070 for (
kkint32 x = 0; x < len; x++)
2072 if (s1[s1Idx] < s2[s2Idx])
2075 else if (s1[s1Idx] > s2[s2Idx])
2093 if ((!val) || (!(searchStr.val)))
2098 kkint32 lastIdx = len - searchStr.len;
2100 while (idx <= lastIdx)
2130 while ((idx >= 0) && (!found))
2155 if ((!val) || (!s.val) || (sLen <= 0) || (sLen > len))
2163 while ((idx >= 0) && (!found))
2165 if (strncmp (val + idx, sVal, sLen) == 0)
2186 while ((x < len) && (numInstances < n))
2193 if (numInstances < n)
2213 if ((dir ==
'L') || (dir ==
'l'))
2216 else if ((dir ==
'C') || (dir ==
'c'))
2249 KKStr errMsg =
"KKStr::RightPad (kkint32 width, char ch) ***ERROR*** width[" + StrFromInt32 (width
) + "] invalid.";
2250 cerr << endl << errMsg << endl << endl;
2255 KKStr errMsg =
"KKStr::RightPad (kkint32 width, char ch) ***ERROR*** width[" + StrFromInt32 (width
) + "] greater-than KKStr suppotrts.";
2256 cerr << endl << errMsg << endl << endl;
2262 AllocateStrSpace (width + 1);
2269 for (
kkint32 x = len; x < allocatedSize; x++)
2277 if (neededSpace > allocatedSize)
2279 if (neededSpace >= KKStrIntMax)
2282 <<
"KKStr::RightPad ***ERROR*** Size of buffer can not fit into String." << std::endl
2283 <<
" neededSpace[" << neededSpace <<
"]" << std::endl
2287 GrowAllocatedStrSpace (neededSpace);
2314 cerr <<
"KKStr::LeftPad (kkint32 width, char ch) **** ERROR ****" << std::endl;
2315 cerr <<
" width[" << width <<
"] invalid." << std::endl;
2321 if (neededSpace >= KKStrIntMax)
2324 errMsg <<
"KKStr::LeftPad ***ERROR*** Size of buffer can not fit into String; neededSpace[" << neededSpace <<
"].";
2325 cerr << std::endl << errMsg << endl << endl;
2335 if (neededSpace > allocatedSize)
2337 GrowAllocatedStrSpace(neededSpace);
2343 errMsg <<
"KKStr::LeftPad ***ERROR*** val == NULL; couuld not allocate neededSpace[" << neededSpace <<
"].";
2344 cerr << std::endl << errMsg << endl << endl;
2357 while (fromIdx < len)
2359 val[toIdx] = val[fromIdx];
2371 while (fromIdx >= 0)
2373 val[toIdx] = val[fromIdx];
2400 ch = (uchar)getchar ();
2419 ch = (uchar)getchar ();
2429 ch = (uchar)getchar ();
2436 kkuint16 newLen = (kkuint16)strlen (buff);
2440 if (neededSpace > allocatedSize)
2444 AllocateStrSpace (neededSpace);
2472 for (x = 0; x < len; x++)
2473 val[x] = (uchar)toupper (val[x]);
2493 for (x = 0; x < len; x++)
2494 val[x] = (uchar)tolower (val[x]);
2501 maxLen = Max ((kkuint32)0, maxLen);
2512 return KKStrIntMax - 1;
2563 while ((strchr (
" \n\t", *ch)) && (*ch))
2577 digit = (*ch -
'0');
2579 while ((digit >= 0) && (digit <= 9))
2581 value = value * 10 + digit;
2583 digit = (*ch -
'0');
2586 value = value * sign;
2605 while ((strchr (
" \n\t", *ch)) && (*ch))
2610 bool decimalFound =
false;
2619 digit = (*ch -
'0');
2620 while (((digit >= 0) && (digit <= 9)) || (*ch ==
'.'))
2626 decimalFound =
true;
2632 value = value * 10 + digit;
2635 digit = (*ch -
'0');
2638 if (decimalDigits > 2)
2641 while (decimalDigits > 0)
2647 value = value * sign;
2665 while ((strchr (
" \n\t", *ch)) && (*ch))
2670 bool decimalFound =
false;
2679 digit = (*ch -
'0');
2681 while (((digit >= 0) && (digit <= 9)) || (*ch ==
'.'))
2687 decimalFound =
true;
2693 value = value * 10 + digit;
2696 digit = (*ch -
'0');
2699 while (decimalDigits > 0)
2705 value = value * sign;
2717 for (
kkint32 x = 0; x < len; x++)
2794 subStr
.Append (((
char*)&(val[firstChar]))
, subStrLen
);
2810 if (((
kkuint16)firstChar >= len) || (lastChar < firstChar))
2816 if (lastChar >= len)
2828 subStr.val[y] = val[x];
2832 subStr.len = subStrLen;
2852 kkuint16 firstChar = Max ((kkuint16)(len - (kkuint16)tailLen), (kkuint16)0);
2872 if (lastCharPos >= len)
2875 if (lastCharPos < -1)
2879 while (len > newLen)
2892 if ((!val) || (len < 1))
2908 case '\"': result
.Append ("\\\"");
break;
2909 case '\t': result
.Append ("\\t");
break;
2910 case '\n': result
.Append ("\\n");
break;
2911 case '\r': result
.Append ("\\r");
break;
2912 case '\\': result
.Append ("\\\\");
break;
2915 default: result
.Append (val[idx]
);
break;
2931 if ((!val) || (len < 1))
2943 case '<' : result
.Append ("<");
break;
2944 case '>' : result
.Append (">");
break;
2945 case '&' : result
.Append ("&");
break;
2946 case '\"': result
.Append (""");
break;
2947 case '\'': result
.Append ("'");
break;
2948 case '\t': result
.Append ("&tab;");
break;
2949 case '\n': result
.Append ("&nl;");
break;
2950 case '\r': result
.Append ("&cr;");
break;
2951 case '\\': result
.Append ("&bs;");
break;
2952 case 0: result
.Append ("&null;");
break;
2954 default: result
.Append (val[idx]
);
break;
2981 char* tokenStart = val;
2984 while ((*tokenStart != 0) && (strchr (delStr, *tokenStart)))
2987 if (*tokenStart == 0)
2991 AllocateStrSpace (1);
2995 char* tokenNext = tokenStart;
2997 while ((*tokenNext != 0) && (!strchr (delStr, *tokenNext)))
3008 len = (kkuint16)strlen (tokenNext);
3009 memmove (val, tokenNext, len);
3016 memset (val, 0, allocatedSize);
3038 char* tokenStart = val;
3041 while ((*tokenStart != 0) && (*tokenStart ==
' '))
3044 if (*tokenStart == 0)
3048 AllocateStrSpace (1);
3052 char* tokenNext = tokenStart;
3054 while ((*tokenNext != 0) && (!strchr (delStr, *tokenNext)))
3058 char* tokenEnd = tokenNext;
3060 while ((tokenEnd != tokenStart) && ((*tokenEnd ==
' ') || (*tokenEnd ==
'\n') || (*tokenEnd ==
'\r')))
3071 len = (kkuint16)strlen (tokenNext);
3072 memmove (val, tokenNext, len);
3079 memset (val, 0, allocatedSize);
3100 while (startCharPos < len)
3102 if (val[startCharPos] !=
' ')
3107 if (startCharPos >= len)
3110 kkint32 lastCharPos = startCharPos;
3112 while (lastCharPos < len)
3114 if (strchr (delStr, val[lastCharPos]) != NULL)
3118 return SubStrPart (startCharPos, lastCharPos);
3136 return atoi (workStr.Str ());
3148 return (kkuint32)atol (workStr.Str ());
3170 return ((workStr
== "YES") ||
3172 (workStr
== "TRUE") ||
3191 return atof (workStr.Str ());
3209 char returnChar = val[0];
3213 for (
kkuint16 x = 0; x < newLen; x++)
3215 val[x] = val[x + 1];
3232 if ((!val) || (len < 1))
3245 if ((!val) || (len == 0))
3251 kkint32 lastCharPos = len - 1;
3253 if ((val[idx] ==
'"') && (val[len - 1] ==
'"'))
3259 while (idx <= lastCharPos)
3261 if (val[idx] ==
'\\')
3264 if (idx <= lastCharPos)
3283 bool decodeEscapeCharacters
3286 if ((!val) || (len == 0))
3292 bool lookForTerminatingQuote =
false;
3294 if (val[idx] ==
'"')
3296 lookForTerminatingQuote =
true;
3305 AllocateStrSpace (1);
3312 if (lookForTerminatingQuote)
3314 if (val[idx] ==
'"')
3319 if (strchr (delChars, val[idx]))
3329 if (strchr (delChars, val[idx]))
3336 if ((val[idx] ==
'\\') && (decodeEscapeCharacters))
3348 case '0': result
.Append (char (0)
);
break;
3350 default: result
.Append (val[idx]
);
break;
3365 memmove (val, &(val[idx]), len);
3388 if ((i < 0) || ((
kkuint16)i >= len))
3422 if ((i < 0) || ((
kkuint16)i >= len))
3455 static KKStr emptyStr =
"";
3472 result.push_back (field);
3491 result.push_back (field);
3515 result.push_back (field);
3546 double d = atof (val);
3558 float f = (
float)atof (val);
3581 kkint16 i = (kkint16)atoi (val);
3602 #if defined(__GNUC__) 3605 return (kkint64)_atoi64 (val);
3616 long l = atol (val);
3639 return (kkuint32)atol (val);
3647 return (ulong)atol (val);
3655 return (kkuint32)atol (val);
3663 #if defined(__GNUC__) 3664 return (kkuint64)atoll (val);
3666 return (kkuint64)_atoi64 (val);
3684 results->push_back (field.ToInt32 ());
3691 for (kkint32 z = startNum; z <= endNum; ++z)
3692 results->push_back (z);
3708 wa =
new wchar_t[1];
3709 mbstowcs (wa,
"", 1);
3714 size_t wideLen = len + 1;
3715 wa =
new wchar_t[wideLen];
3716 mbstowcs (wa, val, wideLen);
3731 char lastChar = (
char)toupper (latitudeStr.LastChar ());
3732 if (lastChar ==
'N')
3737 else if (lastChar ==
'S')
3751 double degrees = 0.0;
3752 double minutes = 0.0;
3753 double seconds = 0.0;
3755 KKStr degreesStr =
"";
3756 KKStr minutesStr =
"";
3757 KKStr secondsStr =
"";
3779 degreesStr
= latitudeStr;
3806 double latitude = degrees + (minutes / 60.0) + (seconds / 3600.0);
3807 while (latitude > 90.0)
3808 latitude = latitude - 180.0;
3811 latitude = 0.0 - latitude;
3823 char lastChar = (
char)toupper (longitudeStr.LastChar ());
3824 if (lastChar ==
'E')
3829 else if (lastChar ==
'W')
3841 double degrees = 0.0;
3842 double minutes = 0.0;
3843 double seconds = 0.0;
3845 KKStr degreesStr =
"";
3846 KKStr minutesStr =
"";
3847 KKStr secondsStr =
"";
3869 degreesStr
= longitudeStr;
3896 double longitude = degrees + (minutes / 60.0) + (seconds / 3600.0);
3897 while (longitude > 180.0)
3898 longitude = longitude - 360.0;
3900 longitude = 0.0 - longitude;
3910 const char* srchStr,
3914 if ((!src) || (!srchStr))
3917 kkint32 numIter = (srcLen - (startPos + srchStrLen - 1));
3918 const char* startCh = src + startPos;
3921 for (x = 0; x < numIter; ++x, ++startCh)
3923 if (strncmp (startCh, srchStr, srchStrLen) == 0)
3924 return startPos + x;
3947 return SearchStr (val, len, pos, s, (kkint32)strlen (s));
3954 for (
kkint32 x = pos; x < len; x++)
3988 kkint32 resultStrLen = len + (kkint32)strlen (right);
3989 KKStr result
(resultStrLen + 1
);
4000 kkint32 resultStrLen = len + right.len;
4002 KKStr result
(resultStrLen + 1
);
4014 kkint32 resultStrLen = len + (kkint32)strlen (buff);
4015 KKStr result
(resultStrLen + 1
);
4027 kkint32 resultStrLen = len + (kkint32)strlen (buff);
4028 KKStr result
(resultStrLen + 1
);
4041 kkint32 resultStrLen = len + (kkint32)strlen (buff);
4042 KKStr result
(resultStrLen + 1
);
4055 kkint32 resultStrLen = len + (kkint32)strlen (buff);
4056 KKStr result
(resultStrLen + 1
);
4069 kkint32 resultStrLen = len + (kkint32)strlen (buff);
4070 KKStr result
(resultStrLen + 1
);
4083 kkint32 resultStrLen = len + (kkint32)strlen (buff);
4084 KKStr result
(resultStrLen + 1
);
4098 kkint32 resultStrLen = len + (kkint32)strlen (buff);
4099 KKStr result
(resultStrLen + 1
);
4112 kkint32 resultStrLen = len + (kkint32)strlen (buff);
4113 KKStr result
(resultStrLen + 1
);
4133 const char* msg =
"KKStr& operator<<(const char* right) **** ERROR **** right==NULL";
4134 cerr << std::endl << msg << std::endl << std::endl;
4157 allocatedSize = right.allocatedSize;
4161 right.allocatedSize = 0;
4230 if (strchr (buff,
'.') != NULL)
4233 kkint32 buffLen = (kkint32)strlen (buff);
4234 while ((buffLen > 1) && (buff[buffLen - 1] ==
'0') && (buff[buffLen - 2] ==
'0'))
4250 if (strchr (buff,
'.') != NULL)
4253 kkint32 buffLen = (kkint32)strlen (buff);
4254 while ((buffLen > 1) && (buff[buffLen - 1] ==
'0') && (buff[buffLen - 2] ==
'0'))
4268 void Test2 (ostream& x1,
const char* x2)
4302 std::ostream& KKB::operator<< ( std::ostream& os,
4306 Test2 (os, strng.Str ());
4313 std::istream& KKB::operator>> (std::istream& is,
4346 cerr << endl <<
"KKStr::MemCpy ***ERROR*** (dest == NULL)" << endl << endl;
4349 else if (src == NULL)
4351 cerr << endl <<
"KKStr::MemCpy ***ERROR*** (src == NULL)" << endl << endl;
4356 memcpy (dest, src, size);
4366 cerr <<
"KKStr::MemSet ***ERROR*** (dest == NULL)" << endl;
4370 memset (dest, byte, size);
4383 *ch = (
char)toupper (*ch);
4392 const char* searchStr
4395 if ((target == NULL) || (searchStr == NULL))
4398 # ifdef USE_SECURE_FUNCS
4399 char* t = _strdup (target);
4400 char* s = _strdup (searchStr);
4402 char* t = strdup (target);
4403 char* s = strdup (searchStr);
4410 bool f = (strstr (t, s) != NULL);
4448 if (expectedLen > 0)
4449 AllocateStrSpace (expectedLen);
4454 AllocateStrSpace (expectedLen);
4457 while (t && (!cancelFlag))
4501 while (s[x] != NULL)
4503 PushOnBack (
new KKStr (s[x]));
4514 KKStrList::const_iterator idx;
4515 for (idx =
this->begin (); idx !=
this->end (); ++idx)
4516 memoryConsumedEstimated += (*idx)->MemoryConsumedEstimated ();
4517 return memoryConsumedEstimated;
4528 for (idx = 0; ((idx < qSize) && (!found)); idx++)
4529 found = (str == (*IdxToPtr (idx)));
4548 while (t && (!cancelFlag))
4560 PushOnBack (
new KKStr (field));
4584 startTag.AddAtribute (
"Count", (kkint32)size ());
4589 for (idx = begin (); idx != end (); ++idx, ++x)
4592 if (x > 0) o
<< "\t";
4611 KKStr errMsg =
"KKStrList::BinarySearch **** ERROR **** KKStr List is Not Sorted";
4612 cerr << endl << errMsg << endl << endl;
4617 kkint32 high = QueueSize () - 1;
4620 KKStrPtr str = NULL;
4624 mid = (low + high) / 2;
4626 str = IdxToPtr (mid);
4628 if (*str
< searchStr)
4633 else if (*str
> searchStr)
4660 const char* delChars
4665 # ifdef USE_SECURE_FUNCS
4666 char* workStr = _strdup (str.Str ());
4668 char* workStr = strdup (str.Str ());
4671 char* nextChar = workStr;
4676 while ((*nextChar) && (*nextChar ==
' '))
4684 const char* startOfToken = nextChar;
4686 while ((*nextChar) && (strchr (delChars, *nextChar) == NULL))
4697 KKStrPtr token =
new KKStr (startOfToken
);
4700 parms->PushOnBack (token);
4726 else if (s2.val == NULL)
4733 return strcmp (s1.val, s2.val);
4745 reversedOrder = _reversedOrder;
4773 sort (begin (), end (), stringComparison);
4774 if (!_reversedOrder)
4782 KKStrList::const_iterator idx;
4783 for (idx = begin (); idx != end (); idx++)
4784 newList->PushOnBack (
new KKStr (*(*idx)));
4799 size_t len = strlen (str);
4800 size_t idx = len - 1;
4802 while ((idx >= 0) && (!found))
4826 char* bp = buff + 511;
4829 bool negativePrinted =
true;
4833 negativePrinted =
false;
4837 bool printDecimalPoint =
false;
4839 kkint32 numOfDecimalPlaces = 0;
4841 kkint32 maskLen = (kkint32)strlen (mask);
4845 const char* maskPtr = mask + maskLen - 1;
4847 long intPart = (
long)floor (val);
4853 if (decimalPosition >= 0)
4855 numOfDecimalPlaces = maskLen - decimalPosition - 1;
4856 printDecimalPoint =
true;
4857 maskPtr = mask + decimalPosition - 1;
4858 maskLen = decimalPosition;
4861 if (printDecimalPoint)
4863 double power = pow ((
double)10, (
double)numOfDecimalPlaces);
4865 double frac = val - floor (val);
4869 for (x = 0; x < numOfDecimalPlaces; x++)
4871 nextDigit = fracInt % 10;
4872 fracInt = fracInt / 10;
4874 *bp = (
char)(
'0' + nextDigit);
4882 intPart = intPart + fracInt;
4889 char formatChar =
' ';
4890 char lastFormatChar =
' ';
4894 formatChar = (
char)toupper (*maskPtr);
4900 nextDigit = intPart % 10;
4901 intPart = intPart / 10;
4903 *bp =
'0' + (
uchar)nextDigit;
4911 nextDigit = intPart % 10;
4912 intPart = intPart / 10;
4914 *bp =
'0' + (
uchar)nextDigit;
4927 nextDigit = intPart % 10;
4928 intPart = intPart / 10;
4930 *bp =
'0' + (
uchar)nextDigit;
4938 nextDigit = intPart % 10;
4939 intPart = intPart / 10;
4941 *bp =
'0' + (
uchar)nextDigit;
4945 if (!negativePrinted)
4947 negativePrinted =
true;
4962 else if (lastFormatChar !=
'Z')
4977 lastFormatChar = formatChar;
4986 nextDigit = intPart % 10;
4987 intPart = intPart / 10;
4989 *bp =
'0' + (
uchar)nextDigit;
4992 if (!negativePrinted)
5020 char* bp = buff + 127;
5023 bool negativePrinted =
true;
5027 negativePrinted =
false;
5031 kkint32 maskLen = (kkint32)strlen (mask);
5032 const char* maskPtr = mask + maskLen - 1;
5038 char formatChar =
' ';
5039 char lastFormatChar =
' ';
5043 formatChar = (uchar)toupper (*maskPtr);
5049 nextDigit = intPart % 10;
5050 intPart = intPart / 10;
5052 *bp =
'0' + (
uchar)nextDigit;
5060 nextDigit = intPart % 10;
5061 intPart = intPart / 10;
5063 *bp =
'0' + (
uchar)nextDigit;
5076 nextDigit = intPart % 10;
5077 intPart = intPart / 10;
5079 *bp =
'0' + (
uchar)nextDigit;
5087 nextDigit = intPart % 10;
5088 intPart = intPart / 10;
5090 *bp =
'0' + (
uchar)nextDigit;
5094 if (!negativePrinted)
5096 negativePrinted =
true;
5111 else if (lastFormatChar !=
'Z')
5126 lastFormatChar = formatChar;
5135 nextDigit = intPart % 10;
5136 intPart = intPart / 10;
5138 *bp =
'0' + (
uchar)nextDigit;
5141 if (!negativePrinted)
5248 Append (o.str ().c_str ());
5289 while (t && (!cancelFlag))
5326 startTag.AddAtribute (
"Count", (kkint32)size ());
5331 for (idx = begin (); idx != end (); ++idx, ++x)
5333 if (x > 0) o
<< "\t";
5334 XmlContent::WriteXml (idx->QuotedStr (), o);
5346 caseSensitive (_caseSensitive)
5350 KKStrListIndexed::KKStrPtrComp::KKStrPtrComp (
const KKStrPtrComp& comparator):
5351 caseSensitive (comparator.caseSensitive)
5356 bool KKStrListIndexed::KKStrPtrComp::operator() (
const KKStrConstPtr& lhs,
const KKStrConstPtr& rhs)
const 5359 return ((*lhs)
< (*rhs));
5369 memoryConsumedEstimated (0),
5374 strIndex =
new StrIndex (comparator);
5375 memoryConsumedEstimated =
sizeof (*
this);
5384 comparator (_caseSensitive),
5386 memoryConsumedEstimated (0),
5391 strIndex =
new StrIndex (comparator);
5392 memoryConsumedEstimated =
sizeof (*
this);
5398 comparator (list.comparator),
5400 memoryConsumedEstimated (0),
5405 strIndex =
new StrIndex (comparator);
5406 memoryConsumedEstimated =
sizeof (*
this);
5407 IndexIndex::const_iterator idx;
5408 for (idx = list.indexIndex.begin (); idx != list.indexIndex.end (); ++idx)
5411 Add (
new KKStr (*(idx->second)));
5423 indexIndex.clear ();
5433 StrIndex::iterator idx;
5434 for (idx = strIndex->begin (); idx != strIndex->end (); ++idx)
5436 KKStrPtr s = idx->first;
5449 return indexIndex.size ();
5456 return memoryConsumedEstimated;
5464 if (indexIndex.size () != right.indexIndex.size ())
5467 bool caseSensativeComparison = caseSensative || right.caseSensative;
5469 IndexIndex::const_iterator idxLeft = indexIndex.begin ();
5470 IndexIndex::const_iterator idxRight = right.indexIndex.begin ();
5472 while ((idxLeft != indexIndex.end ()) && (idxRight != right.indexIndex.end ()))
5474 if (idxLeft->first != idxRight->first)
5477 if (caseSensativeComparison)
5479 if (idxLeft->second->Compare (*(idxRight->second)) != 0)
5484 if (idxLeft->second->CompareIgnoreCase (*(idxRight->second)) != 0)
5488 if ((*(idxLeft->second)) != (*(idxRight->second)))
5501 return !((*
this)
== right);
5508 StrIndex::iterator idx;
5509 idx = strIndex->find (s);
5510 if (idx != strIndex->end ())
5516 strIndex->insert (StrIndexPair (s, index));
5517 indexIndex.insert (IndexIndexPair (index, s));
5521 memoryConsumedEstimated += 8;
5531 StrIndex::iterator idx;
5532 idx = strIndex->find (&s);
5533 if (idx == strIndex->end ())
5536 KKStrPtr strIndexStr = idx->first;
5539 strIndex->erase (idx);
5541 IndexIndex::iterator idx2;
5542 idx2 = indexIndex.find (index);
5543 if (idx2 != indexIndex.end ())
5544 indexIndex.erase (idx2);
5552 memoryConsumedEstimated -= 8;
5560 StrIndex::const_iterator idx;
5564 idx = strIndex->find (&sNotConst);
5565 if (idx == strIndex->end ())
5574 StrIndex::iterator idx;
5575 idx = strIndex->find (s);
5576 if (idx == strIndex->end ())
5586 IndexIndex::const_iterator idx;
5587 idx = indexIndex.find (x);
5588 if (idx == indexIndex.end ())
5603 comparator.caseSensitive = caseSensative;
5606 while (t && (!cancelFlag))
5633 KKStr s (indexIndex.size () * 20);
5634 IndexIndex::const_iterator idx;
5635 for (idx = indexIndex.begin (); idx != indexIndex.end (); ++idx)
5639 s << *(idx->second);
5658 if (x > 0) o
<< "\t";
__int16 kkint16
16 bit signed integer.
KKStr(kkint32 size)
Creates a KKStr object that pre-allocates space for 'size' characters.
XmlTag(const KKStr &_name, TagTypes _tagType)
KKStr StrFromFloat(float f)
KKStr Wide(kkint32 width, char dir= 'R') const
Pads the string with spaces so that it is exactly 'width' characters long. Can pad either left...
VectorKKStr Split(const char *delStr="\n\r\t, ") const
Breaks up the contents of the string into tokens where the characters in 'delStr' acts as separates e...
void AppendInt32(kkint32 i)
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkuint16 right)
char * STRDUP(const char *src)
char operator[](kkint16 i) const
KKStr & Trim(const char *whiteSpaceChars="\n\r\t ")
KKStr(const std::string &s)
bool EqualIgnoreCase(const char *s2) const
void AddAtribute(const KKStr &attributeName, bool attributeValue)
KKStr StrFormatInt64(kkint64 val, const char *mask)
void Append(const char *buff, kkuint32 buffLen)
kkint32 CompareIgnoreCase(const KKStr &s2) const
Compares with another KKStr, ignoring case.
static bool StrEqualNoCase(const char *s1, const char *s2)
kkint32 MemoryConsumedEstimated() const
KKStr GetNextToken2(const char *delStr="\n\t\r ") const
Retrieves the first token in the string without removing any characters.
kkint32 Find(char c, kkint32 pos=0) const
kkint32 MemCompare(const char *s1, const char *s2, kkint32 s1Idx, kkint32 s2Idx, kkint32 len)
void TrimWhiteSpace(const char *_whiteSpace=" ")
After this call all leading and trailing whitespace will be trimmed from tokens.
wchar_t * ToWchar_t() const
KKStr operator+(kkuint16 right) const
kkint32 CountInstancesOf(char ch) const
KKStr StrFromInt64(kkint64 i)
void ReadXML(XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log)
kkuint32 ExtractTokenUint(const char *delStr)
KKStr & TrimRight(const char *whiteSpaceChars="\n\r\t ")
VectorKKStr Parse(const char *delStr="\n\r\t, ") const
Will break up the contents of the string into tokens where one of the characters in 'delStr' separate...
kkuint32 ToUint32() const
static bool StrEqual(const char *s1, const char *s2)
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
bool operator>=(const KKStr &right) const
const KKStr * KKStrConstPtr
KKStr GetNextToken(const char *delStr="\n\t\r ")
Extract next Token from string, tokens will be separated by delimiter characters. ...
void LeftPad(kkint32 width, uchar ch= ' ')
pads the string with enough 'ch' characters on the left side until the string is as long as 'width' c...
void Lower()
Make all characters in the String into lower case.
StringComparison(bool _reversedOrder)
KKStrConstPtr LookUp(kkuint32 x) const
bool StringInList(KKStr &str)
KKStr ExtractToken(const char *delStr="\n\t\r ")
KKStr DecodeQuotedStr() const
Trees this KKSr instance as a QuotedStr; decodes escape sequences such as '\', '', ' ', '', and '\0' into original characters.
KKStr operator+(kkint32 right) const
kkint32 InstancesOfChar(char ch) const
char ExtractLastChar()
Removes the last character from the string and returns it to the caller.
kkint32 LocateStr(const KKStr &searchStr) const
Returns index of 1st occurrence of 'searchStr' otherwise -1.
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint32 right)
bool operator==(const std::string right) const
KKStr ToTabDelString() const
Strings will be separated by tab() characters and in order of index.
bool operator>(const KKStr &right) const
unsigned __int16 kkuint16
16 bit unsigned integer.
KKStr operator+(float right) const
KKStr & operator=(const char *src)
kkint32 LocateLastOccurrence(const char *str, char ch)
bool EndsWith(const KKStr &value, bool ignoreCase)
kkint32 SPRINTF(char *buff, kkint32 buffSize, char const *formatSpec, double d)
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkuint32 right)
XmlContent * XmlContentPtr
kkint32 LocateLastOccurrence(const KKStr &s) const
Returns index of last occurrence of 's' otherwise -1.
bool operator==(const char *rtStr) const
static void StrCapitalize(char *str)
KKStr StrFromUint32(kkuint32 ui)
static KKStr Concat(const VectorKKStr &values)
kkuint32 MaxLenSupported() const
bool operator==(const KKStrListIndexed &right)
char * STRCOPY(char *dest, kkuint16 destSize, const char *src)
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint32 precision, double d)
kkint32 STRICMP(const char *left, const char *right)
static const char * Str(const char *s)
std::istream &__cdecl operator>>(std::istream &is, KKStr &str)
KKStr operator+(const char *right) const
bool EqualIgnoreCase(const KKStr &s2) const
kkint32 CompareIgnoreCase(const std::string &s2) const
KKStr operator+(kkuint64 right) const
unsigned __int32 kkuint32
bool EndsWith(const char *value, bool ignoreCase)
KKStrPtr ToKKStrPtr() const
bool ValidNum(double &value) const
kkint32 MemoryConsumedEstimated() const
char * STRCAT(char *dest, kkint32 destSize, const char *src)
char operator[](kkuint32 i) const
kkint32 SearchStr(const char *src, kkint32 srcLen, kkint32 startPos, const char *srchStr, kkint32 srchStrLen)
KKStrList(const char *s[])
bool operator()(const KKStr &s1, const KKStr &s2)
bool Contains(const char *value)
KKStr & operator=(KKStr &&src)
bool operator!=(const char *rtStr) const
bool operator<=(const KKStr &right) const
static KKStr Concat(const char **values)
kkuint32 Len() const
Returns the number of characters in the string.
KKStrConstPtr AttributeValueByName(const KKStr &name) const
KKStr StrFromUint16(kkuint16 ui)
static void MemSet(void *dest, kkuint8 byte, kkuint32 size)
void AddAtribute(const KKStr &attributeName, kkint32 attributeValue)
void StrReplace(char **dest, const char *src)
Replaces the contents of *dest with *src.
KKStr(double d, kkint32 precision)
summary>Constructs a KKStr instance form a stl::string instance.
KKStrPtr BinarySearch(const KKStr &searchStr)
KKStrListIndexed(bool _owner, bool _caseSensitive)
char * STRCOPY(char *dest, kkint32 destSize, const char *src)
KKStrParser(const KKStr &_str)
KKStr operator+(const char *left, const KKStr &right)
static void StrDelete(char **str)
KKStr operator+(kkuint32 right) const
kkint32 AttributeValueInt32(const KKStr &attributeName) const
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkuint64 right)
double ExtractTokenDouble(const char *delStr)
void Append(const char *buff)
bool ExtractTokenBool(const char *delStr)
Extract the next token from the string assuming that it is a logical True/False value.
void AppendUInt32(kkuint32 i)
KKStr(const KKStr &str)
Copy Constructor.
kkint32 Compare(const std::string &s2) const
Compares with STL string.
void AddAtribute(const KKStr &attributeName, const KKStr &attributeValue)
KKStr Tail(kkint32 tailLen) const
Returns a string consisting of the 'tailLen' characters from the end of the string.
void TrimLeft(const char *whiteSpaceChars="\n\r\t ")
double ToLongitude() const
Processes string as if a standard longitude; ex: "95:32.2E" = 95.53833.
bool EqualIgnoreCase(const KKStrConstPtr s2) const
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
XmlTag const * XmlTagConstPtr
Manages the reading and writing of objects in a simple XML format. For a class to be supported by Xml...
kkint32 Find(const char *s, kkint32 pos=0) const
KKStr SubStrPart(kkint32 firstChar, kkint32 lastChar) const
returns a SubString consisting of all characters starting at index 'firstChar' and ending at 'lastInd...
static KKStr Spaces(kkint32 c)
Returns a string of spaces 'c' characters long.
static kkint32 CompareStrings(const KKStr &s1, const KKStr &s2)
Compares to Strings and returns -1, 0, or 1, indicating if less than, equal, or greater.
bool operator()(KKStrPtr p1, KKStrPtr p2)
unsigned char uchar
Unsigned character.
KKStr StrFromDouble(double d)
bool StrInStr(const KKStr &searchField) const
Searches for the occurrence of 'searchField' and where in the string. If found will return 'true' oth...
bool EndsWith(const char *value)
kkint32 MemoryConsumedEstimated() const
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of 'std::string' strings.
bool Contains(const KKStr &value)
void Upper()
Converts all characters in string to their Upper case equivalents via 'toupper'.
kkint32 LocateLastOccurrence(char ch) const
Returns index of last occurrence of 'ch' otherwise -1.
LessCaseInsensitiveOperator()
static kkint32 StrCompareIgnoreCase(const char *s1, const char *s2)
std::vector< kkint32 > VectorInt32
Vector of signed 32 bit integers.
void ReadXML(XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log)
static bool StrEqualN(const char *s1, const char *s2, kkuint32 len)
KKStr(const char *src, kkuint32 startPos, kkuint32 endPos)
Constructs a KKStr instance from a sub-string of 'src'.
kkint32 LocateCharacter(char ch) const
Returns index of 1st occurrence of 'ch' otherwise -1.
static const KKStr & EmptyStr()
Static method that returns an Empty String.
kkint32 STRNICMP(const char *left, const char *right, kkint32 len)
unsigned long ulong
Unsigned long.
kkint32 LookUp(KKStrPtr s) const
void ReadXML(XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log)
bool StartsWith(const char *value) const
KKStr ExtractQuotedStr(const char *delChars, bool decodeEscapeCharacters)
void Test2(ostream &x1, const char *x2)
bool operator!=(const KKStr &right) const
char ExtractChar()
Removes the first character from the string and returns it to the caller.
void Sort(bool _reversedOrder)
void WriteXML(const KKStr &varName, std::ostream &o) const
bool EndsWith(const KKStr &value)
bool operator==(const KKStr &right) const
unsigned __int64 kkuint64
void AddString(KKStrPtr str)
kkint32 Find(const char *s, kkint32 pos, kkint32 n) const
bool StartsWith(const char *value, bool ignoreCase) const
KKStr StrFormatInt(kkint32 val, const char *mask)
void WriteXML(const KKStr &varName, std::ostream &o) const
std::ostream &__cdecl operator<<(std::ostream &os, const KKStr &str)
kkint32 ExtractTokenInt(const char *delStr)
KKStr operator+(const KKStr &right) const
kkuint64 ExtractTokenUint64(const char *delStr)
bool StartsWith(const KKStr &value, bool ignoreCase) const
kkint32 Find(const KKStr &str, kkint32 pos=0) const
Will return the position where the 1st instance of 'str' after 'pos' occurs or -1 if not found...
wchar_t * StrWide() const
KKStr operator+(kkint16 right) const
static bool StrEqualNoCaseN(const char *s1, const char *s2, kkuint32 len)
const char * Str() const
Returns a pointer to a ascii string.
KKStr MaxLen(kkuint32 maxLen) const
void Append(const std::string &str)
KKStr StrFormatDouble(double val, const char *mask)
void RightPad(kkint32 width, char ch= ' ')
Pads string on the right side with specified character so that the string will be of specified length...
kkint32 LocateNthOccurrence(char ch, kkint32 x) const
KKStr & operator=(kkint32 right)
bool operator!=(const std::string right) const
double ToLatitude() const
Processes string as if a standard latitude; ex: "15:32.2S" = -15.53833.
KKStr operator+(kkint64 right) const
static void WriteXml(const KKStr &s, std::ostream &o)
static const char * StrChr(const char *str, int ch)
void Append(const KKStr &str)
KKException(const char *_exceptionStr)
char operator[](kkint32 i) const
void WriteXML(std::ostream &o)
static void MemCpy(void *dest, void *src, kkuint32 size)
KKStr operator+(double right) const
KKStr & operator=(const KKStr &src)
bool operator==(KKStrConstPtr right) const
KKStrPtr const Content() const
Used for logging messages.
kkint32 LookUp(const KKStr &s) const
bool operator<(const KKStr &right) const
bool StartsWith(const KKStr &value) const
KKStr StrFromInt16(kkint16 i)
float ToPercentage() const
KKStrListIndexed(const KKStrListIndexed &list)
virtual TokenTypes TokenType()=0
Class that manages the extraction of tokens from a String without being destructive to the original s...
kkint32 Compare(const KKStr &s2) const
void WriteXML(const KKStr &varName, std::ostream &o) const
static KKStrListPtr ParseDelimitedString(const KKStr &str, const char *delChars=",\t\n\r")
virtual XmlTokenPtr GetNextToken(VolConstBool &cancelFlag, RunLog &log)
void ReadXML(XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log)
bool operator!=(const KKStrListIndexed &right)
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint64 right)
VectorKKStr Split(char del) const
Splits the string up into tokens using 'del' as the separator returning them in a vector...
KKException(const KKStr &_exceptionStr)
bool ToBool() const
Returns the bool equivalent of the string, ex 'Yes' = true, 'No' = false, 'True' = true...
void LopOff(kkint32 lastCharPos)
Trims off all characters after the 'lastCharPos' index; to make an empty string you would have to spe...
bool ValidInt(kkint32 &value)
VectorInt32 * ToVectorInt32() const
void WriteXML(const KKStr &varName, std::ostream &o) const
kkuint64 ToUint64() const
KKStr StrFromUint64(kkuint64 ui)
KKStr SubStrPart(kkint32 firstChar) const
returns a SubString consisting of all characters starting at index 'firstChar' until the end of the s...
kkint32 CompareIgnoreCase(const char *s2) const
summary>Compares to Strings and returns -1, 0, or 1, indicating if less than, equal, or greater.
char operator[](kkuint16 i) const
KKStrParser(const char *_str)
bool ValidMoney(float &value) const
bool operator!=(KKStrConstPtr right) const
KKStr QuotedStr() const
Returns a quoted version of string where special characters Line-Feed, Carriage Return, and Tab, are encoded as escape sequences.
VectorKKStr(const VectorKKStr &v)
KKStr StrFromInt32(kkint32 i)
KKStr operator+(const char left, const KKStr &right)
volatile const bool VolConstBool
static bool StrInStr(const char *target, const char *searchStr)
KKStrListPtr DuplicateListAndContents() const