KSquare Utilities
KKStr.cpp File Reference
#include "FirstIncludes.h"
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <memory>
#include <sstream>
#include <string>
#include <vector>
#include <string.h>
#include "MemoryDebug.h"
#include "KKQueue.h"
#include "KKStr.h"
#include "KKException.h"
#include "KKStrParser.h"
#include "RunLog.h"
#include "XmlStream.h"

Go to the source code of this file.

Classes

class  KKB::KKStrList::StringComparison
 

Functions

kkint32 LocateLastOccurrence (const char *str, char ch)
 
kkint32 MemCompare (const char *s1, const char *s2, kkint32 s1Idx, kkint32 s2Idx, kkint32 len)
 
kkint32 SearchStr (const char *src, kkint32 srcLen, kkint32 startPos, const char *srchStr, kkint32 srchStrLen)
 
void Test2 (ostream &x1, const char *x2)
 

Function Documentation

kkint32 LocateLastOccurrence ( const char *  str,
char  ch 
)

Definition at line 4791 of file KKStr.cpp.

Referenced by KKB::StrFormatDouble().

4794 {
4795  if (!str)
4796  return -1;
4797 
4798  bool found = false;
4799  size_t len = strlen (str);
4800  size_t idx = len - 1;
4801 
4802  while ((idx >= 0) && (!found))
4803  {
4804  if (str[idx] == ch)
4805  found = true;
4806  else
4807  idx--;
4808  }
4809 
4810  if (found)
4811  return (kkint32)idx;
4812  else
4813  return -1;
4814 
4815 } /* LocateLastOccurrence */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 MemCompare ( const char *  s1,
const char *  s2,
kkint32  s1Idx,
kkint32  s2Idx,
kkint32  len 
)

Definition at line 2063 of file KKStr.cpp.

Referenced by KKB::KKStr::LocateStr().

2069 {
2070  for (kkint32 x = 0; x < len; x++)
2071  {
2072  if (s1[s1Idx] < s2[s2Idx])
2073  return -1;
2074 
2075  else if (s1[s1Idx] > s2[s2Idx])
2076  return 1;
2077 
2078  s1Idx++;
2079  s2Idx++;
2080  }
2081 
2082  return 0;
2083 } /* MemCompare */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 SearchStr ( const char *  src,
kkint32  srcLen,
kkint32  startPos,
const char *  srchStr,
kkint32  srchStrLen 
)

Definition at line 3907 of file KKStr.cpp.

Referenced by KKB::KKStr::Find().

3913 {
3914  if ((!src) || (!srchStr))
3915  return -1;
3916 
3917  kkint32 numIter = (srcLen - (startPos + srchStrLen - 1));
3918  const char* startCh = src + startPos;
3919 
3920  kkint32 x;
3921  for (x = 0; x < numIter; ++x, ++startCh)
3922  {
3923  if (strncmp (startCh, srchStr, srchStrLen) == 0)
3924  return startPos + x;
3925  }
3926  return -1;
3927 }
__int32 kkint32
Definition: KKBaseTypes.h:88
void Test2 ( ostream &  x1,
const char *  x2 
)

Definition at line 4268 of file KKStr.cpp.

References KKB::operator<<().

4269 {
4270  x1 << x2;
4271 }