KSquare Utilities
KKB::KKStr Class Reference

#include <KKStr.h>

Classes

class  LessCaseInsensitiveOperator
 

Public Types

typedef const KKStrKKStrConstPtr
 
typedef KKStrKKStrPtr
 

Public Member Functions

 KKStr ()
 
 KKStr (const char *str)
 
 KKStr (const KKStr &str)
 Copy Constructor. More...
 
 KKStr (KKStr &&str)
 
 KKStr (kkint32 size)
 Creates a KKStr object that pre-allocates space for 'size' characters. More...
 
 KKStr (double d, kkint32 precision)
 summary>Constructs a KKStr instance form a stl::string instance. More...
 
 KKStr (const std::string &s)
 
 KKStr (const char *src, kkuint32 startPos, kkuint32 endPos)
 Constructs a KKStr instance from a sub-string of 'src'. More...
 
 ~KKStr ()
 
void Append (const char *buff)
 
void Append (const char *buff, kkuint32 buffLen)
 
void Append (char ch)
 
void Append (const KKStr &str)
 
void Append (const std::string &str)
 
void AppendInt32 (kkint32 i)
 
void AppendUInt32 (kkuint32 i)
 
const char * c_str ()
 
bool CharInStr (char ch)
 
void ChopFirstChar ()
 
void ChopLastChar ()
 
kkint32 Compare (const KKStr &s2) const
 
kkint32 Compare (const std::string &s2) const
 Compares with STL string. More...
 
kkint32 CompareIgnoreCase (const KKStr &s2) const
 Compares with another KKStr, ignoring case. More...
 
kkint32 CompareIgnoreCase (const std::string &s2) const
 
kkint32 CompareIgnoreCase (const char *s2) const
 summary>Compares to Strings and returns -1, 0, or 1, indicating if less than, equal, or greater. More...
 
kkint32 CompareTo (const KKStr &s2) const
 
bool Contains (const KKStr &value)
 
bool Contains (const char *value)
 
kkint32 CountInstancesOf (char ch) const
 
const char * data ()
 
KKStr DecodeQuotedStr () const
 Trees this KKSr instance as a QuotedStr; decodes escape sequences such as '\', '', '
', '', and '\0' into original characters. More...
 
bool Empty () const
 
bool EndsWith (const KKStr &value)
 
bool EndsWith (const char *value)
 
bool EndsWith (const KKStr &value, bool ignoreCase)
 
bool EndsWith (const char *value, bool ignoreCase)
 
char EnterStr ()
 
bool EqualIgnoreCase (const KKStr &s2) const
 
bool EqualIgnoreCase (const KKStrConstPtr s2) const
 
bool EqualIgnoreCase (const char *s2) const
 
char ExtractChar ()
 Removes the first character from the string and returns it to the caller. More...
 
char ExtractLastChar ()
 Removes the last character from the string and returns it to the caller. More...
 
KKStr ExtractQuotedStr (const char *delChars, bool decodeEscapeCharacters)
 
KKStr ExtractToken (const char *delStr="\n\t\r ")
 
KKStr ExtractToken2 (const char *delStr="\n\t\r ")
 Extract first Token from the string. More...
 
bool ExtractTokenBool (const char *delStr)
 Extract the next token from the string assuming that it is a logical True/False value. More...
 
double ExtractTokenDouble (const char *delStr)
 
kkint32 ExtractTokenInt (const char *delStr)
 
kkuint32 ExtractTokenUint (const char *delStr)
 
kkuint64 ExtractTokenUint64 (const char *delStr)
 
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. More...
 
kkint32 Find (const char *s, kkint32 pos, kkint32 n) const
 
kkint32 Find (const char *s, kkint32 pos=0) const
 
kkint32 Find (char c, kkint32 pos=0) const
 
char FirstChar () const
 
void FreeUpUnUsedSpace ()
 
KKStr GetNextToken2 (const char *delStr="\n\t\r ") const
 Retrieves the first token in the string without removing any characters. More...
 
kkint32 InstancesOfChar (char ch) const
 
char LastChar () const
 
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' characters. More...
 
kkuint32 Len () const
 Returns the number of characters in the string. More...
 
kkint32 LocateCharacter (char ch) const
 Returns index of 1st occurrence of 'ch' otherwise -1. More...
 
kkint32 LocateLastOccurrence (char ch) const
 Returns index of last occurrence of 'ch' otherwise -1. More...
 
kkint32 LocateLastOccurrence (const KKStr &s) const
 Returns index of last occurrence of 's' otherwise -1. More...
 
kkint32 LocateNthOccurrence (char ch, kkint32 x) const
 
kkint32 LocateStr (const KKStr &searchStr) const
 Returns index of 1st occurrence of 'searchStr' otherwise -1. More...
 
void LopOff (kkint32 lastCharPos)
 Trims off all characters after the 'lastCharPos' index; to make an empty string you would have to specify -1. More...
 
void Lower ()
 Make all characters in the String into lower case. More...
 
KKStr MaxLen (kkuint32 maxLen) const
 
kkuint32 MaxLenSupported () const
 
kkint32 MemoryConsumedEstimated () const
 
bool operator!= (const KKStr &right) const
 
bool operator!= (KKStrConstPtr right) const
 
bool operator!= (const char *rtStr) const
 
bool operator!= (const std::string right) const
 
KKStr operator+ (const char *right) const
 
KKStr operator+ (const KKStr &right) const
 
KKStr operator+ (kkint16 right) const
 
KKStr operator+ (kkuint16 right) const
 
KKStr operator+ (kkint32 right) const
 
KKStr operator+ (kkuint32 right) const
 
KKStr operator+ (kkint64 right) const
 
KKStr operator+ (kkuint64 right) const
 
KKStr operator+ (float right) const
 
KKStr operator+ (double right) const
 
KKStroperator+= (const char *right)
 
KKStroperator+= (const KKStr &right)
 
KKStroperator+= (kkint16 right)
 
KKStroperator+= (kkuint16 right)
 
KKStroperator+= (kkint32 right)
 
KKStroperator+= (kkuint32 right)
 
KKStroperator+= (kkint64 right)
 
KKStroperator+= (kkuint64 right)
 
KKStroperator+= (float right)
 
KKStroperator+= (double right)
 
bool operator< (const KKStr &right) const
 
KKStroperator<< (const char *right)
 
KKStroperator<< (const KKStr &right)
 
KKStroperator<< (KKStr &&right)
 
KKStroperator<< (char right)
 
KKStroperator<< (kkint16 right)
 
KKStroperator<< (kkuint16 right)
 
KKStroperator<< (kkint32 right)
 
KKStroperator<< (kkuint32 right)
 
KKStroperator<< (kkint64 right)
 
KKStroperator<< (kkuint64 right)
 
KKStroperator<< (float right)
 
KKStroperator<< (double right)
 
KKStroperator<< (std::ostream &(*mf)(std::ostream &))
 
bool operator<= (const KKStr &right) const
 
KKStroperator= (const KKStr &src)
 
KKStroperator= (KKStr &&src)
 
KKStroperator= (const char *src)
 
KKStroperator= (kkint32 right)
 
KKStroperator= (const std::vector< KKStr > &right)
 
bool operator== (const KKStr &right) const
 
bool operator== (KKStrConstPtr right) const
 
bool operator== (const char *rtStr) const
 
bool operator== (const std::string right) const
 
bool operator> (const KKStr &right) const
 
bool operator>= (const KKStr &right) const
 
char operator[] (kkint16 i) const
 
char operator[] (kkuint16 i) const
 
char operator[] (kkint32 i) const
 
char operator[] (kkuint32 i) const
 
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' separates each token. More...
 
KKStr QuotedStr () const
 Returns a quoted version of string where special characters Line-Feed, Carriage Return, and Tab, are encoded as escape sequences. More...
 
void ReadXML (XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log)
 
void RightPad (kkint32 width, char ch= ' ')
 Pads string on the right side with specified character so that the string will be of specified length. More...
 
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 each token. More...
 
VectorKKStr Split (char del) const
 Splits the string up into tokens using 'del' as the separator returning them in a vector. More...
 
bool StartsWith (const KKStr &value) const
 
bool StartsWith (const char *value) const
 
bool StartsWith (const KKStr &value, bool ignoreCase) const
 
bool StartsWith (const char *value, bool ignoreCase) const
 
const char * Str () const
 Returns a pointer to a ascii string. More...
 
bool StrInStr (const KKStr &searchField) const
 Searches for the occurrence of 'searchField' and where in the string. If found will return 'true' otherwise 'false'. More...
 
void StrReplace (char **dest, const char *src)
 Replaces the contents of *dest with *src. More...
 
wchar_t * StrWide () const
 
KKStr SubStrPart (kkint32 firstChar) const
 returns a SubString consisting of all characters starting at index 'firstChar' until the end of the string. More...
 
KKStr SubStrPart (kkint32 firstChar, kkint32 lastChar) const
 returns a SubString consisting of all characters starting at index 'firstChar' and ending at 'lastIndex' More...
 
KKStr Tail (kkint32 tailLen) const
 Returns a string consisting of the 'tailLen' characters from the end of the string. More...
 
bool ToBool () const
 Returns the bool equivalent of the string, ex 'Yes' = true, 'No' = false, 'True' = true, etc. More...
 
double ToDouble () const
 
float ToFloat () const
 
kkint32 ToInt () const
 
kkint16 ToInt16 () const
 
kkint32 ToInt32 () const
 
kkint64 ToInt64 () const
 
KKStrPtr ToKKStrPtr () const
 
double ToLatitude () const
 Processes string as if a standard latitude; ex: "15:32.2S" = -15.53833. More...
 
long ToLong () const
 
double ToLongitude () const
 Processes string as if a standard longitude; ex: "95:32.2E" = 95.53833. More...
 
KKStr ToLower () const
 
float ToPercentage () const
 
KKStr ToQuotedStr () const
 
kkuint32 ToUint () const
 
kkuint32 ToUint32 () const
 
kkuint64 ToUint64 () const
 
ulong ToUlong () const
 
KKStr ToUpper () const
 
VectorInt32ToVectorInt32 () const
 
wchar_t * ToWchar_t () const
 
KKStr ToXmlStr () const
 
KKStrTrim (const char *whiteSpaceChars="\n\r\t ")
 
void TrimLeft (const char *whiteSpaceChars="\n\r\t ")
 
KKStrTrimRight (const char *whiteSpaceChars="\n\r\t ")
 
void TrimRightChar ()
 
void Upper ()
 Converts all characters in string to their Upper case equivalents via 'toupper'. More...
 
bool ValidInt (kkint32 &value)
 
bool ValidMoney (float &value) const
 
bool ValidNum (double &value) const
 
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, right, or center as specified by 'dir'. If KKStr Already greater than 'width' will truncate new string. /summary> param name='width'> Width of KKStr; will pad KKStr with spaces until it is width long. param name='dir'>Direction to pad from 'L' - Pad on the left side, 'R' - Pad on the right side, and 'C' - Pad on left and Right so that text is centered. More...
 
void WriteXML (const KKStr &varName, std::ostream &o) const
 

Static Public Member Functions

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. More...
 
static KKStr Concat (const char **values)
 
static KKStr Concat (const VectorKKStr &values)
 
static KKStr Concat (const std::vector< std::string > &values)
 Concatenates the list of 'std::string' strings. More...
 
static const KKStrEmptyStr ()
 Static method that returns an Empty String. More...
 
static void MemCpy (void *dest, void *src, kkuint32 size)
 
static void MemSet (void *dest, kkuint8 byte, kkuint32 size)
 
static KKStr Spaces (kkint32 c)
 Returns a string of spaces 'c' characters long. More...
 
static const char * Str (const char *s)
 
static void StrCapitalize (char *str)
 
static const char * StrChr (const char *str, int ch)
 
static kkint32 StrCompareIgnoreCase (const char *s1, const char *s2)
 
static void StrDelete (char **str)
 
static bool StrEqual (const char *s1, const char *s2)
 
static bool StrEqualN (const char *s1, const char *s2, kkuint32 len)
 
static bool StrEqualNoCase (const char *s1, const char *s2)
 
static bool StrEqualNoCaseN (const char *s1, const char *s2, kkuint32 len)
 
static bool StrInStr (const char *target, const char *searchStr)
 

Detailed Description

Definition at line 80 of file KKStr.h.

Member Typedef Documentation

Definition at line 84 of file KKStr.h.

Definition at line 83 of file KKStr.h.

Constructor & Destructor Documentation

KKStr::~KKStr ( )

Definition at line 833 of file KKStr.cpp.

834 {
835  if (val)
836  {
837  delete [] val;
838  val = NULL;
839  }
840 }
KKStr::KKStr ( const char *  str)

Definition at line 537 of file KKStr.cpp.

References KKB::STRCOPY().

Referenced by KKMLL::TrainingConfiguration2::Factory::Factory(), KKB::KKException::KKException(), KKMLL::FeatureFileIO::LoadInSubDirectoryTree(), KKB::operator+(), KKB::osGetCurrentDirectory(), KKB::osGetFileNamePartOfFile(), KKB::osGetPathPartOfFile(), KKB::KKStrList::ParseDelimitedString(), KKMLL::ConfusionMatrix2::PrintConfusionMatrix(), KKMLL::ConfusionMatrix2::PrintConfusionMatrixHTML(), KKMLL::ConfusionMatrix2::PrintConfusionMatrixLatexTable(), KKMLL::ConfusionMatrix2::PrintConfusionMatrixNarrow(), KKMLL::ConfusionMatrix2::PrintConfusionMatrixTabDelimited(), KKB::StrFormatDouble(), KKB::StrFormatInt64(), KKB::StrFromDouble(), KKB::StrFromFloat(), KKB::StrFromInt16(), KKB::StrFromInt32(), KKB::StrFromInt64(), KKB::StrFromUint16(), KKB::StrFromUint32(), KKB::StrFromUint64(), KKMLL::TrainingConfiguration2::TrainingConfiguration2(), KKMLL::TrainingProcess2::TrainingProcess2(), and Wide().

537  :
538  val (NULL)
539 {
540  if (!str)
541  {
542  AllocateStrSpace (1);
543  val[0] = 0;
544  len = 0;
545  return;
546  }
547 
548  kkuint32 newLen = (kkuint32)strlen (str);
549  AllocateStrSpace (newLen + 1);
550 
551  STRCOPY (val, (kkuint16)allocatedSize, str);
552 
553  len = (kkuint16)newLen;
554 }
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
char * STRCOPY(char *dest, kkint32 destSize, const char *src)
Definition: KKStr.cpp:46
KKStr::KKStr ( const KKStr str)

Copy Constructor.

Definition at line 561 of file KKStr.cpp.

References Concat(), KKB::KKException::KKException(), operator+(), KKB::operator+(), and KKB::StrFromUint16().

Referenced by KKMLL::Attribute::AddANominalValue(), KKB::Application::Application(), KKMLL::Attribute::Attribute(), KKB::BmpImage::BmpImage(), KKB::Chart::Chart(), KKMLL::ClassificationBiasMatrix::ClassificationBiasMatrix(), KKMLL::SizeDistribution::ClassTotals::ClassTotals(), KKB::CmdLineExpander::CmdLineExpander(), KKB::Configuration::Configuration(), KKB::Configuration::ConfSection::ConfSection(), KKMLL::BinaryClassParms::CreateFromTabDelStr(), KKMLL::TrainingConfiguration2::Factory::Factory(), KKMLL::FactoryFVProducer::FactoryFVProducer(), KKMLL::FeatureFileIO::FeatureFileIO(), KKMLL::FeatureVector::FeatureVector(), KKMLL::FeatureVectorList::FeatureVectorList(), KKMLL::FeatureVectorProducer::FeatureVectorProducer(), KKB::PointList::FromDelStr(), KKMLL::FeatureFileIOC45::GetFileDesc(), KKB::HTMLReport::HTMLReport(), KKB::ImageDirTree::ImageDirTree(), KKB::KKException::KKException(), KKJobManagment::KKJobManager::KKJobManager(), KKB::KKObserver::KKObserver(), KKB::KKThread::KKThread(), KKMLL::FeatureFileIODstWeb::LoadFile(), KKB::KKStrListIndexed::LookUp(), KKMLL::AttributeList::LookUpByName(), KKMLL::Model::Model(), KKMLL::ModelParam::ModelParam(), KKMLL::ModelParamDual::ModelParamDual(), KKB::MsgQueue::MsgQueue(), KKMLL::Orderings::Orderings(), KKB::osAddSlash(), KKB::osCopyFileBetweenDirectories(), KKB::osLookForFile(), KKB::osMakeFullFileName(), KKB::osMoveFileBetweenDirectories(), KKB::osReadRestOfLine2(), KKB::osRemoveExtension(), KKB::osSubstituteInEnvironmentVariables(), Parse(), KKMLL::ModelParam::ParseCmdLine(), KKMLL::ModelParamOldSVM::ParseCmdLine(), KKMLL::SVMparam::ParseCmdLineParameter(), KKMLL::ClassAssignments::ParseToString(), KKMLL::SizeDistribution::ClassTotals::PrintFormatedLine(), KKMLL::ProbNamePair::ProbNamePair(), KKB::Raster::Raster(), KKB::RasterBuffer::RasterBuffer(), KKB::KKStrListIndexed::ReadXML(), KKMLL::GrayScaleImagesFVList::RecalcFeatureValuesFromImagesInDirTree(), KKLSC::ScannerFile::ScannerFile(), KKLSC::ScannerFileEntry::ScannerFileEntry(), KKB::Chart::Series::Series(), KKB::Configuration::Setting::Setting(), KKB::Configuration::SettingValueToStr(), Split(), KKJobManagment::KKJobManager::StatusFileProcessLine(), KKLSC::Variables::SubstituteInEnvironmentVariables(), KKMLL::SVMparam::SVMparam(), KKB::TokenBufferStr::TokenBufferStr(), KKB::TokenBufferStream::TokenBufferStream(), ToKKStrPtr(), ToLatitude(), ToLongitude(), ToLower(), KKMLL::MLClass::ToString(), ToUpper(), KKMLL::TrainingClass::TrainingClass(), KKMLL::TrainingClassList::TrainingClassList(), KKMLL::TrainingConfiguration2::TrainingConfiguration2(), KKB::Chart::XLabel::XLabel(), KKB::XmlAttribute::XmlAttribute(), KKB::XmlFactory::XmlFactory(), KKB::XmlFactoryManager::XmlFactoryManager(), KKB::XmlStream::XmlStream(), and KKB::XmlTag::XmlTag().

561  :
562  val (NULL)
563 {
564  if (!str.val)
565  {
566  AllocateStrSpace (1);
567  len = 0;
568  return;
569  }
570 
571  if (str.val[str.len] != 0)
572  {
573  std::cerr << std::endl
574  << "KKStr::KKStr ***ERROR*** Missing terminating NULL" << std::endl
575  << std::endl;
576  }
577 
578  kkuint16 neededSpace = str.len + 1;
579  if (neededSpace > str.allocatedSize)
580  {
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;
583  throw new KKException (errMsg);
584  }
585 
586  AllocateStrSpace (str.allocatedSize);
587  if (!val) {
588  std::cerr << std::endl << "KKStr::KKStr ***ERROR*** Allocation Failed." << std::endl << std::endl;
589  throw KKException("KKStr::KKStr ***ERROR*** Allocation Failed.");
590  }
591 
592  std::memcpy (val, str.val, str.len);
593  len = str.len;
594 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
KKStr StrFromUint16(kkuint16 ui)
Definition: KKStr.cpp:5164
KKStr::KKStr ( KKStr &&  str)

Move Constructor

Definition at line 599 of file KKStr.cpp.

599  :
600  allocatedSize (str.allocatedSize),
601  len (str.len),
602  val (str.val)
603 {
604  str.allocatedSize = 0;
605  str.len = 0;
606  str.val = NULL;
607 }
KKStr::KKStr ( kkint32  size)

Creates a KKStr object that pre-allocates space for 'size' characters.

Creates a KKStr object that has 'size' characters preallocated; and set to empty string.

summary> Initializes the string with a displayable version of d with precision decimal points.

Definition at line 655 of file KKStr.cpp.

Referenced by KKMLL::FileDesc::AddANominalValue(), KKB::XmlTag::AddAtribute(), KKMLL::FeatureVector::AddFeatureData(), KKB::KKThread::AddMsg(), KKB::BitString::BitString(), Concat(), KKMLL::FeatureEncoder::CreateEncodedFileDesc(), DecodeQuotedStr(), KKB::Matrix::DeterminantSlow(), KKMLL::FeatureEncoder::EncodeAExample(), ExtractQuotedStr(), KKMLL::FeatureFileIO::FileFormatsReadAndWriteOptionsStr(), KKMLL::FeatureFileIO::FileFormatsReadOptionsStr(), KKMLL::FeatureFileIO::FileFormatsWrittenOptionsStr(), KKMLL::CrossValidationVoting::FoldAccuracysToStr(), KKMLL::CrossValidation::FoldAccuracysToStr(), KKMLL::CrossValidationVoting::FoldStr(), FreeUpUnUsedSpace(), KKMLL::FeatureFileIODstWeb::GetFileDesc(), KKMLL::FeatureFileIOC45::GetFileDesc(), KKB::KKStrParser::GetNextToken(), KKB::KKStrParser::GetRestOfLine(), KKB::KKStrParser::GetRestOfStr(), KKLSC::ScannerFile::GuessFormatOfFile(), KKB::BitString::HexStr(), KKB::Raster::Histogram(), KKB::Matrix::Inverse(), LeftPad(), KKB::BitString::ListOfSetBits16(), KKMLL::FeatureFileIOUCI::LoadFile(), KKB::Matrix::Matrix(), KKB::DateType::MM_DD_YY(), KKB::DateType::MMM_DD_YYYY(), KKB::Matrix::operator*(), KKB::Matrix::operator+(), operator+(), KKB::operator+(), KKB::Matrix::operator+=(), KKB::Matrix::operator-(), KKB::operator<<(), KKB::RunLog::operator<<(), operator<<(), KKB::Matrix::operator[](), KKMLL::FeatureNumList::operator[](), KKB::osReadNextLine(), KKB::osReadNextQuotedStr(), KKB::osReadRestOfLine(), KKB::KKStrParser::PeekNextToken(), KKMLL::ConfusionMatrix2::PrintAccuracyByProbByClassHTML(), KKMLL::BinaryClassParmsList::PushOnBack(), KKMLL::FeatureVectorList::PushOnBack(), KKMLL::BinaryClassParmsList::PushOnFront(), KKMLL::FeatureVectorList::PushOnFront(), QuotedStr(), KKLSC::ScannerFile::ReadHeader(), KKMLL::ModelKnn::ReadXML(), KKMLL::ModelUsfCasCor::ReadXML(), KKMLL::ModelSvmBase::ReadXML(), KKMLL::ModelDual::ReadXML(), KKMLL::ModelOldSVM::ReadXML(), KKMLL::Model::ReadXMLModelToken(), KKMLL::ModelDual::ReconcilePredictions(), KKB::XmlFactoryManager::RegisterFactory(), KKMLL::FeatureVector::ResetNumOfFeatures(), KKB::SaveImagePGM(), KKB::SaveImagePNG(), KKB::SaveImagePPM(), StripOutInvalidLatexCaracters(), KKB::KKStrParser::SubStrPart(), SubStrPart(), KKMLL::ModelParamOldSVM::SvmParamToString(), KKMLL::SVMparam::SvmParamToString(), KKMLL::ModelParamSvmBase::ToCmdLineStr(), KKMLL::ModelParamUsfCasCor::ToCmdLineStr(), KKMLL::ModelParamDual::ToCmdLineStr(), SVM233::svm_parameter::ToCmdLineStr(), KKMLL::ModelParam::ToCmdLineStr(), SVM289_BFS::svm_parameter::ToCmdLineStr(), SVM289_MFS::svm_parameter::ToCmdLineStr(), KKMLL::ModelParamOldSVM::ToCmdLineStr(), KKMLL::MLClassIndexList::ToCommaDelString(), KKJobManagment::KKJob::ToStatusStr(), KKJobManagment::KKJobManager::ToStatusStr(), KKMLL::FeatureNumList::ToString(), KKMLL::SVMparam::ToString(), KKLSC::ScannerFileEntry::ToTabDelStr(), KKLSC::StartStopPoint::ToTabDelStr(), SVM233::svm_parameter::ToTabDelStr(), SVM289_BFS::svm_parameter::ToTabDelStr(), SVM289_MFS::svm_parameter::ToTabDelStr(), ToXmlStr(), KKLSC::ScannerFile::WriteHeader(), KKLSC::ScannerFile::WriteInstrumentDataWord(), SVM289_MFS::Svm_Model::WriteXML(), KKMLL::SVMModel::WriteXML(), KKB::DateType::YY_MM_DD(), KKB::DateType::YYYY_MM_DD(), KKB::DateType::YYYY_MMM_DD(), and KKB::DateType::YYYYMMDD().

655  :
656  val (NULL)
657 {
658  if (size <= 0)
659  size = 1;
660 
661  else if ((kkuint32)size >= KKStrIntMax)
662  {
663  cerr << std::endl
664  << "KKStr::KKStr ***WARNNING*** Trying to allocate Size[" << size << "] which is >= KKStrIntMax[" << KKStrIntMax << "]." << std::endl
665  << std::endl;
666  size = KKStrIntMax - 1;
667  }
668 
669  AllocateStrSpace (size);
670  val[0] = 0;
671  len = 0;
672 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
KKStr::KKStr ( double  d,
kkint32  precision 
)

summary>Constructs a KKStr instance form a stl::string instance.

Creates a String that is populated with 'd' as displayable characters and precision of 'precision'.

Definition at line 617 of file KKStr.cpp.

References KKB::SPRINTF(), and KKB::STRCOPY().

619  :
620  val (NULL)
621 {
622  char buff[60];
623 
624  if ((precision < 0) || (precision > 10))
625  {
626  SPRINTF (buff, sizeof (buff), "%f", d);
627  }
628  else
629  {
630  SPRINTF (buff, sizeof (buff), "%.*f", precision, d);
631  }
632 
633  kkuint16 newLen = (kkuint16)strlen (buff);
634  AllocateStrSpace (newLen + 1);
635 
636  STRCOPY (val, allocatedSize, buff);
637 
638  len = newLen;
639 }
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
char * STRCOPY(char *dest, kkint32 destSize, const char *src)
Definition: KKStr.cpp:46
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr::KKStr ( const std::string &  s)

summary> Constructs an instance from a substring of the ascii-z string src .

param name='src'> Source string to build new instance from.

param name = 'startPos'> Index of first character that we want to include in new instance.

param name='endPos'> Index of last character that we want to include in new instance.

Definition at line 677 of file KKStr.cpp.

677  :
678  allocatedSize (0),
679  len (0),
680  val (NULL)
681 {
682  AllocateStrSpace ((kkint32)(s.size () + 1));
683 
684  len = (kkuint16)s.size ();
685  for (kkint32 x = 0; x < len; ++x)
686  val[x] = s[x];
687  val[len] = 0;
688 }
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
KKStr::KKStr ( const char *  src,
kkuint32  startPos,
kkuint32  endPos 
)

Constructs a KKStr instance from a sub-string of 'src'.

Definition at line 693 of file KKStr.cpp.

References KKB::KKException::KKException().

Referenced by KKB::KKStrParser::GetNextToken(), KKB::KKStrParser::PeekNextToken(), and KKLSC::ScannerFile::ReportTextMsg().

696  :
697  allocatedSize (0),
698  len (0),
699  val (NULL)
700 {
701  if (startPos > endPos)
702  {
703  AllocateStrSpace (1);
704  return;
705  }
706 
707  kkuint32 subStrLen = 1 + endPos - startPos;
708  if (subStrLen > (KKStrIntMax - 1))
709  {
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;
713  }
714 
715  AllocateStrSpace (1 + subStrLen); // Need one extra byte for NULL terminating character.
716  if (!val)
717  throw KKException ("KKStr::KKStr Allocation Failed");
718 
719  memcpy (val, src + startPos, subStrLen);
720  len = (kkuint16)subStrLen;
721  val[subStrLen] = 0;
722 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89

Member Function Documentation

void KKStr::Append ( const char *  buff)

Definition at line 1783 of file KKStr.cpp.

References KKB::KKException::KKException(), KKB::operator+(), and KKB::StrFromUint32().

Referenced by AppendInt32(), AppendUInt32(), Concat(), operator+(), operator<<(), QuotedStr(), and ToXmlStr().

1784 {
1785  #ifdef KKDEBUG
1786  ValidateLen ();
1787  #endif
1788 
1789  if (!buff)
1790  return;
1791 
1792  kkuint32 buffLen = (kkuint32)strlen (buff);
1793  kkuint32 newLen = len + buffLen;
1794  kkuint32 neededSpace = newLen + 1;
1795 
1796  if (neededSpace > allocatedSize)
1797  {
1798  if (neededSpace >= KKStrIntMax)
1799  {
1800  cerr << std::endl
1801  << "KKStr::Append ***ERROR*** Size of buffer can not fit into String." << std::endl
1802  << " buffLen[" << buffLen << "]" << std::endl
1803  << " neededSpace[" << neededSpace << "]" << std::endl
1804  << std::endl;
1805  throw KKException ("KKStr::Append Length will exceed what KKStr can managed; neededSpace: " + StrFromUint32 (neededSpace));
1806  }
1807  GrowAllocatedStrSpace (neededSpace);
1808  }
1809 
1810  kkuint32 x = 0;
1811  for (x = 0; x < buffLen; x++)
1812  {
1813  val[len] = buff[x];
1814  len++;
1815  }
1816  val[len] = 0;
1817 } /* Append */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
KKStr StrFromUint32(kkuint32 ui)
Definition: KKStr.cpp:5187
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
void KKStr::Append ( const char *  buff,
kkuint32  buffLen 
)

Definition at line 1821 of file KKStr.cpp.

References KKB::KKException::KKException(), KKB::operator+(), and KKB::StrFromUint32().

Referenced by Append(), and SubStrPart().

1824 {
1825  #ifdef KKDEBUG
1826  ValidateLen ();
1827  #endif
1828 
1829  if (buffLen == 0)
1830  return;
1831 
1832  kkuint32 newLen = len + buffLen;
1833  kkuint32 neededSpace = newLen + 1;
1834 
1835  if (neededSpace > allocatedSize)
1836  {
1837  if (neededSpace >= KKStrIntMax)
1838  {
1839  cerr << std::endl
1840  << "KKStr::Append ***ERROR*** Size of buffer can not fit into String." << std::endl
1841  << " buffLen[" << buffLen << "]" << std::endl
1842  << " neededSpace[" << neededSpace << "]" << std::endl
1843  << std::endl;
1844  throw KKException("KKStr::Append Length will exceed what KKStr can managed; neededSpace: " + StrFromUint32(neededSpace));
1845  }
1846  GrowAllocatedStrSpace (neededSpace);
1847  }
1848 
1849  kkuint32 x = 0;
1850  for (x = 0; x < buffLen; x++)
1851  {
1852  val[len] = buff[x];
1853  len++;
1854  }
1855 
1856  val[len] = 0;
1857 } /* Append*/
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
KKStr StrFromUint32(kkuint32 ui)
Definition: KKStr.cpp:5187
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
void KKStr::Append ( char  ch)

Definition at line 1863 of file KKStr.cpp.

References KKB::KKException::KKException(), KKB::operator+(), and KKB::StrFromUint32().

Referenced by AppendInt32(), AppendUInt32(), DecodeQuotedStr(), ExtractQuotedStr(), KKB::KKStrParser::GetNextToken(), KKB::KKStrParser::GetRestOfLine(), KKB::KKStrParser::GetRestOfStr(), KKB::BitString::HexStr(), KKB::operator+(), operator<<(), KKB::osReadNextLine(), KKB::osReadRestOfLine(), KKB::KKStrParser::PeekNextToken(), QuotedStr(), KKLSC::ScannerFile::ReadHeaderOneLine(), KKMLL::ModelDual::ReconcilePredictions(), StripOutInvalidLatexCaracters(), KKB::KKStrParser::SubStrPart(), and ToXmlStr().

1864 {
1865  kkuint32 neededSpace = len + 2;
1866  if (neededSpace > allocatedSize)
1867  {
1868  if (neededSpace >= KKStrIntMax)
1869  {
1870  cerr << std::endl
1871  << "KKStr::Append ***ERROR*** Size of buffer can not fit into String." << std::endl
1872  << " neededSpace[" << neededSpace << "]" << std::endl
1873  << std::endl;
1874  throw KKException("KKStr::Append (char ch) Length will exceed what KKStr can managed; neededSpace: " + StrFromUint32(neededSpace));
1875  }
1876  GrowAllocatedStrSpace (neededSpace);
1877  }
1878  val[len] = ch;
1879  len++;
1880  val[len] = 0;
1881 } /* Append */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
KKStr StrFromUint32(kkuint32 ui)
Definition: KKStr.cpp:5187
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
void KKStr::Append ( const KKStr str)

Definition at line 1887 of file KKStr.cpp.

References Append().

Referenced by operator+(), KKB::operator+(), KKMLL::operator<<(), and ReadXML().

1888 {
1889  Append (str.val, str.len);
1890 }
void Append(const char *buff)
Definition: KKStr.cpp:1783
void KKStr::Append ( const std::string &  str)

Definition at line 1894 of file KKStr.cpp.

1895 {
1896  Append (str.c_str ());
1897 }
void Append(const char *buff)
Definition: KKStr.cpp:1783
void KKStr::AppendInt32 ( kkint32  i)

Definition at line 1901 of file KKStr.cpp.

References Append().

Referenced by KKB::RunLog::operator<<(), and operator<<().

1902 {
1903  if (i == 0)
1904  {
1905  Append ('0');
1906  return;
1907  }
1908 
1909  char buff[64];
1910  kkint16 bi = sizeof (buff) - 1;
1911  buff[bi] = 0;
1912 
1913  bool negative = false;
1914  if (i < 0)
1915  {
1916  negative = true;
1917  i = 0 - i;
1918  }
1919 
1920  while (i > 0)
1921  {
1922  --bi;
1923  kkint16 digit = i % 10;
1924  i = i / 10;
1925  buff[bi] = '0' + (char)digit;
1926  }
1927 
1928  if (negative)
1929  {
1930  --bi;
1931  buff[bi] = '-';
1932  }
1933 
1934  Append (buff + bi);
1935  return;
1936 } /* AppendInt32 */
__int16 kkint16
16 bit signed integer.
Definition: KKBaseTypes.h:85
void Append(const char *buff)
Definition: KKStr.cpp:1783
void KKStr::AppendUInt32 ( kkuint32  i)

Definition at line 1940 of file KKStr.cpp.

References Append().

Referenced by KKB::RunLog::operator<<(), and operator<<().

1941 {
1942  if (i == 0)
1943  {
1944  Append ('0');
1945  return;
1946  }
1947 
1948  char buff[64];
1949  kkint16 bi = sizeof (buff) - 1;
1950  buff[bi] = 0;
1951 
1952  while (i > 0)
1953  {
1954  --bi;
1955  kkint16 digit = i % 10;
1956  i = i / 10;
1957  buff[bi] = '0' + (char)digit;
1958  }
1959 
1960  Append (buff + bi);
1961  return;
1962 } /* AppendUInt32 */
__int16 kkint16
16 bit signed integer.
Definition: KKBaseTypes.h:85
void Append(const char *buff)
Definition: KKStr.cpp:1783
const char* KKB::KKStr::c_str ( )
inline

Definition at line 585 of file KKStr.h.

References Str().

585 {return Str ();}
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
bool KKStr::CharInStr ( char  ch)

Determines if 'ch' occurs anywhere in the string.

Definition at line 2712 of file KKStr.cpp.

2713 {
2714  if (!val)
2715  return false;
2716 
2717  for (kkint32 x = 0; x < len; x++)
2718  {
2719  if (val[x] == ch)
2720  return true;
2721  }
2722  return false;
2723 }
__int32 kkint32
Definition: KKBaseTypes.h:88
void KKStr::ChopFirstChar ( )

Removes the first character from the string.

Definition at line 1649 of file KKStr.cpp.

Referenced by KKB::PointList::FromDelStr(), ToLatitude(), and ToLongitude().

1650 {
1651  #ifdef KKDEBUG
1652  ValidateLen ();
1653  #endif
1654 
1655  if (!val) return;
1656 
1657  if (len > 0)
1658  {
1659  for (int x = 0; x < len; ++x)
1660  val[x] = val[x + 1];
1661  len--;
1662  val[len] = 0;
1663  }
1664 } /* ChopLastChar */
void KKStr::ChopLastChar ( )

Removes the last character from the string.

Definition at line 1668 of file KKStr.cpp.

Referenced by KKMLL::FeatureFileIODstWeb::AttrDescLine::AttrDescLine(), KKMLL::FeatureFileIOC45::GetFileDesc(), KKMLL::FeatureFileIODstWeb::LoadFile(), KKB::osGetDirNameFromPath(), KKB::osGetParentDirectoryOfDirPath(), KKB::osGetParentDirPath(), KKB::osGetRootNameOfDirectory(), ToLatitude(), and ToLongitude().

1669 {
1670  #ifdef KKDEBUG
1671  ValidateLen ();
1672  #endif
1673 
1674  if (!val) return;
1675 
1676  if (len > 0)
1677  {
1678  len--;
1679  val[len] = 0;
1680  }
1681 } /* ChopLastChar */
kkint32 KKStr::Compare ( const KKStr s2) const

'-1' = less than 's2', '0' = Same as 's2', and '1' = Greater than 's2'.

Definition at line 844 of file KKStr.cpp.

Referenced by CompareTo(), operator!=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().

845 {
846  kkint32 zed = Min (len, s2.len);
847 
848  const char* s1Ptr = val;
849  const char* s2Ptr = s2.val;
850 
851  for (kkint32 x = 0; x < zed; x++)
852  {
853  if ((*s1Ptr) < (*s2Ptr))
854  return -1;
855 
856  else if ((*s1Ptr) > (*s2Ptr))
857  return 1;
858 
859  s1Ptr++;
860  s2Ptr++;
861  }
862 
863  if (len == s2.len)
864  return 0;
865 
866  else if (len < s2.len)
867  return -1;
868 
869  else
870  return 1;
871 
872 } /* Compare */
__int32 kkint32
Definition: KKBaseTypes.h:88
T Min(T a, T b)
Generic Min function, Both parameters must be of the same type.
Definition: KKBaseTypes.h:168
kkint32 KKStr::Compare ( const std::string &  s2) const

Compares with STL string.

'-1' = less than 's2', '0' = Same as 's2', and '1' = Greater than 's2'.

Parameters
[in]s2STL String std::string that we will compare with.
Returns
-1=less, 0=equal, 1=greater, -1, 0, or 1, indicating if less than, equal, or greater.

Definition at line 881 of file KKStr.cpp.

882 {
883  kkuint16 s2Len = (kkuint16)s2.size ();
884  kkint32 zed = Min (len, s2Len);
885 
886  const char* s1Ptr = val;
887  const char* s2Ptr = s2.c_str ();
888 
889  for (kkint32 x = 0; x < zed; x++)
890  {
891  if ((*s1Ptr) < (*s2Ptr))
892  return -1;
893 
894  else if ((*s1Ptr) > (*s2Ptr))
895  return 1;
896 
897  s1Ptr++;
898  s2Ptr++;
899  }
900 
901  if (len == s2Len)
902  return 0;
903 
904  else if (len < s2Len)
905  return -1;
906 
907  else
908  return 1;
909 
910 } /* Compare */
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
T Min(T a, T b)
Generic Min function, Both parameters must be of the same type.
Definition: KKBaseTypes.h:168
kkint32 KKStr::CompareIgnoreCase ( const KKStr s2) const

Compares with another KKStr, ignoring case.

summary>Compares with STL string ignoring case.

Parameters
s2STL String std::string that we will compare with.

returns> -1=less, 0=equal, 1=greater, -1, 0, or 1, indicating if less than, equal, or greater.

Parameters
[in]s2Other String to compare with.
Returns
-1=less, 0=equal, 1=greater, -1, 0, or 1, indicating if less than, equal, or greater.

Definition at line 919 of file KKStr.cpp.

Referenced by EqualIgnoreCase().

920 {
921  kkint32 zed = Min (len, s2.len);
922 
923  const char* s1Ptr = val;
924  const char* s2Ptr = s2.val;
925 
926  for (kkint32 x = 0; x < zed; x++)
927  {
928  if (toupper (*s1Ptr) < toupper (*s2Ptr))
929  return -1;
930 
931  else if (toupper (*s1Ptr) > toupper (*s2Ptr))
932  return 1;
933 
934  s1Ptr++;
935  s2Ptr++;
936  }
937 
938  if (len == s2.len)
939  return 0;
940 
941  else if (len < s2.len)
942  return -1;
943 
944  else
945  return 1;
946 } /* CompareIgnoreCase */
__int32 kkint32
Definition: KKBaseTypes.h:88
T Min(T a, T b)
Generic Min function, Both parameters must be of the same type.
Definition: KKBaseTypes.h:168
kkint32 KKStr::CompareIgnoreCase ( const std::string &  s2) const

summary>Compares with ascii-z string ignoring case.

param name='s2'> Ascii-z string to compare with.

returns> -1=less, 0=equal, 1=greater, -1, 0, or 1, indicating if less than, equal, or greater.

Definition at line 998 of file KKStr.cpp.

999 {
1000  kkuint16 s2Len = (kkuint16)s2.size ();
1001  kkint32 zed = Min (len, s2Len);
1002 
1003  const char* s1Ptr = val;
1004  const char* s2Ptr = s2.c_str ();
1005 
1006  for (kkint32 x = 0; x < zed; x++)
1007  {
1008  if (toupper (*s1Ptr) < toupper (*s2Ptr))
1009  return -1;
1010 
1011  else if (toupper (*s1Ptr) > toupper (*s2Ptr))
1012  return 1;
1013 
1014  s1Ptr++;
1015  s2Ptr++;
1016  }
1017 
1018  if (len == s2Len)
1019  return 0;
1020 
1021  else if (len < s2Len)
1022  return -1;
1023 
1024  else
1025  return 1;
1026 
1027 } /* CompareIgnoreCase */
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
T Min(T a, T b)
Generic Min function, Both parameters must be of the same type.
Definition: KKBaseTypes.h:168
kkint32 KKStr::CompareIgnoreCase ( const char *  s2) const

summary>Compares to Strings and returns -1, 0, or 1, indicating if less than, equal, or greater.

Compares with ascii-z string ignoring case.

Parameters
[in]s2Ascii-z string to compare with.
Returns
-1=less, 0=equal, 1=greater, -1, 0, or 1, indicating if less than, equal, or greater.

Definition at line 955 of file KKStr.cpp.

Referenced by KKJobManagment::KKJob::JobStatusFromStr(), KKB::DateType::MonthFromStr(), KKJobManagment::KKJob::PrerequisitesFromStr(), and KKJobManagment::KKJobManager::StatusFileProcessLine().

956 {
957  if (s2 == NULL)
958  {
959  if (len == 0)
960  return 0;
961  else
962  return 1;
963  }
964 
965  kkuint32 s2Len = 0;
966  if (s2 != NULL)
967  s2Len = (kkuint32)strlen (s2);
968  kkuint32 zed = Min ((kkuint32)len, s2Len);
969 
970  const char* s1Ptr = val;
971  const char* s2Ptr = s2;
972 
973  for (kkuint16 x = 0; x < zed; x++)
974  {
975  if (toupper (*s1Ptr) < toupper (*s2Ptr))
976  return -1;
977 
978  else if (toupper (*s1Ptr) > toupper (*s2Ptr))
979  return 1;
980 
981  s1Ptr++;
982  s2Ptr++;
983  }
984 
985  if (len == s2Len)
986  return 0;
987 
988  else if (len < s2Len)
989  return -1;
990 
991  else
992  return 1;
993 } /* CompareIgnoreCase */
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
T Min(T a, T b)
Generic Min function, Both parameters must be of the same type.
Definition: KKBaseTypes.h:168
kkint32 KKStr::CompareStrings ( const KKStr s1,
const KKStr s2 
)
static

Compares to Strings and returns -1, 0, or 1, indicating if less than, equal, or greater.

summary> Concatenates the list of char* strings, stopping at first NULL. Each of these NULL terminated strings are concatenated onto the result string; terminates when 'values[x] == NULL'. /summary>

Definition at line 4714 of file KKStr.cpp.

Referenced by KKB::KKStrList::StringComparison::operator()().

4717 {
4718  if (s1.val == NULL)
4719  {
4720  if (s2.val == NULL)
4721  return 0;
4722  else
4723  return -1;
4724  }
4725 
4726  else if (s2.val == NULL)
4727  {
4728  return 1;
4729  }
4730 
4731  else
4732  {
4733  return strcmp (s1.val, s2.val);
4734  }
4735 } /* CompareStrings */
kkint32 KKB::KKStr::CompareTo ( const KKStr s2) const
inline

summary>Compares with another KKStr, ignoring case.

param name='s2'> Other String to compare with.

returns> -1=less, 0=equal, 1=greater, -1, 0, or 1, indicating if less than, equal, or greater.

Definition at line 184 of file KKStr.h.

References Compare().

KKStr KKStr::Concat ( const char **  values)
static

summary> Concatenates the list of char* strings, stops at first NULL Each of these NULL terminated strings are concatenated onto the result string; terminates when 'values[x] == NULL'. /summary>

Definition at line 1031 of file KKStr.cpp.

References Append(), Concat(), and KKStr().

1032 {
1033  if (values == NULL)
1034  return "";
1035 
1036  kkuint32 len = 0;
1037  kkint32 x = 0;
1038  while (values[x] != NULL)
1039  {
1040  len += (kkuint32)strlen (values[x]);
1041  x++;
1042  }
1043 
1044  KKStr result (len);
1045  x = 0;
1046  while (values[x] != NULL)
1047  {
1048  result.Append (values[x]);
1049  x++;
1050  }
1051 
1052  return result;
1053 } /* Concat */
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
KKStr KKStr::Concat ( const VectorKKStr values)
static

Definition at line 1057 of file KKStr.cpp.

References Concat(), and KKStr().

1058 {
1059  kkuint32 x = 0;
1060  kkint32 len = 0;
1061 
1062  for (x = 0; x < values.size (); x++)
1063  len += (kkint32)values.size ();
1064 
1065  KKStr result (len);
1066  x = 0;
1067  for (x = 0; x < values.size (); x++)
1068  {
1069  result.Append (values[x]);
1070  x++;
1071  }
1072 
1073  return result;
1074 } /* Concat */
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
KKStr KKStr::Concat ( const std::vector< std::string > &  values)
static

Concatenates the list of 'std::string' strings.

Iterates through values concatenating each one onto a result string.

Iterates through values Concatenating each one onto a result string.

Definition at line 1082 of file KKStr.cpp.

References Concat(), and KKStr().

Referenced by KKMLL::ConfusionMatrix2::AccuracyStr(), KKLSC::ScannerHeaderFields::Add(), KKB::XmlElementKeyValuePairs::Add(), KKMLL::Attribute::AddANominalValue(), KKMLL::FileDesc::AddANominalValue(), KKB::XmlTag::AddAtribute(), KKMLL::FeatureVector::AddFeatureData(), KKB::MsgQueue::AddMsg(), KKB::KKThread::AddMsg(), KKMLL::FeatureVectorList::AddQueue(), KKB::RasterBuffer::AddRaster(), KKMLL::DuplicateImages::AddSingleExample(), KKMLL::FeatureFileIO::AppendToFile(), KKMLL::FeatureFileIODstWeb::AttrDescLine::AttrDescLine(), KKB::XmlAttributeList::AttributeValueKKStr(), KKMLL::GrayScaleImagesFVList::BackOfQueue(), KKB::KKStrList::BinarySearch(), KKB::BitString::BitString(), KKMLL::TrainingConfiguration2::BuildTrainingClassListFromDirectoryStructure(), KKMLL::FileDesc::Cardinality(), KKMLL::MLClass::ChangeNameOfClass(), KKMLL::Classifier2::Classifier2(), KKMLL::FeatureVector::ClassName(), KKMLL::FeatureVectorList::ClassStatisticsStr(), KKB::CmdLineExpander::CmdLineExpander(), KKMLL::GrayScaleImagesFVProducer::ComputeFeatureVector(), Concat(), KKMLL::TrainingConfiguration2::ConfigFileExists(), KKLSC::Variables::ConfigurationDir(), KKMLL::Model::CreateAModel(), KKMLL::FeatureEncoder2::CreateEncodedFileDesc(), KKMLL::FeatureEncoder::CreateEncodedFileDesc(), KKMLL::TrainingConfiguration2::CreateFromDirectoryStructure(), KKMLL::TrainingConfiguration2::CreateFromFeatureVectorList(), KKMLL::BinaryClassParms::CreateFromTabDelStr(), KKMLL::ClassProbList::CreateFromXMLStream(), KKMLL::MLClass::CreateNewMLClass(), KKMLL::Orderings::CreateOrderingsObjFromFileIfAvaliable(), KKB::BmpImage::CodedPixels::CreatePixelDataStructure8Bit(), KKLSC::ScannerFile::CreateScannerFileForOutput(), KKMLL::TrainingProcess2::CreateTrainingProcess(), KKMLL::TrainingProcess2::CreateTrainingProcessForLevel(), KKB::DateTime::DateTime(), KKB::DateType::DateType(), DecodeQuotedStr(), KKMLL::ModelSvmBase::Description(), KKMLL::ModelOldSVM::Description(), KKMLL::ModelDual::Description(), KKB::Matrix::DeterminantSlow(), KKMLL::TrainingConfiguration2::DirectoryPathForClass(), EmptyStr(), KKMLL::FeatureEncoder::EncodeAExample(), KKMLL::ModelParam::EncodingMethodFromStr(), KKMLL::EncodingMethodFromStr(), KKB::GoalKeeper::EndBlock(), KKMLL::DuplicateImage::ExampleWithSmallestScanLine(), KKMLL::TrainingClass::ExpandedDirectory(), KKB::Raster::ExtractBlobs(), KKB::Raster::ExtractChannel(), KKMLL::FeatureVectorList::ExtractDuplicatesByRootImageFileName(), KKMLL::FeatureVectorList::ExtractExamplesForAGivenClass(), KKMLL::FeatureNumList::ExtractFeatureNumsFromStr(), KKMLL::MLClassList::ExtractHTMLTableHeader(), ExtractQuotedStr(), KKMLL::MLClassList::ExtractThreeTitleLines(), ExtractToken(), ExtractToken2(), ExtractTokenBool(), ExtractTokenDouble(), ExtractTokenInt(), ExtractTokenUint(), ExtractTokenUint64(), KKMLL::MLClassList::ExtractTwoTitleLines(), KKMLL::FeatureFileIO::FeatureDataReSink(), KKMLL::FeatureEncoder::FeatureEncoder(), KKMLL::FeatureVectorProducer::FeatureName(), KKMLL::FeatureVectorList::FeatureVectorList(), KKMLL::FeatureFileIO::FileFormatsReadAndWriteOptionsStr(), KKMLL::FeatureFileIO::FileFormatsReadOptionsStr(), KKMLL::FeatureFileIO::FileFormatsWrittenOptionsStr(), KKMLL::SVMModel::FindWorstSupportVectors(), KKMLL::SVMModel::FindWorstSupportVectors2(), KKMLL::ConfusionMatrix2::FMeasure(), KKMLL::CrossValidationVoting::FoldAccuracysToStr(), KKMLL::CrossValidation::FoldAccuracysToStr(), KKMLL::CrossValidationVoting::FoldStr(), KKB::Configuration::FormatErrorsWithLineNumbers(), FreeUpUnUsedSpace(), KKB::PointList::FromDelStr(), GetClassNameByHierarchyLevel(), KKMLL::MLClass::GetClassNameFromDirName(), KKMLL::TrainingConfiguration2::GetEffectiveConfigFileName(), KKMLL::FileDesc::GetExistingFileDesc(), KKMLL::FeatureFileIODstWeb::GetFileDesc(), KKMLL::FeatureFileIOColumn::GetFileDesc(), KKMLL::FeatureFileIOC45::GetFileDesc(), KKMLL::FeatureFileIOUCI::GetFileDesc(), KKMLL::FeatureFileIOSparse::GetFileDesc(), KKB::KKStrParser::GetNextToken(), KKB::XmlStream::GetNextToken(), KKB::KKStrParser::GetNextTokenChar(), KKMLL::Attribute::GetNominalValue(), KKLSC::ScannerFileEntry::GetOrCreateScannerFileEntry(), KKB::KKStrParser::GetRestOfLine(), KKB::KKStrParser::GetRestOfStr(), KKLSC::ScannerHeaderFields::GetValue(), KKLSC::ScannerFile::GetValue(), KKLSC::ScannerHeaderFields::GetValueFloat(), KKLSC::ScannerHeaderFields::GetValueInt32(), KKMLL::GrayScaleImagesFVList::GrayScaleImagesFVList(), KKLSC::ScannerFile::GuessFormatOfFile(), KKB::BitString::HexStr(), KKB::Raster::Histogram(), KKLSC::Variables::HomeDir(), KKJobManagment::KKJobManager::InitilizeJobManager(), KKB::Matrix::Inverse(), KKMLL::KernalTypeFromStr(), KKStr(), LeftPad(), KKB::BitString::ListOfSetBits16(), KKMLL::TrainingConfiguration2::Load(), KKMLL::FeatureNumList::Load(), KKMLL::TrainingProcess2::LoadExistingTrainingProcess(), KKMLL::FeatureFileIOC45::LoadFeatureFile(), KKMLL::FeatureFileIO::LoadFeatureFile(), KKMLL::FeatureFileIODstWeb::LoadFile(), KKMLL::FeatureFileIOColumn::LoadFile(), KKMLL::FeatureFileIOUCI::LoadFile(), KKMLL::FeatureFileIOC45::LoadFile(), KKMLL::FeatureFileIOSparse::LoadFile(), KKLSC::ScannerFile::LoadIndexFile(), KKMLL::FeatureFileIO::LoadInSubDirectoryTree(), KKMLL::TrainingConfiguration2::LoadOtherClasssExamples(), KKMLL::TrainingConfiguration2List::LookUp(), KKB::KKStrListIndexed::LookUp(), KKMLL::AttributeList::LookUpByName(), KKMLL::FeatureVectorList::LookUpByRootName(), KKMLL::MachineTypeFromStr(), KKB::Matrix::Matrix(), KKMLL::FileDesc::MergeSymbolicFields(), KKMLL::MLClass::MLClassForGivenHierarchialLevel(), KKMLL::FeatureVector::MLClassName(), KKB::DateType::MM_DD_YY(), KKB::DateType::MMM_DD_YYYY(), KKMLL::ClassStatistic::Name(), KKB::XmlElement::NameTagStr(), KKMLL::FileDesc::NewContinuousDataOnly(), KKMLL::FeatureVectorList::RootNameComparrison::operator()(), KKMLL::FeatureVectorList::RootNameComparrisonReversed::operator()(), KKMLL::FeatureVectorList::ClassNameComparrison::operator()(), KKMLL::FeatureVectorList::ClassNameComparrisonReversed::operator()(), KKB::KKStrList::StringComparison::operator()(), KKB::Matrix::operator*(), KKB::Matrix::operator+(), operator+(), KKB::operator+(), KKB::Matrix::operator+=(), KKB::Matrix::operator-(), KKB::operator<<(), KKB::RunLog::operator<<(), operator<<(), operator=(), KKB::Matrix::operator[](), KKMLL::FeatureNumList::operator[](), KKB::osAddSlash(), KKB::osCopyFile(), KKB::osCopyFileBetweenDirectories(), KKB::osCreateDirectoryPath(), KKB::osCreateUniqueFileName(), osFileNameMatchesSearchFields(), KKB::osGetCurrentDirectory(), KKB::osGetDirNameFromPath(), KKB::osGetErrorNoDesc(), KKB::osGetFileExtension(), KKB::osGetFileNamePartOfFile(), KKB::osGetHostName(), KKB::osGetListOfFilesInDirectoryTree(), KKB::osGetListOfImageFiles(), KKB::osGetParentDirectoryOfDirPath(), KKB::osGetParentDirPath(), KKB::osGetPathPartOfFile(), KKB::osGetProgName(), KKB::osGetRootName(), KKB::osGetRootNameOfDirectory(), KKB::osGetRootNameWithExtension(), KKB::osGetUserName(), KKB::osLookForFile(), KKB::osMakeFullFileName(), KKB::osMoveFileBetweenDirectories(), KKB::osParseFileSpec(), KKB::osReadNextLine(), KKB::osReadNextQuotedStr(), KKB::osReadRestOfLine(), KKB::osReadRestOfLine2(), KKB::osRemoveExtension(), KKB::osSubstituteInEnvironmentVariables(), KKMLL::ModelOldSVM::Param(), KKMLL::MLClass::ParentName(), Parse(), KKMLL::MLClassIndexList::ParseClassIndexList(), KKMLL::ModelParam::ParseCmdLine(), KKMLL::ModelParamOldSVM::ParseCmdLine(), KKMLL::SVMparam::ParseCmdLineParameter(), KKB::KKStrList::ParseDelimitedString(), KKLSC::ScannerFileEntry::ParseTabDelStr(), KKLSC::StartStopPoint::ParseTabDelStr(), SVM233::svm_parameter::ParseTabDelStr(), SVM289_BFS::svm_parameter::ParseTabDelStr(), SVM289_MFS::svm_parameter::ParseTabDelStr(), KKMLL::ClassAssignments::ParseToString(), KKB::KKStrParser::PeekNextToken(), KKMLL::GrayScaleImagesFVList::PopFromBack(), KKMLL::ModelSvmBase::Predict(), KKMLL::ModelUsfCasCor::Predict(), KKMLL::SVMModel::Predict(), KKMLL::FeatureVector::PredictedClassName(), KKJobManagment::KKJob::PrerequisitesToStr(), KKMLL::ConfusionMatrix2::PrintAccuracyByProbByClassHTML(), KKMLL::SizeDistribution::PrintByClassCollumns(), KKMLL::ConfusionMatrix2::PrintConfusionMatrix(), KKMLL::ConfusionMatrix2::PrintConfusionMatrixHTML(), KKMLL::ConfusionMatrix2::PrintConfusionMatrixLatexTable(), KKMLL::ConfusionMatrix2::PrintConfusionMatrixNarrow(), KKMLL::ConfusionMatrix2::PrintConfusionMatrixTabDelimited(), KKMLL::SizeDistribution::ClassTotals::PrintFormatedLine(), KKMLL::ConfusionMatrix2::PrintTrueFalsePositivesTabDelimited(), KKMLL::ModelKnn::ProbabilitiesByClass(), KKMLL::ModelSvmBase::ProbabilitiesByClass(), KKMLL::ModelUsfCasCor::ProbabilitiesByClass(), KKMLL::ModelOldSVM::ProbabilitiesByClass(), KKMLL::ModelParamDual::ProbFusionMethodToStr(), KKJobManagment::KKJob::ProcessStatusStr(), KKMLL::ClassProbList::PushOnBack(), KKMLL::BinaryClassParmsList::PushOnBack(), KKMLL::FeatureVectorList::PushOnBack(), KKMLL::ClassProbList::PushOnFront(), KKMLL::BinaryClassParmsList::PushOnFront(), KKMLL::FeatureVectorList::PushOnFront(), QuotedStr(), KKB::Raster::Raster(), KKLSC::ScannerFile::ReadHeader(), KKB::ReadImage(), KKB::ReadImagePGM(), KKB::ReadImagePPM(), KKB::ReadImagePpmField(), KKMLL::ModelParamKnn::ReadXML(), KKMLL::AttributeTypeVector::ReadXML(), KKB::VectorKKStr::ReadXML(), KKMLL::ModelParamUsfCasCor::ReadXML(), KKMLL::ModelParamDual::ReadXML(), KKMLL::NormalizationParms::ReadXML(), KKMLL::ModelKnn::ReadXML(), KKMLL::ClassProbList::ReadXML(), KKMLL::FeatureEncoder::ReadXML(), KKMLL::ModelUsfCasCor::ReadXML(), KKMLL::ModelSvmBase::ReadXML(), KKMLL::ModelParamOldSVM::ReadXML(), KKMLL::TrainingClassList::ReadXML(), SVM233::SvmModel233::ReadXML(), KKMLL::ModelDual::ReadXML(), SVM289_MFS::Svm_Model::ReadXML(), KKMLL::FileDesc::ReadXML(), KKMLL::SVMparam::ReadXML(), KKMLL::ModelOldSVM::ReadXML(), KKMLL::SVMModel::ReadXML(), KKMLL::TrainingProcess2::ReadXML(), KKB::KKStrList::ReadXML(), KKB::KKStrListIndexed::ReadXML(), KKMLL::TrainingConfiguration2::ReadXMLBaseToken(), KKMLL::ModelParam::ReadXMLModelParamToken(), KKMLL::Model::ReadXMLModelPost(), KKMLL::Model::ReadXMLModelToken(), KKMLL::GrayScaleImagesFVList::RecalcFeatureValuesFromImagesInDirTree(), KKMLL::ModelDual::ReconcilePredictions(), KKMLL::ModelDual::ReconcileProbAndVotes(), KKB::XmlFactoryManager::RegisterFactory(), KKB::XmlFactory::RegisterFactory(), KKLSC::ScannerFile::ReportTextMsg(), KKMLL::FeatureVectorList::ResetFileDesc(), KKMLL::FeatureVector::ResetNumOfFeatures(), KKMLL::FeatureVectorList::ReSyncSymbolicData(), KKMLL::ModelSvmBase::RetrieveCrossProbTable(), RightPad(), KKB::Row::Row(), KKMLL::FileDesc::SameExceptForSymbolicData(), KKB::BmpImage::Save(), KKMLL::Orderings::Save(), KKMLL::FeatureFileIO::SaveFeatureFile(), KKMLL::FeatureFileIORoberts::SaveFile(), KKMLL::FeatureFileIOC45::SaveFile(), KKB::BmpImage::SaveGrayscaleInverted4Bit(), KKB::BmpImage::SaveGrayscaleInverted8Bit(), KKB::SaveImage(), KKB::SaveImageGrayscaleInverted4Bit(), KKB::SaveImageGrayscaleInverted8Bit(), KKB::SaveImagePGM(), KKB::SaveImagePNG(), KKB::SaveImagePPM(), KKLSC::Variables::ScannerFilesDefaultDir(), KKB::XmlToken::SectionName(), KKB::XmlElement::SectionName(), KKB::Raster::SegmentImage(), KKMLL::SelectionMethodFromStr(), KKB::Configuration::SettingValueToStr(), Spaces(), Split(), KKJobManagment::KKJobManager::StatusFileProcessLine(), KKJobManagment::KKJobManager::StatusFileProcessLineJobStatusChange(), KKB::StrFormatDouble(), KKB::StrFormatInt64(), KKB::StrFromDouble(), KKB::StrFromFloat(), KKB::StrFromInt16(), KKB::StrFromInt32(), KKB::StrFromInt64(), KKB::StrFromUint16(), KKB::StrFromUint32(), KKB::StrFromUint64(), StripOutInvalidLatexCaracters(), StrReplace(), KKLSC::Variables::SubstituteInEnvironmentVariables(), KKB::KKStrParser::SubStrPart(), SubStrPart(), KKB::SupportedImageFileFormat(), KKMLL::SVMModel::SupportVectorNames(), SVM233::svm_GetSupportVectorStatistics(), SVM233::svm_parameter::svm_parameter(), SVM289_BFS::svm_train_one(), SVM289_MFS::svm_train_one(), KKMLL::TrainingConfiguration2::SVMparamREF(), KKMLL::ModelParamOldSVM::SvmParamToString(), KKMLL::SVMparam::SvmParamToString(), KKMLL::FeatureVectorList::SynchronizeSymbolicData(), KKB::ThreadStartCallBack(), KKB::KKThread::ThreadStatusToStr(), KKB::TimeType::TimeType(), KKMLL::ModelParamSvmBase::ToCmdLineStr(), KKMLL::ModelParamUsfCasCor::ToCmdLineStr(), KKMLL::ModelParamDual::ToCmdLineStr(), SVM233::svm_parameter::ToCmdLineStr(), KKMLL::ModelParam::ToCmdLineStr(), SVM289_BFS::svm_parameter::ToCmdLineStr(), SVM289_MFS::svm_parameter::ToCmdLineStr(), KKMLL::ModelParamOldSVM::ToCmdLineStr(), KKMLL::MLClassList::ToCommaDelimitedQuotedStr(), KKMLL::MLClassList::ToCommaDelimitedStr(), KKMLL::MLClassIndexList::ToCommaDelString(), KKB::PointList::ToDelStr(), ToKKStrPtr(), ToLatitude(), ToLongitude(), ToLower(), ToPercentage(), KKJobManagment::KKJob::ToStatusStr(), KKJobManagment::KKJobManager::ToStatusStr(), KKB::PixelValue::ToStr(), KKMLL::ClassAssignments::ToString(), KKMLL::MLClass::ToString(), KKMLL::FeatureNumList::ToString(), KKMLL::SVMparam::ToString(), KKB::XmlTag::ToString(), KKMLL::MLClassList::ToString(), KKMLL::MLClassList::ToTabDelimitedStr(), KKLSC::ScannerFileEntry::ToTabDelStr(), KKLSC::StartStopPoint::ToTabDelStr(), SVM233::svm_parameter::ToTabDelStr(), SVM289_BFS::svm_parameter::ToTabDelStr(), SVM289_MFS::svm_parameter::ToTabDelStr(), KKMLL::BinaryClassParms::ToTabDelString(), KKB::KKStrListIndexed::ToTabDelString(), ToUpper(), ToVectorInt32(), ToXmlStr(), KKMLL::ModelUsfCasCor::TrainModel(), KKMLL::ModelSvmBase::TrainModel(), KKMLL::ModelDual::TrainModel(), KKMLL::ModelOldSVM::TrainModel(), KKMLL::Model::TrainModel(), KKB::XmlToken::VarName(), KKB::XmlElement::VarName(), Wide(), KKLSC::ScannerFile::WriteHeader(), KKLSC::ScannerFile::WriteInstrumentDataWord(), KKMLL::TrainingClassList::WriteXML(), SVM289_MFS::Svm_Model::WriteXML(), KKMLL::SVMModel::WriteXML(), KKB::XmlElementArrayFloat2DVarying::WriteXML(), KKB::XmlElementKeyValuePairs::XmlElementKeyValuePairs(), KKMLL::XmlElementMLClassNameList::XmlElementMLClassNameList(), KKB::XmlTag::XmlTag(), KKB::DateType::YY_MM_DD(), KKB::DateType::YYYY_MM_DD(), KKB::DateType::YYYY_MMM_DD(), and KKB::DateType::YYYYMMDD().

1083 {
1084  kkuint32 x = 0;
1085  kkint32 len = 0;
1086 
1087  for (x = 0; x < values.size (); x++)
1088  len += (kkint32)values.size ();
1089 
1090  KKStr result (len);
1091  x = 0;
1092  for (x = 0; x < values.size (); x++)
1093  {
1094  result.Append (values[x]);
1095  x++;
1096  }
1097 
1098  return result;
1099 } /* Concat */
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
bool KKStr::Contains ( const KKStr value)

Definition at line 1103 of file KKStr.cpp.

References Empty(), and StrInStr().

1104 {
1105  if (value.Empty ())
1106  return true;
1107  else
1108  return StrInStr (value);
1109 }
bool Empty() const
Definition: KKStr.h:241
static bool StrInStr(const char *target, const char *searchStr)
Definition: KKStr.cpp:4391
bool KKStr::Contains ( const char *  value)

Definition at line 1112 of file KKStr.cpp.

References Find().

1113 {
1114  if ((value == NULL) || (*value == 0))
1115  return true;
1116  else
1117  return (Find (value, 0) >= 0);
1118 }
kkint32 Find(const KKStr &str, kkint32 pos=0) const
Will return the position where the 1st instance of &#39;str&#39; after &#39;pos&#39; occurs or -1 if not found...
Definition: KKStr.cpp:3931
kkint32 KKStr::CountInstancesOf ( char  ch) const

Definition at line 1122 of file KKStr.cpp.

Referenced by KKB::DateTime::DateTime().

1123 {
1124  if (!val)
1125  return 0;
1126  kkint32 count = 0;
1127  for (kkint32 x = 0; x < len; ++x)
1128  {
1129  if (val[x] == ch)
1130  ++count;
1131  }
1132  return count;
1133 }
__int32 kkint32
Definition: KKBaseTypes.h:88
const char* KKB::KKStr::data ( )
inline

Definition at line 587 of file KKStr.h.

References Str().

587 {return Str ();}
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
KKStr KKStr::DecodeQuotedStr ( ) const

Trees this KKSr instance as a QuotedStr; decodes escape sequences such as '\', '', '
', '', and '\0' into original characters.

Definition at line 3243 of file KKStr.cpp.

References Append(), Concat(), EmptyStr(), and KKStr().

3244 {
3245  if ((!val) || (len == 0))
3246  return EmptyStr ();
3247 
3248  KKStr result (len + 4);
3249  kkint32 idx = 0;
3250 
3251  kkint32 lastCharPos = len - 1;
3252 
3253  if ((val[idx] == '"') && (val[len - 1] == '"'))
3254  {
3255  ++idx;
3256  --lastCharPos;
3257  }
3258 
3259  while (idx <= lastCharPos)
3260  {
3261  if (val[idx] == '\\')
3262  {
3263  ++idx;
3264  if (idx <= lastCharPos)
3265  {
3266  result.Append (val[idx]);
3267  ++idx;
3268  }
3269  }
3270  else
3271  {
3272  result.Append (val[idx]);
3273  ++idx;
3274  }
3275  }
3276 
3277  return result;
3278 } /* DecodeQuotedStr */
__int32 kkint32
Definition: KKBaseTypes.h:88
static const KKStr & EmptyStr()
Static method that returns an Empty String.
Definition: KKStr.cpp:3453
bool KKB::KKStr::Empty ( ) const
inline

Definition at line 241 of file KKStr.h.

Referenced by KKMLL::MLClassList::AddMLClass(), KKMLL::DuplicateImages::AddSingleExample(), KKLSC::ScannerFile::AddStartStopEntryToIndexFile(), KKB::CmdLineExpander::CmdLineExpander(), Contains(), KKMLL::TrainingConfiguration2::CreateFromDirectoryStructure(), KKMLL::TrainingConfiguration2::CreateFromFeatureVectorList(), KKMLL::BinaryClassParms::CreateFromTabDelStr(), KKMLL::ClassProbList::CreateFromXMLStream(), KKMLL::Orderings::CreateOrderingsObjFromFileIfAvaliable(), KKB::DateTime::DateTime(), KKMLL::TrainingClass::ExpandedDirectory(), KKMLL::FeatureNumList::ExtractFeatureNumsFromStr(), KKMLL::MLClassList::ExtractThreeTitleLines(), KKMLL::FeatureFileIO::FeatureDataReSink(), KKMLL::FeatureFileIO::FileFormatsReadAndWriteOptionsStr(), KKMLL::FeatureFileIO::FileFormatsReadOptionsStr(), KKMLL::FeatureFileIO::FileFormatsWrittenOptionsStr(), GetClassNameByHierarchyLevel(), KKMLL::TrainingConfiguration2::GetEffectiveConfigFileName(), KKMLL::FeatureFileIOC45::GetFileDesc(), KKMLL::FeatureFileIOUCI::GetFileDesc(), KKB::Tokenizer::GetNextTokens(), KKB::XmlTokenizer::GetNextTokens(), KKLSC::Variables::HomeDir(), KKB::Application::InitalizeApplication(), KKMLL::FeatureNumList::Load(), KKMLL::FeatureFileIOUCI::LoadFile(), KKMLL::FeatureFileIOC45::LoadFile(), KKMLL::FeatureFileIO::LoadInSubDirectoryTree(), KKMLL::TrainingConfiguration2::LoadOtherClasssExamples(), KKMLL::Orderings::Orderings(), KKB::osCreateDirectoryPath(), KKB::osCreateUniqueFileName(), KKB::osGetDirNameFromPath(), KKB::osGetListOfFilesInDirectoryTree(), KKB::osLookForFile(), osParseSearchSpec(), KKB::osValidFileNameErrors(), Parse(), KKMLL::ModelParam::ParseCmdLine(), KKMLL::ModelParamOldSVM::ParseCmdLine(), KKLSC::ScannerFileEntry::ParseTabDelStr(), SVM233::svm_parameter::ParseTabDelStr(), SVM289_BFS::svm_parameter::ParseTabDelStr(), SVM289_MFS::svm_parameter::ParseTabDelStr(), KKMLL::ClassAssignments::ParseToString(), KKMLL::MLClassList::PushOnBack(), KKMLL::MLClassList::PushOnFront(), KKMLL::ClassProbList::ReadXML(), KKMLL::TrainingConfiguration2::ReadXMLPost(), KKMLL::ModelDual::ReconcilePredictions(), KKMLL::Orderings::Save(), Split(), KKJobManagment::KKJobManager::StatusFileProcessLine(), SVM233::svm_parameter::svm_parameter(), KKMLL::ModelParamDual::ToCmdLineStr(), KKMLL::MLClassIndexList::ToCommaDelString(), KKMLL::FeatureNumList::ToString(), KKB::KKStrListIndexed::ToTabDelString(), ToVectorInt32(), KKB::RunLog::WriteLine(), KKMLL::ModelParamKnn::WriteXML(), KKMLL::AttributeTypeVector::WriteXML(), KKB::VectorKKStr::WriteXML(), KKMLL::ModelParamSvmBase::WriteXML(), KKMLL::ModelParamUsfCasCor::WriteXML(), KKMLL::ModelParamDual::WriteXML(), KKMLL::ModelKnn::WriteXML(), KKMLL::NormalizationParms::WriteXML(), KKMLL::ClassProbList::WriteXML(), KKMLL::FeatureEncoder::WriteXML(), KKMLL::ModelUsfCasCor::WriteXML(), KKB::BitString::WriteXML(), KKMLL::ModelSvmBase::WriteXML(), KKMLL::Attribute::WriteXML(), KKMLL::ModelParamOldSVM::WriteXML(), KKMLL::TrainingClassList::WriteXML(), KKMLL::MLClass::WriteXML(), KKMLL::AttributeList::WriteXML(), SVM233::SvmModel233::WriteXML(), KKMLL::ModelDual::WriteXML(), SVM289_MFS::Svm_Model::WriteXML(), KKMLL::FeatureNumList::WriteXML(), KKMLL::SVMparam::WriteXML(), KKMLL::FileDesc::WriteXML(), KKMLL::ModelOldSVM::WriteXML(), KKMLL::SVMModel::WriteXML(), KKMLL::TrainingProcess2::WriteXML(), KKMLL::TrainingConfiguration2::WriteXML(), KKMLL::MLClassList::WriteXML(), KKB::XmlElementBool::WriteXML(), KKMLL::MLClassIndexList::WriteXML(), KKB::XmlElementDateTime::WriteXML(), WriteXML(), KKMLL::XmlElementMLClassNameList::WriteXML(), KKB::XmlElementKeyValuePairs::WriteXML(), KKB::XmlElementArrayFloat2DVarying::WriteXML(), KKB::KKStrList::WriteXML(), KKB::KKStrListIndexed::WriteXML(), KKMLL::XmlElementMLClass::XmlElementMLClass(), and KKMLL::XmlElementMLClassNameList::XmlElementMLClassNameList().

241 {return (len <= 0);}
bool KKStr::EndsWith ( const KKStr value)

Definition at line 1190 of file KKStr.cpp.

References EndsWith().

1191 {
1192  return EndsWith (value, false);
1193 }
bool EndsWith(const KKStr &value)
Definition: KKStr.cpp:1190
bool KKStr::EndsWith ( const char *  value)

Definition at line 1197 of file KKStr.cpp.

References EndsWith().

1198 {
1199  return EndsWith (value, false);
1200 }
bool EndsWith(const KKStr &value)
Definition: KKStr.cpp:1190
bool KKStr::EndsWith ( const KKStr value,
bool  ignoreCase 
)

Definition at line 1204 of file KKStr.cpp.

References Len(), StrEqual(), and StrEqualNoCase().

Referenced by EndsWith().

1207 {
1208  if (value.len == 0)
1209  return true;
1210 
1211  kkint32 startPos = 1 + len - value.Len ();
1212  if (startPos < 0)
1213  return false;
1214 
1215  if (ignoreCase)
1216  return StrEqualNoCase (val + startPos, value.val);
1217  else
1218  return StrEqual (val + startPos, value.val);
1219 }
static bool StrEqualNoCase(const char *s1, const char *s2)
Definition: KKStr.cpp:408
__int32 kkint32
Definition: KKBaseTypes.h:88
static bool StrEqual(const char *s1, const char *s2)
Definition: KKStr.cpp:373
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
bool KKStr::EndsWith ( const char *  value,
bool  ignoreCase 
)

Definition at line 1223 of file KKStr.cpp.

References StrEqual(), and StrEqualNoCase().

Referenced by EndsWith().

1226 {
1227  if (value == NULL)
1228  return true;
1229 
1230  kkint32 valueLen = (kkint32)strlen (value);
1231 
1232  kkint32 startPos = 1 + len - valueLen;
1233  if (startPos < 0)
1234  return false;
1235 
1236  if (ignoreCase)
1237  return StrEqualNoCase (val + startPos, value);
1238  else
1239  return StrEqual (val + startPos, value);
1240 }
static bool StrEqualNoCase(const char *s1, const char *s2)
Definition: KKStr.cpp:408
__int32 kkint32
Definition: KKBaseTypes.h:88
static bool StrEqual(const char *s1, const char *s2)
Definition: KKStr.cpp:373
char KKStr::EnterStr ( )

Definition at line 2394 of file KKStr.cpp.

References KKB::STRCOPY().

2395 {
2396  kkint32 bp = 0;
2397  char buff[256];
2398  uchar ch;
2399 
2400  ch = (uchar)getchar ();
2401  if (ch == 10)
2402  ch = EnterChar;
2403 
2404  while ((ch != EnterChar) && (ch != EscapeChar))
2405  {
2406  if (ch == 8)
2407  {
2408  // Back Space
2409  if (bp > 0) {
2410  bp--;
2411  buff[bp] = 0;
2412  putchar (ch);
2413  }
2414  }
2415 
2416  else if (ch == 0)
2417  {
2418  // We have a control character.
2419  ch = (uchar)getchar ();
2420  }
2421 
2422  else
2423  {
2424  // putchar (ch);
2425  buff[bp] = ch;
2426  bp++;
2427  }
2428 
2429  ch = (uchar)getchar ();
2430  if (ch == 10)
2431  ch = EnterChar;
2432  }
2433 
2434  buff[bp] = 0;
2435 
2436  kkuint16 newLen = (kkuint16)strlen (buff);
2437 
2438  kkuint16 neededSpace = newLen + 1;
2439 
2440  if (neededSpace > allocatedSize)
2441  {
2442  delete [] val;
2443  val = NULL;
2444  AllocateStrSpace (neededSpace);
2445  }
2446 
2447  STRCOPY (val, allocatedSize, buff);
2448  len = newLen;
2449 
2450  return ch;
2451 } /* EnterStr */
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
char * STRCOPY(char *dest, kkint32 destSize, const char *src)
Definition: KKStr.cpp:46
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
#define EnterChar
Definition: KKStr.h:30
#define EscapeChar
Definition: KKStr.h:31
bool KKStr::EqualIgnoreCase ( const KKStr s2) const

Definition at line 1250 of file KKStr.cpp.

References CompareIgnoreCase().

Referenced by KKMLL::TrainingClassList::LocateByDirectory(), KKMLL::TrainingConfiguration2List::LookUp(), KKMLL::Classifier2List::LookUpByName(), KKB::Configuration::SettingList::LookUpLineNum(), KKLSC::ScannerFile::ScannerFileFormatFromStr(), and KKLSC::StartStopPoint::StartStopTypeFromStr().

1251 {
1252  return (CompareIgnoreCase (s2) == 0);
1253 } /* EqualIgnoreCase */
kkint32 CompareIgnoreCase(const KKStr &s2) const
Compares with another KKStr, ignoring case.
Definition: KKStr.cpp:919
bool KKStr::EqualIgnoreCase ( const KKStrConstPtr  s2) const

Definition at line 1244 of file KKStr.cpp.

References EqualIgnoreCase(), and Str().

Referenced by KKB::Configuration::SettingList::LookUp(), and KKB::Configuration::ConfSectionList::LookUp().

1245 {
1246  return EqualIgnoreCase (s2->Str ());
1247 }
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
bool KKStr::EqualIgnoreCase ( const char *  s2) const

Definition at line 1257 of file KKStr.cpp.

References StrCompareIgnoreCase().

Referenced by KKMLL::AttributeTypeFromStr(), EqualIgnoreCase(), KKMLL::FeatureNumList::ExtractFeatureNumsFromStr(), KKLSC::ScannerFile::ExtractHeaderField(), KKLSC::ScannerFile::GuessFormatOfFile(), SVM289_BFS::Kernel_Type_FromStr(), SVM289_MFS::Kernel_Type_FromStr(), KKMLL::FeatureFileIOC45::LoadFile(), KKLSC::ScannerFile::LoadIndexFile(), KKMLL::ModelParam::ModelParamTypeFromStr(), KKMLL::Model::ModelTypeFromStr(), KKB::MorphOp::OperationTypeFromStr(), KKMLL::ModelParam::ParseCmdLine(), KKLSC::ScannerFileEntry::ParseTabDelStr(), SVM289_BFS::svm_parameter::ParseTabDelStr(), SVM289_MFS::svm_parameter::ParseTabDelStr(), KKMLL::FeatureNumList::ParseToString(), KKMLL::ModelParamDual::ProbFusionMethodFromStr(), SVM289_BFS::svm_parameter::ProcessSvmParameter(), SVM289_MFS::svm_parameter::ProcessSvmParameter(), KKMLL::ModelParamKnn::ReadXML(), KKMLL::AttributeTypeVector::ReadXML(), KKMLL::ModelParamSvmBase::ReadXML(), KKMLL::ModelParamUsfCasCor::ReadXML(), KKMLL::ModelParamDual::ReadXML(), KKMLL::TrainingClass::ReadXML(), KKMLL::NormalizationParms::ReadXML(), KKMLL::FeatureEncoder::ReadXML(), KKMLL::ModelParamOldSVM::ReadXML(), SVM233::SvmModel233::ReadXML(), SVM289_MFS::Svm_Model::ReadXML(), KKMLL::FileDesc::ReadXML(), KKMLL::SVMparam::ReadXML(), KKMLL::ModelOldSVM::ReadXML(), KKMLL::SVMModel::ReadXML(), KKMLL::TrainingProcess2::ReadXML(), KKMLL::TrainingConfiguration2::ReadXMLBaseToken(), KKMLL::ModelParam::ReadXMLModelParamToken(), KKMLL::Model::ReadXMLModelToken(), KKB::SaveImageGrayscaleInverted4Bit(), KKB::SaveImageGrayscaleInverted8Bit(), KKJobManagment::KKJobManager::StatusFileProcessLine(), KKLSC::Variables::SubstituteInEnvironmentVariables(), SVM289_BFS::SVM_Type_FromStr(), SVM289_MFS::SVM_Type_FromStr(), and KKMLL::XmlElementMLClass::XmlElementMLClass().

1258 {
1259  return (StrCompareIgnoreCase (val, s2) == 0);
1260 } /* EqualIgnoreCase */
static kkint32 StrCompareIgnoreCase(const char *s1, const char *s2)
Definition: KKStr.cpp:318
char KKStr::ExtractChar ( )

Removes the first character from the string and returns it to the caller.

If the String is already empty it will return 0.

Definition at line 3197 of file KKStr.cpp.

3198 {
3199  #ifdef KKDEBUG
3200  ValidateLen ();
3201  #endif
3202 
3203  if (!val)
3204  return 0;
3205 
3206  if (len <= 0)
3207  return 0;
3208 
3209  char returnChar = val[0];
3210 
3211  kkuint16 newLen = len - 1;
3212 
3213  for (kkuint16 x = 0; x < newLen; x++)
3214  {
3215  val[x] = val[x + 1];
3216  }
3217 
3218  len = newLen;
3219  val[len] = 0;
3220 
3221  return returnChar;
3222 } /* ExtractChar */
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
char KKStr::ExtractLastChar ( )

Removes the last character from the string and returns it to the caller.

If the String is already empty it will return 0.summary> Extracts the next string token; if the string starts with a quote(") will extract until the terminating quote. Special control characters that are encoded with back-slashes such as carriage-return, line-feed, tab, quotes, etc will be decoded. It is the inverse of the QuotedStr or ToQuotedStr methods. /summary> param nqame='delChars'> List of acceptable delimiter characters.

param name='decodeEscapeCharacters'> Indicates if escape sequences should be decoded back to their original code.

returns>Token String

Definition at line 3226 of file KKStr.cpp.

3227 {
3228  #ifdef KKDEBUG
3229  ValidateLen ();
3230  #endif
3231 
3232  if ((!val) || (len < 1))
3233  return 0;
3234 
3235  --len;
3236 
3237  return val[len];
3238 } /* ExtractLastChar */
KKStr KKStr::ExtractQuotedStr ( const char *  delChars,
bool  decodeEscapeCharacters 
)

summary> Extract first Token from the string.

remarks> Removes first Token from string and returns it skipping over any leading delimiters. Tokens will be terminated by end of string or the first occurrence of a delimiter character. If no more tokens left will return a Empty KKStr. Note if you do not want to skip over leading delimiter characters the use 'ExtractToken2'. /remarks> param name='delStr'> List of delimiting characters.

returns> Extracted Token.

seealso cref='ExtractToken2'/>

Definition at line 3282 of file KKStr.cpp.

References Append(), Concat(), EmptyStr(), and KKStr().

Referenced by KKB::CmdLineExpander::CmdLineExpander(), and KKMLL::BinaryClassParms::CreateFromTabDelStr().

3285 {
3286  if ((!val) || (len == 0))
3287  return EmptyStr ();
3288 
3289  KKStr result (len);
3290  kkint32 idx = 0;
3291 
3292  bool lookForTerminatingQuote = false;
3293 
3294  if (val[idx] == '"')
3295  {
3296  lookForTerminatingQuote = true;
3297  idx++;
3298  }
3299 
3300 
3301  if (idx >= len)
3302  {
3303  delete [] val;
3304  val = NULL;
3305  AllocateStrSpace (1);
3306  return result;
3307  }
3308 
3309  // Search for matching terminating Quote
3310  while (idx < len)
3311  {
3312  if (lookForTerminatingQuote)
3313  {
3314  if (val[idx] == '"')
3315  {
3316  idx++;
3317  if (idx < len)
3318  {
3319  if (strchr (delChars, val[idx]))
3320  idx++;
3321  }
3322 
3323  break;
3324  }
3325  }
3326 
3327  else
3328  {
3329  if (strchr (delChars, val[idx]))
3330  {
3331  idx++;
3332  break;
3333  }
3334  }
3335 
3336  if ((val[idx] == '\\') && (decodeEscapeCharacters))
3337  {
3338  idx++;
3339  if (idx < len)
3340  {
3341  switch (val[idx])
3342  {
3343  case '"': result.Append ('"'); break;
3344  case 't': result.Append ('\t'); break;
3345  case 'n': result.Append ('\n'); break;
3346  case 'r': result.Append ('\r'); break;
3347  case '\\': result.Append ('\\'); break;
3348  case '0': result.Append (char (0)); break;
3349  case 0: break;
3350  default: result.Append (val[idx]); break;
3351  }
3352  idx++;
3353  }
3354  }
3355  else
3356  {
3357  result.Append (val[idx]);
3358  idx++;
3359  }
3360  }
3361 
3362  if (idx < len)
3363  {
3364  len = (kkuint16)(len - idx);
3365  memmove (val, &(val[idx]), len);
3366  val[len] = 0;
3367  }
3368  else
3369  {
3370  val[0] = 0;
3371  len = 0;
3372  }
3373 
3374  return result;
3375 } /* ExtractQuotedStr */
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
static const KKStr & EmptyStr()
Static method that returns an Empty String.
Definition: KKStr.cpp:3453
KKStr KKStr::ExtractToken ( const char *  delStr = "\n\t\r ")

Definition at line 2969 of file KKStr.cpp.

References Concat(), and operator=().

Referenced by KKMLL::FeatureFileIODstWeb::AttrDescLine::AttrDescLine(), KKB::DateType::DateType(), KKMLL::FeatureNumList::ExtractFeatureNumsFromStr(), KKMLL::MLClassList::ExtractThreeTitleLines(), GetClassNameByHierarchyLevel(), KKMLL::FeatureFileIOUCI::GetFileDesc(), KKMLL::FeatureFileIOSparse::GetFileDesc(), KKMLL::FeatureFileIODstWeb::LoadFile(), KKMLL::FeatureFileIOUCI::LoadFile(), KKB::osCreateDirectoryPath(), KKMLL::ModelParam::ParseCmdLine(), KKMLL::ModelParamOldSVM::ParseCmdLine(), KKMLL::ClassAssignments::ParseToString(), SVM233::svm_parameter::svm_parameter(), and KKB::TimeType::TimeType().

2970 {
2971  if (!val)
2972  return "";
2973 
2974 
2975  #ifdef KKDEBUG
2976  ValidateLen ();
2977  #endif
2978 
2979  KKStr token;
2980 
2981  char* tokenStart = val;
2982 
2983  // Skip leading Delimiters
2984  while ((*tokenStart != 0) && (strchr (delStr, *tokenStart)))
2985  tokenStart++;
2986 
2987  if (*tokenStart == 0)
2988  {
2989  delete [] val;
2990  val = NULL;
2991  AllocateStrSpace (1);
2992  return token;
2993  }
2994 
2995  char* tokenNext = tokenStart;
2996 
2997  while ((*tokenNext != 0) && (!strchr (delStr, *tokenNext)))
2998  tokenNext++;
2999 
3000  if (*tokenNext)
3001  {
3002  *tokenNext = 0;
3003  token = tokenStart;
3004 
3005  *tokenNext = ' ';
3006  tokenNext++;
3007 
3008  len = (kkuint16)strlen (tokenNext);
3009  memmove (val, tokenNext, len);
3010  val[len] = 0;
3011  }
3012 
3013  else
3014  {
3015  token = tokenStart;
3016  memset (val, 0, allocatedSize);
3017  len = 0;
3018  }
3019 
3020  return token;
3021 } /* ExtractToken */
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
KKStr KKStr::ExtractToken2 ( const char *  delStr = "\n\t\r ")

Extract first Token from the string.

Removes first Token from string and returns it. Unlike 'ExtractToken' it will not skip over leading delimiters. If the first character is a delimiter it will return a empty string. Tokens will be terminated by end of string or the first occurrence of a delimiter character. If no more tokens left will return a Empty KKStr.

Parameters
[in]delStrList of delimiting characters.
Returns
Extracted Token.
See also
ExtractToken
ExtractTokenInt
ExtractTokenDouble
ExtractTokenUint
ExtractTokenBool

Definition at line 3026 of file KKStr.cpp.

References Concat(), KKStr(), and operator=().

Referenced by KKMLL::ClassProbList::CreateFromXMLStream(), ExtractTokenBool(), ExtractTokenDouble(), ExtractTokenInt(), ExtractTokenUint(), ExtractTokenUint64(), KKLSC::ScannerFile::GuessFormatOfFile(), KKLSC::ScannerFile::LoadIndexFile(), Parse(), KKLSC::ScannerFileEntry::ParseTabDelStr(), KKLSC::StartStopPoint::ParseTabDelStr(), SVM233::svm_parameter::ParseTabDelStr(), SVM289_BFS::svm_parameter::ParseTabDelStr(), SVM289_MFS::svm_parameter::ParseTabDelStr(), KKLSC::ScannerFile::ReadHeader(), KKMLL::ModelDual::ReconcilePredictions(), KKLSC::ScannerFile::ReportTextMsg(), Split(), KKJobManagment::KKJobManager::StatusFileProcessLine(), and KKJobManagment::KKJobManager::StatusFileProcessLineJobStatusChange().

3027 {
3028  #ifdef KKDEBUG
3029  ValidateLen ();
3030  #endif
3031 
3032 
3033  if (!val)
3034  return KKStr ();
3035 
3036  KKStr token;
3037 
3038  char* tokenStart = val;
3039 
3040  // Skip Leading Blanks
3041  while ((*tokenStart != 0) && (*tokenStart == ' '))
3042  tokenStart++;
3043 
3044  if (*tokenStart == 0)
3045  {
3046  delete [] val;
3047  val = NULL;
3048  AllocateStrSpace (1);
3049  return token;
3050  }
3051 
3052  char* tokenNext = tokenStart;
3053 
3054  while ((*tokenNext != 0) && (!strchr (delStr, *tokenNext)))
3055  tokenNext++;
3056 
3057  // Remove trailing spaces
3058  char* tokenEnd = tokenNext;
3059  tokenEnd--;
3060  while ((tokenEnd != tokenStart) && ((*tokenEnd == ' ') || (*tokenEnd == '\n') || (*tokenEnd == '\r')))
3061  *tokenEnd = 0;
3062 
3063  if (*tokenNext)
3064  {
3065  *tokenNext = 0;
3066  token = tokenStart;
3067 
3068  *tokenNext = ' ';
3069  tokenNext++;
3070 
3071  len = (kkuint16)strlen (tokenNext);
3072  memmove (val, tokenNext, len);
3073  val[len] = 0;
3074  }
3075 
3076  else
3077  {
3078  token = tokenStart;
3079  memset (val, 0, allocatedSize);
3080  len = 0;
3081  }
3082 
3083  return token;
3084 } /* ExtractToken2 */
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
bool KKStr::ExtractTokenBool ( const char *  delStr)

Extract the next token from the string assuming that it is a logical True/False value.

This function calls 'ExtractToken2' and then returns true if the string that it extracted is equal to "Y", "Yes", "True", "T", or "1" otherwise false.

Parameters
[in]delStrList of delimiter characters.
Returns
'true' or 'false'.

Definition at line 3165 of file KKStr.cpp.

References Concat(), ExtractToken2(), operator==(), and Upper().

Referenced by KKMLL::ModelParam::ParseCmdLine().

3166 {
3167  KKStr workStr = ExtractToken2 (delStr);
3168  workStr.Upper ();
3169 
3170  return ((workStr == "YES") ||
3171  (workStr == "Y") ||
3172  (workStr == "TRUE") ||
3173  (workStr == "T") ||
3174  (workStr == "1")
3175  );
3176 } /* ExtractTokenBool */
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
void Upper()
Converts all characters in string to their Upper case equivalents via &#39;toupper&#39;.
Definition: KKStr.cpp:2461
double KKStr::ExtractTokenDouble ( const char *  delStr)

Definition at line 3180 of file KKStr.cpp.

References Concat(), ExtractToken2(), and Len().

Referenced by KKMLL::ClassProbList::CreateFromXMLStream(), KKLSC::ScannerFileEntry::ParseTabDelStr(), SVM233::svm_parameter::ParseTabDelStr(), SVM289_BFS::svm_parameter::ParseTabDelStr(), SVM289_MFS::svm_parameter::ParseTabDelStr(), and KKJobManagment::KKJobManager::StatusFileProcessLine().

3181 {
3182  #ifdef KKDEBUG
3183  ValidateLen ();
3184  #endif
3185 
3186  KKStr workStr = ExtractToken2 (delStr);
3187 
3188  if (workStr.Len () == 0)
3189  return 0.0;
3190 
3191  return atof (workStr.Str ());
3192 }
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
kkint32 KKStr::ExtractTokenInt ( const char *  delStr)

Definition at line 3129 of file KKStr.cpp.

References Concat(), and ExtractToken2().

Referenced by KKMLL::FeatureNumList::ExtractFeatureNumsFromStr(), KKB::PointList::FromDelStr(), KKLSC::ScannerFile::LoadIndexFile(), KKLSC::StartStopPoint::ParseTabDelStr(), SVM233::svm_parameter::ParseTabDelStr(), SVM289_BFS::svm_parameter::ParseTabDelStr(), SVM289_MFS::svm_parameter::ParseTabDelStr(), KKMLL::ClassAssignments::ParseToString(), KKB::ReadImagePGM(), KKLSC::ScannerFile::ReportTextMsg(), KKJobManagment::KKJobManager::StatusFileProcessLine(), and KKJobManagment::KKJobManager::StatusFileProcessLineJobStatusChange().

3130 {
3131  #ifdef KKDEBUG
3132  ValidateLen ();
3133  #endif
3134 
3135  KKStr workStr = ExtractToken2 (delStr);
3136  return atoi (workStr.Str ());
3137 }
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
kkuint32 KKStr::ExtractTokenUint ( const char *  delStr)

Definition at line 3141 of file KKStr.cpp.

References Concat(), and ExtractToken2().

Referenced by KKLSC::ScannerFile::LoadIndexFile(), KKLSC::ScannerFileEntry::ParseTabDelStr(), and KKLSC::ScannerFile::ReportTextMsg().

3142 {
3143  #ifdef KKDEBUG
3144  ValidateLen ();
3145  #endif
3146 
3147  KKStr workStr = ExtractToken2 (delStr);
3148  return (kkuint32)atol (workStr.Str ());
3149 }
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
KKB::kkuint64 KKStr::ExtractTokenUint64 ( const char *  delStr)

Definition at line 3153 of file KKStr.cpp.

References Concat(), ExtractToken2(), and ToUint64().

Referenced by KKLSC::ScannerFile::LoadIndexFile().

3154 {
3155  #ifdef KKDEBUG
3156  ValidateLen ();
3157  #endif
3158 
3159  KKStr workStr = ExtractToken2 (delStr);
3160  return workStr.ToUint64 ();
3161 }
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
kkuint64 ToUint64() const
Definition: KKStr.cpp:3660
kkint32 KKStr::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.

Todo:
Want to implement all the methods that the std::string class implements this way people who are familiar with the std::string class will find using this class easier.

param name='str'> String that you are searching for.

param name='pos'> The starting position to start the search from.

returns> The index where 'str' first occurs at or after 'pos' otherwise -1 if not found.

Definition at line 3931 of file KKStr.cpp.

References Len(), SearchStr(), and Str().

3932 {
3933  return SearchStr (val, len, pos, str.Str (), str.Len ());
3934 }
kkint32 SearchStr(const char *src, kkint32 srcLen, kkint32 startPos, const char *srchStr, kkint32 srchStrLen)
Definition: KKStr.cpp:3907
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
kkint32 KKStr::Find ( const char *  s,
kkint32  pos,
kkint32  n 
) const

Definition at line 3938 of file KKStr.cpp.

References SearchStr().

3939 {
3940  return SearchStr (val, len, pos, s, n);
3941 }
kkint32 SearchStr(const char *src, kkint32 srcLen, kkint32 startPos, const char *srchStr, kkint32 srchStrLen)
Definition: KKStr.cpp:3907
kkint32 KKStr::Find ( const char *  s,
kkint32  pos = 0 
) const

Definition at line 3945 of file KKStr.cpp.

Referenced by Contains().

3946 {
3947  return SearchStr (val, len, pos, s, (kkint32)strlen (s));
3948 }
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 SearchStr(const char *src, kkint32 srcLen, kkint32 startPos, const char *srchStr, kkint32 srchStrLen)
Definition: KKStr.cpp:3907
kkint32 KKStr::Find ( char  c,
kkint32  pos = 0 
) const

Definition at line 3952 of file KKStr.cpp.

Referenced by KKB::PointList::FromDelStr().

3953 {
3954  for (kkint32 x = pos; x < len; x++)
3955  {
3956  if (val[x] == c)
3957  return x;
3958  }
3959  return -1;
3960 }
__int32 kkint32
Definition: KKBaseTypes.h:88
char KKStr::FirstChar ( ) const
void KKStr::FreeUpUnUsedSpace ( )

Alloocated space s significanly larger than length of string will reallocate to free up unused space.

Definition at line 1980 of file KKStr.cpp.

References Concat(), KKB::KKException::KKException(), and KKStr().

1981 {
1982  kkuint32 unUsedSpace = allocatedSize - (len + 1);
1983  kkuint32 acceptableWaist = allocatedSize / 5;
1984  if (unUsedSpace > acceptableWaist)
1985  {
1986  kkuint32 neededSpace = len + 1;
1987  char* newVal = new char[neededSpace];
1988  if (newVal == NULL)
1989  {
1990  KKStr errMsg(128);
1991  errMsg << "KKStr::FreeUpUnUsedSpace ***ERROR*** Allocation of NeededSpace[" << neededSpace << "] characters failed.";
1992  cerr << endl << errMsg << endl << endl;
1993  throw KKException(errMsg);
1994  }
1995 
1996  memcpy(newVal, val, len);
1997  newVal[len] = 0;
1998  delete[] val;
1999  val = newVal;
2000  allocatedSize = (kkuint16)neededSpace;
2001  }
2002 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
KKStr KKStr::GetNextToken2 ( const char *  delStr = "\n\t\r ") const

Retrieves the first token in the string without removing any characters.

Similar to 'ExtractToken2' except it does not remove characters from the string.

Returns
The first token in the string.

Definition at line 3089 of file KKStr.cpp.

References SubStrPart().

3090 {
3091  #ifdef KKDEBUG
3092  ValidateLen ();
3093  #endif
3094 
3095  if (!val)
3096  return "";
3097 
3098  kkint32 startCharPos = 0;
3099 
3100  while (startCharPos < len)
3101  {
3102  if (val[startCharPos] != ' ')
3103  break;
3104  startCharPos++;
3105  }
3106 
3107  if (startCharPos >= len)
3108  return "";
3109 
3110  kkint32 lastCharPos = startCharPos;
3111 
3112  while (lastCharPos < len)
3113  {
3114  if (strchr (delStr, val[lastCharPos]) != NULL)
3115  {
3116  // We just found the first delimiter
3117  lastCharPos--;
3118  return SubStrPart (startCharPos, lastCharPos);
3119  }
3120  lastCharPos++;
3121  }
3122 
3123  return SubStrPart (startCharPos);
3124 } /* GetNextToken2 */
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr SubStrPart(kkint32 firstChar) const
returns a SubString consisting of all characters starting at index &#39;firstChar&#39; until the end of the s...
Definition: KKStr.cpp:2780
kkint32 KKStr::InstancesOfChar ( char  ch) const

Returns the number of instances of 'ch' in the string.

Definition at line 2041 of file KKStr.cpp.

Referenced by KKMLL::MLClass::NumHierarchialLevels().

2042 {
2043  #ifdef KKDEBUG
2044  ValidateLen ();
2045  #endif
2046 
2047  if (val == NULL)
2048  return 0;
2049 
2050  kkint32 count = 0;
2051 
2052  for (kkuint16 x = 0; x < len; x++)
2053  {
2054  if (val[x] == ch)
2055  count++;
2056  }
2057 
2058  return count;
2059 } /* InstancesOfChar */
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
char KKStr::LastChar ( ) const

Returns the last character in the string but if the string is empty returns 0.

Definition at line 2007 of file KKStr.cpp.

Referenced by KKMLL::FeatureFileIODstWeb::AttrDescLine::AttrDescLine(), KKMLL::FeatureFileIOC45::GetFileDesc(), KKMLL::FeatureFileIODstWeb::LoadFile(), KKB::osAddLastSlash(), KKB::osAddSlash(), KKB::osCreateDirectoryPath(), KKB::osGetDirNameFromPath(), KKB::osGetFileNamePartOfFile(), KKB::osGetListOfDirectories(), KKB::osGetParentDirectoryOfDirPath(), KKB::osGetParentDirPath(), KKB::osGetRootNameOfDirectory(), KKB::osMoveFileBetweenDirectories(), KKB::osParseFileSpec(), and ToPercentage().

2008 {
2009  if (!val)
2010  return 0;
2011 
2012  if (val[0] == 0)
2013  return 0;
2014  else
2015  return val[len - 1];
2016 } /* LastChar */
void KKStr::LeftPad ( kkint32  width,
uchar  ch = ' ' 
)

pads the string with enough 'ch' characters on the left side until the string is as long as 'width' characters.

if 'width' is less than the current length of the string then the string will have characters removed the beginning until its 'len' equals 'width'.

Todo:
Need to properly debug through 'KKStr::LeftPad;

Definition at line 2303 of file KKStr.cpp.

References Concat(), KKB::KKException::KKException(), and KKStr().

Referenced by KKMLL::MLClassList::ExtractThreeTitleLines(), KKMLL::ConfusionMatrix2::PrintConfusionMatrixNarrow(), KKMLL::SizeDistribution::ClassTotals::PrintFormatedLine(), and Wide().

2306 {
2307  #ifdef KKDEBUG
2308  ValidateLen ();
2309  #endif
2310 
2311  if (width < 0)
2312  {
2313  cerr << std::endl;
2314  cerr << "KKStr::LeftPad (kkint32 width, char ch) **** ERROR ****" << std::endl;
2315  cerr << " width[" << width << "] invalid." << std::endl;
2316  cerr << std::endl;
2317  width = 0;
2318  }
2319 
2320  kkuint32 neededSpace = (kkuint32)width + 1;
2321  if (neededSpace >= KKStrIntMax)
2322  {
2323  KKStr errMsg(128);
2324  errMsg << "KKStr::LeftPad ***ERROR*** Size of buffer can not fit into String; neededSpace[" << neededSpace << "].";
2325  cerr << std::endl << errMsg << endl << endl;
2326  throw KKException(errMsg);
2327  }
2328 
2329  if (!val)
2330  {
2331  len = 0;
2332  allocatedSize = 0;
2333  }
2334 
2335  if (neededSpace > allocatedSize)
2336  {
2337  GrowAllocatedStrSpace(neededSpace);
2338  }
2339 
2340  if (val == NULL)
2341  {
2342  KKStr errMsg(128);
2343  errMsg << "KKStr::LeftPad ***ERROR*** val == NULL; couuld not allocate neededSpace[" << neededSpace << "].";
2344  cerr << std::endl << errMsg << endl << endl;
2345  throw KKException(errMsg);
2346  }
2347 
2348 
2349  if (len >= (kkuint16)width)
2350  {
2351  // 2010-04-20
2352  // This code has never been debugged. So the first time we run it
2353  // we want to make sure that it is doing what I say it is doing.
2354  /** @todo Need to properly debug through 'KKStr::LeftPad; */
2355  kkuint16 toIdx = 0;
2356  kkuint16 fromIdx = len - (kkuint16)width;
2357  while (fromIdx < len)
2358  {
2359  val[toIdx] = val[fromIdx];
2360  val[fromIdx] = 0;
2361  ++toIdx;
2362  ++fromIdx;
2363  }
2364  len = (kkuint16)width;
2365  val[len] = 0;
2366  }
2367  else
2368  {
2369  kkint32 fromIdx = len - 1;
2370  kkint32 toIdx = width - 1;
2371  while (fromIdx >= 0)
2372  {
2373  val[toIdx] = val[fromIdx];
2374  --fromIdx;
2375  --toIdx;
2376  }
2377 
2378  while (toIdx >= 0)
2379  {
2380  val[toIdx] = ch;
2381  --toIdx;
2382  }
2383 
2384  len = (kkuint16)width;
2385  val[len] = 0;
2386  }
2387  return;
2388 } /* LeftPad */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
kkint32 KKStr::LocateCharacter ( char  ch) const

Returns index of 1st occurrence of 'ch' otherwise -1.

Definition at line 2021 of file KKStr.cpp.

Referenced by KKMLL::FeatureNumList::ExtractFeatureNumsFromStr(), KKMLL::MLClassList::ExtractTwoTitleLines(), KKMLL::FeatureFileIODstWeb::GetFileDesc(), KKB::osGetFileNamePartOfFile(), KKB::osGetListOfDirectories(), KKB::osLocateFirstSlashChar(), KKB::osParseFileSpec(), KKB::osSubstituteInEnvironmentVariables(), KKLSC::Variables::SubstituteInEnvironmentVariables(), ToLatitude(), ToLongitude(), and ToVectorInt32().

2022 {
2023  if (!val)
2024  return -1;
2025 
2026  kkint32 idx = 0;
2027 
2028  while (idx < len)
2029  {
2030  if (val[idx] == ch)
2031  return idx;
2032  idx++;
2033  }
2034 
2035  return -1;
2036 } /* LocateCharacter */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 KKStr::LocateLastOccurrence ( char  ch) const

Returns index of last occurrence of 'ch' otherwise -1.

Returns the position of the last occurrence of the character 'ch'.

A return of -1 indicates that there is no occurrence of 'ch' in the string.

Definition at line 2118 of file KKStr.cpp.

Referenced by KKMLL::DuplicateImage::ExampleWithSmallestScanLine(), KKMLL::MLClass::GetClassNameFromDirName(), KKMLL::FeatureFileIOC45::LoadFeatureFile(), KKB::osGetParentDirectoryOfDirPath(), KKB::osGetParentDirPath(), KKB::osGetPathPartOfFile(), KKB::osGetRootName(), KKB::osGetRootNameOfDirectory(), KKB::osGetRootNameWithExtension(), KKB::osLocateLastSlashChar(), KKB::osParseFileName(), KKB::osParseFileSpec(), and KKB::osRemoveExtension().

2119 {
2120  #ifdef KKDEBUG
2121  ValidateLen ();
2122  #endif
2123 
2124  if (!val)
2125  return -1;
2126 
2127  bool found = false;
2128  kkint32 idx = len - 1;
2129 
2130  while ((idx >= 0) && (!found))
2131  {
2132  if (val[idx] == ch)
2133  found = true;
2134  else
2135  idx--;
2136  }
2137 
2138  if (found)
2139  return idx;
2140  else
2141  return -1;
2142 } /* LocateLastOccurrence */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 KKStr::LocateLastOccurrence ( const KKStr s) const

Returns index of last occurrence of 's' otherwise -1.

Returns the position of the last occurrence of the string 's'.

A return of -1 indicates that there is no occurrence of 's' in the string.

Definition at line 2151 of file KKStr.cpp.

References Len().

2152 {
2153  kkint32 sLen = s.Len ();
2154 
2155  if ((!val) || (!s.val) || (sLen <= 0) || (sLen > len))
2156  return -1;
2157 
2158  bool found = false;
2159  kkint32 idx = len - sLen;
2160 
2161  char* sVal = s.val;
2162 
2163  while ((idx >= 0) && (!found))
2164  {
2165  if (strncmp (val + idx, sVal, sLen) == 0)
2166  found = true;
2167  else
2168  idx--;
2169  }
2170 
2171  if (found)
2172  return idx;
2173  else
2174  return -1;
2175 } /* LocateLastOccurrence */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
kkint32 KKStr::LocateNthOccurrence ( char  ch,
kkint32  x 
) const

Definition at line 2179 of file KKStr.cpp.

2180 {
2181  if (!val)
2182  return -1;
2183 
2184  kkint32 numInstances = 0;
2185  kkint32 x = 0;
2186  while ((x < len) && (numInstances < n))
2187  {
2188  if (val[x] == ch)
2189  ++numInstances;
2190  ++x;
2191  }
2192 
2193  if (numInstances < n)
2194  return -1;
2195  else
2196  return (x - 1);
2197 }
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 KKStr::LocateStr ( const KKStr searchStr) const

Returns index of 1st occurrence of 'searchStr' otherwise -1.

returns the position of the 1st occurrence of the string 'searchStr'.

A return of -1 indicates that there is no occurrence of 'searchStr' in the string.

Definition at line 2091 of file KKStr.cpp.

References MemCompare().

2092 {
2093  if ((!val) || (!(searchStr.val)))
2094  return -1;
2095 
2096  kkint32 idx = 0;
2097 
2098  kkint32 lastIdx = len - searchStr.len;
2099 
2100  while (idx <= lastIdx)
2101  {
2102  if (MemCompare (val, searchStr.val, idx, 0, searchStr.len) == 0)
2103  return idx;
2104  idx++;
2105  }
2106 
2107  return -1;
2108 }; // LocateStr
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 MemCompare(const char *s1, const char *s2, kkint32 s1Idx, kkint32 s2Idx, kkint32 len)
Definition: KKStr.cpp:2063
void KKStr::LopOff ( kkint32  lastCharPos)

Trims off all characters after the 'lastCharPos' index; to make an empty string you would have to specify -1.

Remove characters from the end of the string.

Removes characters from end of string starting at position 'lastCharPos'. If 'lastCharPos' is greater than length of string will do nothing. If 'lastCharPos' is less than or equal to '0' will delete all characters from string.

Parameters
[in]lastCharPosWill remove all characters starting at 'lastCharPos' from end of string.

Definition at line 2866 of file KKStr.cpp.

2867 {
2868  #ifdef KKDEBUG
2869  ValidateLen ();
2870  #endif
2871 
2872  if (lastCharPos >= len)
2873  return;
2874 
2875  if (lastCharPos < -1)
2876  lastCharPos = -1;
2877 
2878  kkuint16 newLen = (kkuint16)(lastCharPos + 1);
2879  while (len > newLen)
2880  {
2881  len--;
2882  val[len] = 0;
2883  }
2884 } /* LoppOff */
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
void KKStr::Lower ( )

Make all characters in the String into lower case.

Converts all characters in string to their Lower case equivalents via 'tolower'.

See also
ToLower

Definition at line 2482 of file KKStr.cpp.

Referenced by ToLower().

2483 {
2484  #ifdef KKDEBUG
2485  ValidateLen ();
2486  #endif
2487 
2488  if (!val)
2489  return;
2490 
2491  kkuint32 x;
2492 
2493  for (x = 0; x < len; x++)
2494  val[x] = (uchar)tolower (val[x]);
2495 } /* Lower */
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
KKStr KKStr::MaxLen ( kkuint32  maxLen) const

Returns a string that will not be longer that 'maxLen'; any chracters beyond that length will be chopped off.

Definition at line 2499 of file KKStr.cpp.

References SubStrPart().

2500 {
2501  maxLen = Max ((kkuint32)0, maxLen);
2502  if (len < maxLen)
2503  return *this;
2504  else
2505  return SubStrPart (0, maxLen - 1);
2506 }
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
T Max(T a, T b)
generic Max function, Both parameters must be of the same type.
Definition: KKBaseTypes.h:181
KKStr SubStrPart(kkint32 firstChar) const
returns a SubString consisting of all characters starting at index &#39;firstChar&#39; until the end of the s...
Definition: KKStr.cpp:2780
kkuint32 KKStr::MaxLenSupported ( ) const

Returns the maximum String Length that this string can support.

Definition at line 2510 of file KKStr.cpp.

Referenced by KKB::osReadRestOfLine(), and RightPad().

2511 {
2512  return KKStrIntMax - 1;
2513 }
void KKStr::MemCpy ( void *  dest,
void *  src,
kkuint32  size 
)
static

Definition at line 4338 of file KKStr.cpp.

4342 {
4343 
4344  if (dest == NULL)
4345  {
4346  cerr << endl << "KKStr::MemCpy ***ERROR*** (dest == NULL)" << endl << endl;
4347  }
4348 
4349  else if (src == NULL)
4350  {
4351  cerr << endl << "KKStr::MemCpy ***ERROR*** (src == NULL)" << endl << endl;
4352  }
4353 
4354  else
4355  {
4356  memcpy (dest, src, size);
4357  }
4358 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
void KKStr::MemSet ( void *  dest,
kkuint8  byte,
kkuint32  size 
)
static

Definition at line 4362 of file KKStr.cpp.

4363 {
4364  if (dest == NULL)
4365  {
4366  cerr << "KKStr::MemSet ***ERROR*** (dest == NULL)" << endl;
4367  return;
4368  }
4369 
4370  memset (dest, byte, size);
4371 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
bool KKStr::operator!= ( const KKStr right) const
bool KKStr::operator!= ( KKStrConstPtr  right) const

Definition at line 1577 of file KKStr.cpp.

References Compare().

1578 {
1579  if (!right)
1580  return true;
1581 
1582  return (Compare (*right) != 0);
1583 }
kkint32 Compare(const KKStr &s2) const
Definition: KKStr.cpp:844
bool KKStr::operator!= ( const char *  rtStr) const

Definition at line 1596 of file KKStr.cpp.

References StrEqual().

Referenced by KKMLL::FeatureFileIODstWeb::GetFileDesc(), KKMLL::FeatureFileIOUCI::GetFileDesc(), and KKMLL::FeatureFileIOUCI::LoadFile().

1597 {
1598  return (!StrEqual (val, rtStr));
1599 }
static bool StrEqual(const char *s1, const char *s2)
Definition: KKStr.cpp:373
bool KKStr::operator!= ( const std::string  right) const

Definition at line 1611 of file KKStr.cpp.

1612 {
1613  return (Compare (right) != 0);
1614 }
kkint32 Compare(const KKStr &s2) const
Definition: KKStr.cpp:844
KKStr KKStr::operator+ ( const char *  right) const

Definition at line 3986 of file KKStr.cpp.

References Append(), Concat(), and KKStr().

Referenced by KKB::BmpImage::BlueRow(), KKB::Application::BuildDate(), KKMLL::ClassificationBiasMatrix::ClassificationBiasMatrix(), KKLSC::Variables::ConfigurationDir(), KKMLL::Model::CreateAModel(), KKMLL::FeatureEncoder2::CreateEncodedFileDesc(), KKMLL::FeatureEncoder::CreateEncodedFileDesc(), KKMLL::TrainingConfiguration2::CreateFromDirectoryStructure(), KKMLL::Orderings::CreateOrderingsObjFromFileIfAvaliable(), KKB::DateTime::DateTime(), KKMLL::ModelSvmBase::Description(), KKMLL::ModelOldSVM::Description(), KKMLL::ModelDual::Description(), KKMLL::Model::Description(), KKB::GoalKeeperSimple::EndBlock(), KKB::GoalKeeper::EndBlock(), KKB::Raster::ExtractChannel(), KKMLL::FeatureFileIO::FeatureDataReSink(), KKMLL::FeatureEncoder::FeatureEncoder(), KKMLL::TrainingConfiguration2::GetEffectiveConfigFileName(), KKB::TimeType::HH_MM_SS(), KKB::DateTime::HH_MM_SS(), KKB::BmpImage::ImageRow(), KKStr(), KKMLL::TrainingProcess2::LoadExistingTrainingProcess(), KKMLL::FeatureFileIOC45::LoadFeatureFile(), KKMLL::FeatureFileIODstWeb::LoadFile(), KKMLL::FeatureFileIOColumn::LoadFile(), KKMLL::FeatureFileIOUCI::LoadFile(), KKMLL::FeatureFileIOC45::LoadFile(), KKLSC::ScannerFile::LoadIndexFile(), KKMLL::FeatureFileIO::LoadInSubDirectoryTree(), KKMLL::TrainingConfiguration2::LoadOtherClasssExamples(), KKLSC::ScannerFile::Open(), KKB::operator<<(), KKMLL::Orderings::Orderings(), KKB::osCreateUniqueFileName(), KKB::osGetDirNameFromPath(), KKB::osGetListOfFilesInDirectoryTree(), KKB::osSubstituteInEnvironmentVariables(), KKMLL::ConfusionMatrix2::PrintAccuracyByProbByClassHTML(), KKMLL::ClassProbList::PushOnBack(), KKMLL::ClassProbList::PushOnFront(), KKB::BmpImage::RedRow(), RightPad(), KKB::BmpImage::Save(), KKMLL::FeatureFileIORoberts::SaveFile(), KKB::BmpImage::SaveGrayscaleInverted4Bit(), KKB::BmpImage::SaveGrayscaleInverted8Bit(), KKB::SaveImage(), KKB::SaveImageGrayscaleInverted4Bit(), KKB::SaveImageGrayscaleInverted8Bit(), KKB::SaveImagePNG(), KKB::SaveImagePPM(), KKLSC::ScannerFile::SaveIndexFile(), KKMLL::TrainingProcess2::SaveTrainingProcess(), KKLSC::Variables::ScannerFilesDefaultDir(), KKB::Raster::SegmentImage(), StrReplace(), KKMLL::KKMLVariables::TempDir(), KKMLL::ModelParamKnn::ToCmdLineStr(), KKMLL::ModelParamSvmBase::ToCmdLineStr(), KKB::PixelValue::ToStr(), KKB::tqli(), KKMLL::KKMLVariables::TrainingLibrariesDir(), KKMLL::KKMLVariables::TrainingModelsDir(), KKMLL::ModelSvmBase::TrainModel(), KKMLL::ModelDual::TrainModel(), KKB::Tred2(), and KKB::DateTime::YYYY_MM_DD_HH_MM_SS().

3987 {
3988  kkint32 resultStrLen = len + (kkint32)strlen (right);
3989  KKStr result (resultStrLen + 1);
3990  result.Append (*this);
3991  result.Append (right);
3992  return result;
3993 }
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr KKStr::operator+ ( const KKStr right) const

Definition at line 3998 of file KKStr.cpp.

References Append(), Concat(), and KKStr().

Referenced by KKB::BmpImage::BlueRow(), KKB::Application::BuildDate(), KKMLL::FeatureEncoder2::CreateEncodedFileDesc(), KKMLL::FeatureEncoder::CreateEncodedFileDesc(), KKMLL::TrainingConfiguration2::CreateFromDirectoryStructure(), KKB::DateTime::DateTime(), KKMLL::ModelDual::Description(), KKMLL::Model::Description(), KKMLL::TrainingClass::ExpandedDirectory(), KKMLL::FeatureFileIO::FeatureDataReSink(), KKMLL::FeatureEncoder::FeatureEncoder(), KKMLL::TrainingConfiguration2::GetEffectiveConfigFileName(), KKB::TimeType::HH_MM_SS(), KKB::DateTime::HH_MM_SS(), KKB::TimeType::HHMMSS(), KKB::BmpImage::ImageRow(), KKMLL::FeatureFileIOColumn::LoadFile(), KKMLL::FeatureFileIOUCI::LoadFile(), KKMLL::FeatureFileIOC45::LoadFile(), KKMLL::FeatureFileIO::LoadInSubDirectoryTree(), KKMLL::TrainingConfiguration2::LoadOtherClasssExamples(), KKB::operator+(), KKB::operator<<(), KKB::osCreateUniqueFileName(), KKB::osGetDirNameFromPath(), KKB::osGetListOfFilesInDirectoryTree(), KKB::osLookForFile(), KKB::osSubstituteInEnvironmentVariables(), KKB::BmpImage::RedRow(), KKB::Raster::SegmentImage(), KKLSC::Variables::SubstituteInEnvironmentVariables(), KKMLL::ModelParamKnn::ToCmdLineStr(), KKMLL::ModelParamSvmBase::ToCmdLineStr(), KKB::PixelValue::ToStr(), KKB::DateTime::YYYY_MM_DD_HH_MM_SS(), and KKB::DateTime::YYYYMMDDHHMMSS().

3999 {
4000  kkint32 resultStrLen = len + right.len;
4001 
4002  KKStr result (resultStrLen + 1);
4003  result.Append (*this);
4004  result.Append (right);
4005  return result;
4006 }
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr KKStr::operator+ ( kkint16  right) const

Definition at line 4010 of file KKStr.cpp.

References Append(), Concat(), KKStr(), and KKB::SPRINTF().

4011 {
4012  char buff[60];
4013  SPRINTF (buff, sizeof (buff), "%-ld", right);
4014  kkint32 resultStrLen = len + (kkint32)strlen (buff);
4015  KKStr result (resultStrLen + 1);
4016  result.Append (*this);
4017  result.Append (buff);
4018  return result;
4019 }
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr KKStr::operator+ ( kkuint16  right) const

Definition at line 4022 of file KKStr.cpp.

References Append(), Concat(), KKStr(), and KKB::SPRINTF().

4023 {
4024  char buff[30];
4025  SPRINTF (buff, sizeof (buff), "%u", right);
4026 
4027  kkint32 resultStrLen = len + (kkint32)strlen (buff);
4028  KKStr result (resultStrLen + 1);
4029  result.Append (*this);
4030  result.Append (buff);
4031  return result;
4032 }
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr KKStr::operator+ ( kkint32  right) const

Definition at line 4036 of file KKStr.cpp.

References Append(), Concat(), KKStr(), and KKB::SPRINTF().

Referenced by KKB::GoalKeeperSimple::EndBlock(), and KKB::GoalKeeper::EndBlock().

4037 {
4038  char buff[60];
4039  SPRINTF (buff, sizeof (buff), "%-ld", right);
4040 
4041  kkint32 resultStrLen = len + (kkint32)strlen (buff);
4042  KKStr result (resultStrLen + 1);
4043  result.Append (*this);
4044  result.Append (buff);
4045  return result;
4046 }
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr KKStr::operator+ ( kkuint32  right) const

Definition at line 4050 of file KKStr.cpp.

References Append(), Concat(), KKStr(), and KKB::SPRINTF().

4051 {
4052  char buff[30];
4053  SPRINTF (buff, sizeof (buff), "%u", right);
4054 
4055  kkint32 resultStrLen = len + (kkint32)strlen (buff);
4056  KKStr result (resultStrLen + 1);
4057  result.Append (*this);
4058  result.Append (buff);
4059  return result;
4060 }
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr KKStr::operator+ ( kkint64  right) const

Definition at line 4064 of file KKStr.cpp.

References Append(), Concat(), KKStr(), and KKB::SPRINTF().

4065 {
4066  char buff[70];
4067  SPRINTF (buff, sizeof (buff), "%-lld", right);
4068 
4069  kkint32 resultStrLen = len + (kkint32)strlen (buff);
4070  KKStr result (resultStrLen + 1);
4071  result.Append (*this);
4072  result.Append (buff);
4073  return result;
4074 }
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr KKStr::operator+ ( kkuint64  right) const

Definition at line 4078 of file KKStr.cpp.

References Append(), Concat(), KKStr(), and KKB::SPRINTF().

4079 {
4080  char buff[70];
4081  SPRINTF (buff, sizeof (buff), "%-llu", right);
4082 
4083  kkint32 resultStrLen = len + (kkint32)strlen (buff);
4084  KKStr result (resultStrLen + 1);
4085  result.Append (*this);
4086  result.Append (buff);
4087  return result;
4088 }
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr KKStr::operator+ ( float  right) const

Definition at line 4092 of file KKStr.cpp.

References Append(), Concat(), KKStr(), and KKB::SPRINTF().

4093 {
4094  char buff[60];
4095 
4096  SPRINTF (buff, sizeof (buff), "%.9g", right);
4097 
4098  kkint32 resultStrLen = len + (kkint32)strlen (buff);
4099  KKStr result (resultStrLen + 1);
4100  result.Append (*this);
4101  result.Append (buff);
4102  return result;
4103 }
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr KKStr::operator+ ( double  right) const

Definition at line 4107 of file KKStr.cpp.

References Append(), Concat(), KKStr(), and KKB::SPRINTF().

4108 {
4109  char buff[60];
4110  SPRINTF (buff, sizeof (buff), "%.17g", right);
4111 
4112  kkint32 resultStrLen = len + (kkint32)strlen (buff);
4113  KKStr result (resultStrLen + 1);
4114  result.Append (*this);
4115  result.Append (buff);
4116  return result;
4117 }
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr& KKB::KKStr::operator+= ( const char *  right)
inline

Definition at line 681 of file KKStr.h.

681 {return *this << right;}
KKStr& KKB::KKStr::operator+= ( const KKStr right)
inline

Definition at line 682 of file KKStr.h.

Referenced by KKMLL::ModelDual::ReconcilePredictions().

682 {return *this << right;}
KKStr& KKB::KKStr::operator+= ( kkint16  right)
inline

Definition at line 683 of file KKStr.h.

683 {return *this << right;}
KKStr& KKB::KKStr::operator+= ( kkuint16  right)
inline

Definition at line 684 of file KKStr.h.

684 {return *this << right;}
KKStr& KKB::KKStr::operator+= ( kkint32  right)
inline

Definition at line 685 of file KKStr.h.

685 {return *this << right;}
KKStr& KKB::KKStr::operator+= ( kkuint32  right)
inline

Definition at line 686 of file KKStr.h.

686 {return *this << right;}
KKStr& KKB::KKStr::operator+= ( kkint64  right)
inline

Definition at line 687 of file KKStr.h.

687 {return *this << right;}
KKStr& KKB::KKStr::operator+= ( kkuint64  right)
inline

Definition at line 688 of file KKStr.h.

688 {return *this << right;}
KKStr& KKB::KKStr::operator+= ( float  right)
inline

Definition at line 689 of file KKStr.h.

689 {return *this << right;}
KKStr& KKB::KKStr::operator+= ( double  right)
inline

Definition at line 690 of file KKStr.h.

690 {return *this << right;}
KKStr & KKStr::operator<< ( const char *  right)

Definition at line 4129 of file KKStr.cpp.

References Append(), and KKB::KKException::KKException().

4130 {
4131  if (!right)
4132  {
4133  const char* msg = "KKStr& operator<<(const char* right) **** ERROR **** right==NULL";
4134  cerr << std::endl << msg << std::endl << std::endl;
4135  throw KKException (msg);
4136  }
4137 
4138  Append (right);
4139  return *this;
4140 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
void Append(const char *buff)
Definition: KKStr.cpp:1783
KKStr & KKStr::operator<< ( const KKStr right)

Definition at line 4144 of file KKStr.cpp.

References Append(), and Str().

4145 {
4146  Append (right.Str ());
4147  return *this;
4148 }
void Append(const char *buff)
Definition: KKStr.cpp:1783
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
KKStr & KKStr::operator<< ( KKStr &&  right)

Definition at line 4151 of file KKStr.cpp.

References Append(), and Str().

4152 {
4153  if (len < 1)
4154  {
4155  val = right.val;
4156  len = right.len;
4157  allocatedSize = right.allocatedSize;
4158 
4159  right.val = NULL;
4160  right.len = 0;
4161  right.allocatedSize = 0;
4162  }
4163  else
4164  {
4165  Append (right.Str ());
4166  }
4167 
4168  return *this;
4169 }
void Append(const char *buff)
Definition: KKStr.cpp:1783
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
KKStr & KKStr::operator<< ( char  right)

Definition at line 4121 of file KKStr.cpp.

References Append().

4122 {
4123  Append (right);
4124  return *this;
4125 }
void Append(const char *buff)
Definition: KKStr.cpp:1783
KKStr & KKStr::operator<< ( kkint16  right)

Definition at line 4174 of file KKStr.cpp.

References AppendInt32().

4175 {
4176  AppendInt32 (right);
4177  return *this;
4178 }
void AppendInt32(kkint32 i)
Definition: KKStr.cpp:1901
KKStr & KKStr::operator<< ( kkuint16  right)

Definition at line 4182 of file KKStr.cpp.

References AppendUInt32().

4183 {
4184  AppendUInt32 (right);
4185  return *this;
4186 }
void AppendUInt32(kkuint32 i)
Definition: KKStr.cpp:1940
KKStr & KKStr::operator<< ( kkint32  right)

Definition at line 4190 of file KKStr.cpp.

References AppendInt32().

4191 {
4192  AppendInt32 (right);
4193  return *this;
4194 }
void AppendInt32(kkint32 i)
Definition: KKStr.cpp:1901
KKStr & KKStr::operator<< ( kkuint32  right)

Definition at line 4198 of file KKStr.cpp.

References AppendUInt32().

4199 {
4200  AppendUInt32 (right);
4201  return *this;
4202 }
void AppendUInt32(kkuint32 i)
Definition: KKStr.cpp:1940
KKStr & KKStr::operator<< ( kkint64  right)

Definition at line 4206 of file KKStr.cpp.

References Append(), Concat(), KKStr(), operator=(), Str(), and KKB::StrFormatInt64().

4207 {
4208  KKStr s (30);
4209  s = StrFormatInt64 (right, "0");
4210  Append (s.Str ());
4211  return *this;
4212 }
KKStr StrFormatInt64(kkint64 val, const char *mask)
Definition: KKStr.cpp:5013
void Append(const char *buff)
Definition: KKStr.cpp:1783
KKStr & KKStr::operator<< ( kkuint64  right)

Definition at line 4216 of file KKStr.cpp.

References Append(), Concat(), KKStr(), operator=(), Str(), and KKB::StrFormatInt64().

4217 {
4218  KKStr s (30);
4219  s = StrFormatInt64 (right, "0");
4220  Append (s.Str ());
4221  return *this;
4222 }
KKStr StrFormatInt64(kkint64 val, const char *mask)
Definition: KKStr.cpp:5013
void Append(const char *buff)
Definition: KKStr.cpp:1783
KKStr & KKStr::operator<< ( float  right)

Definition at line 4226 of file KKStr.cpp.

References Append(), and KKB::SPRINTF().

4227 {
4228  char buff[60];
4229  SPRINTF (buff, sizeof (buff), "%.9g", right);
4230  if (strchr (buff, '.') != NULL)
4231  {
4232  // Remove trailing Zeros
4233  kkint32 buffLen = (kkint32)strlen (buff);
4234  while ((buffLen > 1) && (buff[buffLen - 1] == '0') && (buff[buffLen - 2] == '0'))
4235  {
4236  buffLen--;
4237  buff[buffLen] = 0;
4238  }
4239  }
4240  Append (buff);
4241  return *this;
4242 }
__int32 kkint32
Definition: KKBaseTypes.h:88
void Append(const char *buff)
Definition: KKStr.cpp:1783
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr & KKStr::operator<< ( double  right)

Definition at line 4246 of file KKStr.cpp.

References Append(), and KKB::SPRINTF().

4247 {
4248  char buff[70];
4249  SPRINTF (buff, sizeof (buff), "%.17g", right);
4250  if (strchr (buff, '.') != NULL)
4251  {
4252  // Remove trailing Zeros
4253  kkint32 buffLen = (kkint32)strlen (buff);
4254  while ((buffLen > 1) && (buff[buffLen - 1] == '0') && (buff[buffLen - 2] == '0'))
4255  {
4256  buffLen--;
4257  buff[buffLen] = 0;
4258  }
4259  }
4260  Append (buff);
4261  return *this;
4262 }
__int32 kkint32
Definition: KKBaseTypes.h:88
void Append(const char *buff)
Definition: KKStr.cpp:1783
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr & KKStr::operator<< ( std::ostream &(*)(std::ostream &)  mf)

Definition at line 5244 of file KKStr.cpp.

5245 {
5246  ostringstream o;
5247  mf (o);
5248  Append (o.str ().c_str ());
5249  return *this;
5250 }
void Append(const char *buff)
Definition: KKStr.cpp:1783
bool KKStr::operator<= ( const KKStr right) const

Definition at line 1642 of file KKStr.cpp.

References Compare().

1643 {
1644  return (Compare (right) <= 0);
1645 }
kkint32 Compare(const KKStr &s2) const
Definition: KKStr.cpp:844
KKStr & KKStr::operator= ( const KKStr src)

Definition at line 1390 of file KKStr.cpp.

References KKB::KKException::KKException().

Referenced by KKMLL::ConfusionMatrix2::AccuracyStr(), KKLSC::ScannerFileEntry::Assign(), KKB::RunLog::AttachFile(), KKB::RunLog::AttachFileAppend(), KKMLL::TrainingProcess2::BuildTrainingProcess(), KKMLL::Classifier2::Classifier2(), KKMLL::FileDesc::ClassNameAttribute(), KKLSC::ScannerFileEntry::Description(), KKMLL::MLClass::Description(), KKMLL::FeatureVector::ExampleFileName(), KKB::KKThread::ExceptionText(), KKMLL::FeatureVectorList::ExtractDuplicatesByRootImageFileName(), KKMLL::MLClassList::ExtractThreeTitleLines(), KKMLL::FeatureFileIO::FeatureDataReSink(), KKMLL::TrainingClass::FeatureFileName(), KKMLL::FileDesc::FileName(), KKMLL::ModelParam::FileName(), KKMLL::FeatureVectorList::FileName(), KKB::Raster::FileName(), KKMLL::ConfusionMatrix2::FMeasure(), KKB::PointList::FromDelStr(), KKLSC::ScannerFileEntry::FullName(), KKMLL::FeatureFileIODstWeb::GetFileDesc(), KKMLL::FeatureFileIOC45::GetFileDesc(), KKB::Configuration::Load(), KKMLL::TrainingConfiguration2::Load(), KKMLL::FeatureFileIOC45::LoadFeatureFile(), KKMLL::FeatureFileIOC45::LoadFile(), KKMLL::TrainingConfiguration2::LoadOtherClasssExamples(), KKMLL::Model::Name(), KKLSC::ScannerFile::Open(), KKMLL::Attribute::operator=(), KKMLL::Orderings::Orderings(), KKB::osGetRootName(), KKB::osGetRootNameOfDirectory(), KKB::osGetRootNameWithExtension(), KKB::osParseFileName(), KKB::osParseFileSpec(), KKMLL::Attribute::ReadXML(), KKMLL::TrainingClassList::RootDir(), KKMLL::TrainingConfiguration2::RootDir(), KKMLL::Model::RootFileName(), KKLSC::ScannerFileEntry::RootName(), KKB::RunLog::RunLog(), KKB::BmpImage::Save(), KKMLL::Orderings::Save(), KKB::BmpImage::SaveGrayscaleInverted4Bit(), KKB::BmpImage::SaveGrayscaleInverted8Bit(), KKLSC::Variables::SetHomeDir(), KKMLL::KKMLVariables::SetMachineLearninigHomeDir(), KKMLL::TrainingClass::SubClassifierName(), SVM233::svm_parameter::svm_parameter(), KKB::Raster::TakeOwnershipOfAnotherRastersData(), KKB::Raster::Title(), ToLatitude(), ToLongitude(), KKB::RunLog::WriteLine(), and KKMLL::NormalizationParms::WriteToFile().

1391 {
1392  #ifdef KKDEBUG
1393  ValidateLen ();
1394  src.ValidateLen ();
1395  #endif
1396 
1397  if (&src == this)
1398  {
1399  // We are assigning our selves to our selves; there is nothing to do.
1400  return *this;
1401  }
1402 
1403  kkuint16 spaceNeeded = src.len + 1;
1404  if ((spaceNeeded > allocatedSize) || (!val))
1405  {
1406  delete val;
1407  val = NULL;
1408  allocatedSize = 0;
1409  AllocateStrSpace (spaceNeeded);
1410  if (!val)
1411  throw KKException ("KKStr::operator=");
1412  }
1413  else
1414  {
1415  memset (val, 0, allocatedSize);
1416  }
1417 
1418  if (src.val)
1419  memcpy (val, src.val, src.len);
1420 
1421  len = src.len;
1422  val[len] = 0;
1423 
1424  return *this;
1425 }
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
KKStr & KKStr::operator= ( KKStr &&  src)

Definition at line 1369 of file KKStr.cpp.

Referenced by KKMLL::FeatureFileIODstWeb::AttrDescLine::AttrDescLine(), KKMLL::ClassificationBiasMatrix::ClassificationBiasMatrix(), KKMLL::TrainingConfiguration2::CreateFromDirectoryStructure(), KKMLL::ClassProbList::CreateFromXMLStream(), KKMLL::TrainingClass::ExpandedDirectory(), ExtractAttribute(), KKMLL::FeatureVectorList::ExtractDuplicatesByRootImageFileName(), KKMLL::FeatureNumList::ExtractFeatureNumsFromStr(), KKMLL::MLClassList::ExtractThreeTitleLines(), KKMLL::FeatureFileIO::FeatureDataReSink(), KKB::PointList::FromDelStr(), GetClassNameByHierarchyLevel(), KKMLL::MLClass::GetClassNameFromDirName(), KKMLL::TrainingConfiguration2::GetEffectiveConfigFileName(), KKMLL::FeatureFileIOC45::GetFileDesc(), KKMLL::FeatureFileIOUCI::GetFileDesc(), KKMLL::TrainingConfiguration2::Load(), KKMLL::FeatureFileIOC45::LoadFeatureFile(), KKMLL::FeatureFileIODstWeb::LoadFile(), KKMLL::FeatureFileIOC45::LoadFile(), KKLSC::ScannerFile::LoadIndexFile(), KKMLL::FeatureFileIO::LoadInSubDirectoryTree(), KKMLL::TrainingConfiguration2::LoadOtherClasssExamples(), KKLSC::ScannerFile::Open(), KKB::operator<<(), KKB::RunLog::operator<<(), operator<<(), KKMLL::Orderings::Orderings(), KKB::osCreateDirectoryPath(), KKB::osCreateUniqueFileName(), KKB::osGetRootName(), KKB::osGetRootNameOfDirectory(), KKB::osGetRootNameWithExtension(), KKB::osParseFileName(), KKB::osParseFileSpec(), KKB::osSubstituteInEnvironmentVariables(), KKMLL::ModelParam::ParseCmdLine(), KKMLL::ModelParamOldSVM::ParseCmdLine(), KKLSC::ScannerFileEntry::ParseTabDelStr(), KKMLL::ConfusionMatrix2::PrintAccuracyByProbByClassHTML(), KKMLL::ModelDual::ProbabilitiesByClassDual(), KKMLL::Model::ProbabilitiesByClassDual(), KKB::ReadImagePGM(), KKB::ReadImagePPM(), KKMLL::AttributeTypeVector::ReadXML(), KKMLL::Attribute::ReadXML(), KKMLL::ModelParamOldSVM::ReadXML(), KKMLL::ModelParam::ReadXMLModelParamToken(), KKMLL::Model::ReadXMLModelToken(), KKMLL::TrainingConfiguration2::RootDir(), KKLSC::ScannerFile::SaveIndexFile(), KKMLL::TrainingProcess2::SaveTrainingProcess(), KKJobManagment::KKJobManager::StatusFileProcessLine(), StripOutAnyComments(), KKLSC::Variables::SubstituteInEnvironmentVariables(), SVM233::svm_parameter::svm_parameter(), KKB::TimeType::TimeType(), KKMLL::ModelParamSvmBase::ToCmdLineStr(), KKMLL::ModelParamDual::ToCmdLineStr(), KKMLL::ModelParamOldSVM::ToCmdLineStr(), ToLatitude(), ToLongitude(), KKMLL::SVMparam::ToString(), ToVectorInt32(), Wide(), and KKB::XmlTag::XmlTag().

1370 {
1371  #ifdef KKDEBUG
1372  ValidateLen ();
1373  src.ValidateLen ();
1374  #endif
1375 
1376  delete val;
1377  val = src.val;
1378  allocatedSize = src.allocatedSize;
1379  len = src.len;
1380  src.val = NULL;
1381  src.allocatedSize = 0;
1382  src.len = 0;
1383 
1384  return *this;
1385 }
KKStr & KKStr::operator= ( const char *  src)

Definition at line 1442 of file KKStr.cpp.

References KKB::STRCOPY().

Referenced by KKMLL::ConfusionMatrix2::AccuracyStr(), KKB::XmlElementKeyValuePairs::Add(), KKB::RunLog::AttachFile(), KKB::BmpImage::BmpImage(), KKMLL::TrainingConfiguration2::CreateFromFeatureVectorList(), KKB::RunLog::DetachFile(), ExtractAttribute(), KKMLL::MLClassList::ExtractThreeTitleLines(), ExtractToken(), ExtractToken2(), KKMLL::MLClassList::ExtractTwoTitleLines(), KKB::PointList::FromDelStr(), KKMLL::FeatureFileIOC45::GetFileDesc(), KKMLL::FeatureFileIORoberts::GetFileDesc(), KKMLL::FeatureFileIOUCI::GetFileDesc(), KKMLL::FeatureFileIO::GetLine(), KKMLL::FeatureFileIO::GetToken(), KKMLL::FeatureFileIODstWeb::LoadFile(), KKMLL::FeatureFileIORoberts::LoadFile(), KKMLL::FeatureFileIOC45::LoadFile(), KKB::Configuration::LoadFile(), KKMLL::FeatureFileIO::LoadInSubDirectoryTree(), KKB::operator>>(), KKB::osCreateDirectoryPath(), KKB::osCreateUniqueFileName(), KKB::osGetErrorNoDesc(), KKB::osGetListOfFilesInDirectoryTree(), KKB::osParseFileName(), KKB::osParseFileSpec(), KKMLL::ModelParamOldSVM::ParseCmdLine(), KKMLL::ConfusionMatrix2::PrintAccuracyByProbByClassHTML(), KKLSC::ScannerFile::ReadHeaderOneLine(), ReadWholeTag(), KKB::RunLog::RunLog(), KKMLL::FeatureFileIODstWeb::SaveFile(), StripOutAnyComments(), KKMLL::FeatureVectorList::SynchronizeSymbolicData(), ToLatitude(), ToLongitude(), KKLSC::ScannerFile::WriteHeader(), and KKB::RunLog::WriteLine().

1443 {
1444  #ifdef KKDEBUG
1445  ValidateLen ();
1446  #endif
1447 
1448  if (!src)
1449  {
1450  delete val;
1451  val = NULL;
1452  allocatedSize = 0;
1453  AllocateStrSpace (10);
1454  len = 0;
1455  return *this;
1456  }
1457 
1458  kkuint16 newLen = (kkuint16)strlen (src);
1459  kkuint16 spaceNeeded = newLen + 1;
1460 
1461  if (spaceNeeded > allocatedSize)
1462  {
1463  delete val;
1464  val = NULL;
1465  allocatedSize = 0;
1466  AllocateStrSpace (spaceNeeded);
1467  }
1468 
1469  STRCOPY (val, allocatedSize, src);
1470  len = newLen;
1471 
1472  return *this;
1473 }
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
char * STRCOPY(char *dest, kkint32 destSize, const char *src)
Definition: KKStr.cpp:46
KKStr & KKStr::operator= ( kkint32  right)

Definition at line 1478 of file KKStr.cpp.

References KKB::SPRINTF(), and KKB::STRCOPY().

Referenced by KKMLL::SizeDistribution::ClassTotals::PrintFormatedLine().

1479 {
1480  #ifdef KKDEBUG
1481  ValidateLen ();
1482  #endif
1483 
1484  char buff[60];
1485  SPRINTF (buff, sizeof (buff), "%d", right);
1486 
1487  kkuint16 newLen = (kkuint16)strlen (buff);
1488 
1489  kkuint16 spaceNeeded = newLen + 1;
1490 
1491  if (spaceNeeded > allocatedSize)
1492  {
1493  delete val;
1494  val = NULL;
1495  allocatedSize = 0;
1496  AllocateStrSpace (spaceNeeded);
1497  }
1498 
1499  memset (val, 0, allocatedSize);
1500 
1501  STRCOPY (val, allocatedSize, buff);
1502  len = newLen;
1503 
1504  return *this;
1505 }
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
char * STRCOPY(char *dest, kkint32 destSize, const char *src)
Definition: KKStr.cpp:46
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr & KKStr::operator= ( const std::vector< KKStr > &  right)

Definition at line 1509 of file KKStr.cpp.

References Concat(), and KKB::KKException::KKException().

1510 {
1511  kkint32 spaceNeeded = 2; /* Start with 2 bytes for overhead. */
1512  kkuint32 x = 0;
1513  for (x = 0; x < right.size (); x++)
1514  spaceNeeded += right[x].Len ();
1515 
1516  if (spaceNeeded > allocatedSize)
1517  {
1518  delete val;
1519  val = NULL;
1520  allocatedSize = 0;
1521  AllocateStrSpace (spaceNeeded);
1522  }
1523 
1524  if (!val)
1525  {
1526  KKStr errMsg = "KKStr::operator= (const std::vector<KKStr>& right) ***ERROR*** Space for string not allocatd!";
1527  cerr << endl << errMsg << endl <<endl;
1528  throw KKException (errMsg);
1529  }
1530 
1531  char* ptr = val;
1532  kkint32 allocatedSpaceNotUsed = allocatedSize - 1;
1533  for (x = 0; x < right.size (); x++)
1534  {
1535  kkint32 rightLen = right[x].Len ();
1536 #ifdef USE_SECURE_FUNCS
1537  strncpy_s (ptr, allocatedSpaceNotUsed, right[x].Str (), rightLen);
1538 #else
1539  strncpy (ptr, right[x].Str (), rightLen);
1540 #endif
1541  ptr = ptr + rightLen;
1542  allocatedSpaceNotUsed -= rightLen;
1543  *ptr = 0;
1544  }
1545  return *this;
1546 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
bool KKStr::operator== ( const KKStr right) const
bool KKStr::operator== ( KKStrConstPtr  right) const

Definition at line 1566 of file KKStr.cpp.

References Compare().

1567 {
1568  if (!right)
1569  return false;
1570 
1571  return (Compare (*right) == 0);
1572 }
kkint32 Compare(const KKStr &s2) const
Definition: KKStr.cpp:844
bool KKStr::operator== ( const std::string  right) const

Definition at line 1603 of file KKStr.cpp.

1604 {
1605  return (Compare (right) == 0);
1606 }
kkint32 Compare(const KKStr &s2) const
Definition: KKStr.cpp:844
bool KKStr::operator>= ( const KKStr right) const

Definition at line 1627 of file KKStr.cpp.

References Compare().

1628 {
1629  return (Compare (right) >= 0);
1630 }
kkint32 Compare(const KKStr &s2) const
Definition: KKStr.cpp:844
char KKStr::operator[] ( kkint16  i) const

Returns back the character at position 'i', if i > length of KKStr then returns back 0.

Definition at line 3379 of file KKStr.cpp.

Referenced by KKB::osGetDriveLetter(), KKB::osSubstituteInEnvironmentVariables(), and KKB::ReadImagePGM().

3380 {
3381  #ifdef KKDEBUG
3382  ValidateLen ();
3383  #endif
3384 
3385  if (!val)
3386  return 0;
3387 
3388  if ((i < 0) || ((kkuint16)i >= len))
3389  return 0;
3390  else
3391  return val[i];
3392 }
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
char KKStr::operator[] ( kkuint16  i) const

Returns back the character at position 'i', if i > length of KKStr then returns back 0.

Definition at line 3396 of file KKStr.cpp.

Referenced by KKB::osSplitDirectoryPathIntoParts().

3397 {
3398  #ifdef KKDEBUG
3399  ValidateLen ();
3400  #endif
3401 
3402  if (!val)
3403  return 0;
3404 
3405  if (i >= len)
3406  return 0;
3407  else
3408  return val[i];
3409 }
char KKStr::operator[] ( kkint32  i) const

Returns back the character at position 'i', if i > length of KKStr then returns back 0.

Definition at line 3413 of file KKStr.cpp.

Referenced by KKMLL::TrainingClass::ExpandedDirectory(), ExtractAttribute(), KKB::BitString::FromHexStr(), KKB::KKStrParser::GetNextTokenChar(), KKMLL::ModelParamOldSVM::ParseCmdLine(), StripOutAnyComments(), KKLSC::Variables::SubstituteInEnvironmentVariables(), and SVM233::svm_parameter::svm_parameter().

3414 {
3415  #ifdef KKDEBUG
3416  ValidateLen ();
3417  #endif
3418 
3419  if (!val)
3420  return 0;
3421 
3422  if ((i < 0) || ((kkuint16)i >= len))
3423  return 0;
3424  else
3425  return val[i];
3426 }
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
char KKStr::operator[] ( kkuint32  i) const

Returns back the character at position 'i', if i > length of KKStr then returns back 0.

Definition at line 3430 of file KKStr.cpp.

Referenced by KKMLL::MLClass::GetClassNameFromDirName(), KKMLL::FeatureFileIOC45::GetFileDesc(), KKB::TokenBufferStr::GetNextChar(), KKB::osSplitDirectoryPathIntoParts(), KKB::osValidFileNameErrors(), KKB::TokenBufferStr::PeekNextChar(), and StripOutInvalidLatexCaracters().

3431 {
3432  #ifdef KKDEBUG
3433  ValidateLen ();
3434  #endif
3435 
3436  if (!val)
3437  return 0;
3438 
3439  if (i >= len)
3440  return 0;
3441  else
3442  return val[i];
3443 }
VectorKKStr KKStr::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' separates each token.

Definition at line 3461 of file KKStr.cpp.

References Concat(), Empty(), ExtractToken2(), KKStr(), TrimLeft(), and TrimRight().

3462 {
3463  KKStr wrkStr (*this);
3464  wrkStr.TrimLeft (" ");
3465  wrkStr.TrimRight (" ");
3466 
3467  VectorKKStr result;
3468 
3469  while (!wrkStr.Empty ())
3470  {
3471  KKStr field = wrkStr.ExtractToken2 (delStr);
3472  result.push_back (field);
3473  }
3474 
3475  return result;
3476 } /* Parse */
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
KKStr KKStr::QuotedStr ( ) const

Returns a quoted version of string where special characters Line-Feed, Carriage Return, and Tab, are encoded as escape sequences.

string where 'Line Feed(\n'), Carriage Returns('\r'), Tabs('\t'), and Quotes(") are coded as escape sequences "\n", "\r", "t", or "\". It is then enclosed in quotes(").

Returns
Quoted String.

Definition at line 2890 of file KKStr.cpp.

References Append(), Concat(), KKStr(), and Len().

Referenced by ToQuotedStr(), KKB::XmlTag::ToString(), KKB::KKStrList::WriteXML(), and KKB::KKStrListIndexed::WriteXML().

2891 {
2892  if ((!val) || (len < 1))
2893  {
2894  return "\"\"";
2895  }
2896 
2897 
2898  KKStr result (Len () + 5);
2899 
2900  result.Append ('"');
2901 
2902  kkint32 idx = 0;
2903 
2904  while (idx < len)
2905  {
2906  switch (val[idx])
2907  {
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;
2913  case 0: result.Append ("\\0"); break;
2914 
2915  default: result.Append (val[idx]); break;
2916  }
2917 
2918  idx++;
2919  }
2920 
2921  result.Append ('"');
2922 
2923  return result;
2924 } /* QuotedStr */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
void KKStr::ReadXML ( XmlStream s,
XmlTagConstPtr  tag,
VolConstBool cancelFlag,
RunLog log 
)

Definition at line 4438 of file KKStr.cpp.

References Append(), KKB::XmlTag::AttributeValueInt32(), KKB::XmlContent::Content(), KKB::XmlStream::GetNextToken(), KKB::XmlToken::tokContent, KKB::XmlToken::TokenType(), and TrimRight().

4443 {
4444  kkuint16 expectedLen = tag->AttributeValueInt32 ("Len");
4445  delete val;
4446  val = NULL;
4447  allocatedSize = 0;
4448  if (expectedLen > 0)
4449  AllocateStrSpace (expectedLen);
4450 
4451  delete val;
4452  val = NULL;
4453  allocatedSize = 0;
4454  AllocateStrSpace (expectedLen);
4455 
4456  XmlTokenPtr t = s.GetNextToken (cancelFlag, log);
4457  while (t && (!cancelFlag))
4458  {
4460  {
4461  XmlContentPtr c = dynamic_cast<XmlContentPtr> (t);
4462  Append (*(c->Content ()));
4463  }
4464  delete t;
4465  if (cancelFlag)
4466  t = NULL;
4467  else
4468  t = s.GetNextToken (cancelFlag, log);
4469  }
4470  delete t;
4471  t = NULL;
4472 
4473  TrimRight (" \r\n");
4474 } /* ReadXML */
KKStr & TrimRight(const char *whiteSpaceChars="\n\r\t ")
Definition: KKStr.cpp:1695
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
void Append(const char *buff)
Definition: KKStr.cpp:1783
KKStrPtr const Content() const
Definition: XmlStream.h:338
virtual TokenTypes TokenType()=0
virtual XmlTokenPtr GetNextToken(VolConstBool &cancelFlag, RunLog &log)
Definition: XmlStream.cpp:116
void KKStr::RightPad ( kkint32  width,
char  ch = ' ' 
)

Pads string on the right side with specified character so that the string will be of specified length.

Parameters
[in]widthWidth that string will need to be; if less than current length then the string will be truncated to 'len'.
[in]chCharacter to pad with; if not specified will default to space (' ').

Definition at line 2239 of file KKStr.cpp.

References Concat(), KKB::KKException::KKException(), MaxLenSupported(), operator+(), KKB::operator+(), and KKB::StrFromInt32().

Referenced by KKMLL::MLClassList::ExtractThreeTitleLines(), KKMLL::SizeDistribution::ClassTotals::PrintFormatedLine(), Spaces(), and Wide().

2242 {
2243  #ifdef KKDEBUG
2244  ValidateLen ();
2245  #endif
2246 
2247  if (width < 0)
2248  {
2249  KKStr errMsg = "KKStr::RightPad (kkint32 width, char ch) ***ERROR*** width[" + StrFromInt32 (width) + "] invalid.";
2250  cerr << endl << errMsg << endl << endl;
2251  throw KKException(errMsg);
2252  }
2253 
2254  if ((kkuint32)width > MaxLenSupported ()) {
2255  KKStr errMsg = "KKStr::RightPad (kkint32 width, char ch) ***ERROR*** width[" + StrFromInt32 (width) + "] greater-than KKStr suppotrts.";
2256  cerr << endl << errMsg << endl << endl;
2257  throw KKException(errMsg);
2258  }
2259 
2260  if (!val)
2261  {
2262  AllocateStrSpace (width + 1);
2263  len = 0;
2264  }
2265 
2266  if (len > (kkuint16)width)
2267  {
2268  len = (kkuint16)width;
2269  for (kkint32 x = len; x < allocatedSize; x++)
2270  val[x] = 0;
2271  }
2272 
2273  else
2274  {
2275  kkuint32 neededSpace = width + 1;
2276 
2277  if (neededSpace > allocatedSize)
2278  {
2279  if (neededSpace >= KKStrIntMax)
2280  {
2281  cerr << std::endl
2282  << "KKStr::RightPad ***ERROR*** Size of buffer can not fit into String." << std::endl
2283  << " neededSpace[" << neededSpace << "]" << std::endl
2284  << std::endl;
2285  return;
2286  }
2287  GrowAllocatedStrSpace (neededSpace);
2288  }
2289 
2290  while (len < (kkuint16)width)
2291  {
2292  val[len] = ch;
2293  len++;
2294  }
2295 
2296  val[len] = 0;
2297  }
2298 } /* RightPad */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
kkuint32 MaxLenSupported() const
Definition: KKStr.cpp:2510
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
KKStr StrFromInt32(kkint32 i)
Definition: KKStr.cpp:5175
KKStr KKStr::Spaces ( kkint32  c)
static

Returns a string of spaces 'c' characters long.

Parameters
[in]cNumber of space characters to fill the string with.

Definition at line 4329 of file KKStr.cpp.

References Concat(), and RightPad().

Referenced by Wide().

4330 {
4331  KKStr s;
4332  s.RightPad (c);
4333  return s;
4334 }
void RightPad(kkint32 width, char ch= ' ')
Pads string on the right side with specified character so that the string will be of specified length...
Definition: KKStr.cpp:2239
VectorKKStr KKStr::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 each token.

Parameters
[in]delStrList of characters that where any one of them can be a delimiter.

Definition at line 3480 of file KKStr.cpp.

References Concat(), Empty(), ExtractToken2(), KKStr(), TrimLeft(), and TrimRight().

Referenced by KKMLL::FeatureFileIOC45::GetFileDesc().

3481 {
3482  KKStr wrkStr (*this);
3483  wrkStr.TrimLeft (" ");
3484  wrkStr.TrimRight (" ");
3485 
3486  VectorKKStr result;
3487 
3488  while (!wrkStr.Empty ())
3489  {
3490  KKStr field = wrkStr.ExtractToken2 (delStr);
3491  result.push_back (field);
3492  }
3493 
3494  return result;
3495 } /* Split */
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
VectorKKStr KKStr::Split ( char  del) const

Splits the string up into tokens using 'del' as the separator returning them in a vector.

Definition at line 3500 of file KKStr.cpp.

References Concat(), Empty(), ExtractToken2(), KKStr(), TrimLeft(), and TrimRight().

Referenced by KKMLL::MLClassList::BuildListFromDelimtedStr(), DelimitedStrToArray(), KKMLL::MLClassList::ExtractHTMLTableHeader(), KKMLL::MLClass::MLClassForGivenHierarchialLevel(), KKJobManagment::KKJob::PrerequisitesFromStr(), and KKJobManagment::KKJob::ProcessStatusStr().

3501 {
3502  char delStr[2];
3503  delStr[0] = del;
3504  delStr[1] = 0;
3505 
3506  KKStr wrkStr (*this);
3507  wrkStr.TrimLeft (" ");
3508  wrkStr.TrimRight (" ");
3509 
3510  VectorKKStr result;
3511 
3512  while (!wrkStr.Empty ())
3513  {
3514  KKStr field = wrkStr.ExtractToken2 (delStr);
3515  result.push_back (field);
3516  }
3517 
3518  return result;
3519 } /* Parse */
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
bool KKStr::StartsWith ( const KKStr value) const

Definition at line 1137 of file KKStr.cpp.

References StartsWith().

Referenced by KKMLL::ModelDual::ReconcileProbAndVotes().

1138 {
1139  return StartsWith (value, false);
1140 }
bool StartsWith(const KKStr &value) const
Definition: KKStr.cpp:1137
bool KKStr::StartsWith ( const char *  value) const

Definition at line 1144 of file KKStr.cpp.

References StartsWith().

Referenced by KKMLL::ClassProbList::CreateFromXMLStream().

1145 {
1146  return StartsWith (value, false);
1147 }
bool StartsWith(const KKStr &value) const
Definition: KKStr.cpp:1137
bool KKStr::StartsWith ( const KKStr value,
bool  ignoreCase 
) const

Definition at line 1150 of file KKStr.cpp.

References StrEqualN(), and StrEqualNoCaseN().

Referenced by StartsWith().

1153 {
1154  if (value.len == 0)
1155  return true;
1156 
1157  if (value.len > len)
1158  return false;
1159 
1160  if (ignoreCase)
1161  return StrEqualNoCaseN (val, value.val, value.len);
1162  else
1163  return StrEqualN (val, value.val, value.len);
1164 }
static bool StrEqualN(const char *s1, const char *s2, kkuint32 len)
Definition: KKStr.cpp:388
static bool StrEqualNoCaseN(const char *s1, const char *s2, kkuint32 len)
Definition: KKStr.cpp:436
bool KKStr::StartsWith ( const char *  value,
bool  ignoreCase 
) const

Definition at line 1169 of file KKStr.cpp.

References StrEqualN(), and StrEqualNoCaseN().

Referenced by KKLSC::ScannerFile::ReportTextMsg(), and StartsWith().

1172 {
1173  if (value == NULL)
1174  return true;
1175 
1176  kkint32 valueLen = (kkint32)strlen (value);
1177 
1178  if (ignoreCase)
1179  return StrEqualNoCaseN (val, value, valueLen);
1180  else
1181  return StrEqualN (val, value, valueLen);
1182 }
__int32 kkint32
Definition: KKBaseTypes.h:88
static bool StrEqualN(const char *s1, const char *s2, kkuint32 len)
Definition: KKStr.cpp:388
static bool StrEqualNoCaseN(const char *s1, const char *s2, kkuint32 len)
Definition: KKStr.cpp:436
const char * KKStr::Str ( const char *  s)
static

Definition at line 286 of file KKStr.cpp.

287 {
288  if (!s)
289  return "";
290  else
291  return s;
292 }
void KKStr::StrCapitalize ( char *  str)
static

Definition at line 4375 of file KKStr.cpp.

Referenced by StrInStr().

4376 {
4377  if (!str)
4378  return;
4379 
4380  char* ch = str;
4381  while (*ch)
4382  {
4383  *ch = (char)toupper (*ch);
4384  ch++;
4385  }
4386 }
const char * KKStr::StrChr ( const char *  str,
int  ch 
)
static

Definition at line 308 of file KKStr.cpp.

311 {
312  return strchr (str, ch);
313 }
kkint32 KKStr::StrCompareIgnoreCase ( const char *  s1,
const char *  s2 
)
static

Definition at line 318 of file KKStr.cpp.

Referenced by EqualIgnoreCase().

321 {
322  if (s1 == NULL)
323  {
324  if (s2 == NULL)
325  return 0;
326  else
327  return -1;
328  }
329  else if (s2 == NULL)
330  return 1;
331 
332 
333  while ((*s1) && (*s2) && (toupper (*s1) == toupper (*s2)))
334  {
335  s1++;
336  s2++;
337  }
338 
339  if (*s1 == 0)
340  {
341  if (*s2 == 0)
342  {
343  return 0;
344  }
345  else
346  {
347  // s1 < s2
348  return -1;
349  }
350  }
351  else
352  {
353  if (*s2 == 0)
354  {
355  return 1;
356  }
357  else
358  {
359  if (*s1 < *s2)
360  return -1;
361  else
362  return 1;
363  }
364  }
365 
366 
367  //return _stricmp (s1, s2);
368 } /* StrCompareIgnoreCase */
void KKStr::StrDelete ( char **  str)
static

Definition at line 296 of file KKStr.cpp.

297 {
298  if (*str)
299  {
300  delete [] *str;
301  *str = NULL;
302  }
303 }
bool KKStr::StrEqual ( const char *  s1,
const char *  s2 
)
static

Definition at line 373 of file KKStr.cpp.

Referenced by EndsWith(), operator!=(), and operator==().

376 {
377  if ((!s1) && (!s2))
378  return true;
379 
380  if ((!s1) || (!s2))
381  return false;
382 
383  return (strcmp (s1, s2) == 0);
384 }
bool KKStr::StrEqualN ( const char *  s1,
const char *  s2,
kkuint32  len 
)
static

Definition at line 388 of file KKStr.cpp.

Referenced by StartsWith().

392 {
393  if ((!s1) && (!s2))
394  return true;
395 
396  if ((!s1) || (!s2))
397  return false;
398 
399  for (kkuint32 x = 0; x < len; ++x)
400  if (s1[x] != s2[x])
401  return false;
402 
403  return true;
404 }
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
bool KKStr::StrEqualNoCase ( const char *  s1,
const char *  s2 
)
static

Definition at line 408 of file KKStr.cpp.

Referenced by EndsWith(), and KKB::osLookForFile().

411 {
412  if ((!s1) && (!s2))
413  return true;
414 
415  if ((!s1) || (!s2))
416  return false;
417 
418  size_t l1 = strlen (s1);
419  size_t l2 = strlen (s2);
420 
421  if (l1 != l2)
422  return false;
423 
424 
425  for (size_t i = 0; i < l1; i++)
426  {
427  if (toupper (s1[i]) != toupper (s2[i]))
428  return false;
429  }
430 
431  return true;
432 } /* StrEqualNoCase */
bool KKStr::StrEqualNoCaseN ( const char *  s1,
const char *  s2,
kkuint32  len 
)
static

Definition at line 436 of file KKStr.cpp.

Referenced by StartsWith().

440 {
441  if ((!s1) && (!s2))
442  return true;
443 
444  if ((!s1) || (!s2))
445  return false;
446 
447  for (kkuint32 x = 0; x < len; ++x)
448  if (toupper (s1[x]) != toupper (s2[x]))
449  return false;
450 
451  return true;
452 }
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
bool KKStr::StrInStr ( const char *  target,
const char *  searchStr 
)
static

Definition at line 4391 of file KKStr.cpp.

References StrCapitalize().

Referenced by StrInStr().

4394 {
4395  if ((target == NULL) || (searchStr == NULL))
4396  return false;
4397 
4398 # ifdef USE_SECURE_FUNCS
4399  char* t = _strdup (target);
4400  char* s = _strdup (searchStr);
4401 # else
4402  char* t = strdup (target);
4403  char* s = strdup (searchStr);
4404 #endif
4405 
4406 
4407  StrCapitalize (t);
4408  StrCapitalize (s);
4409 
4410  bool f = (strstr (t, s) != NULL);
4411 
4412  free(t);
4413  free(s);
4414  return f;
4415 }
static void StrCapitalize(char *str)
Definition: KKStr.cpp:4375
bool KKStr::StrInStr ( const KKStr searchField) const

Searches for the occurrence of 'searchField' and where in the string. If found will return 'true' otherwise 'false'.

Definition at line 2731 of file KKStr.cpp.

References StrInStr().

Referenced by Contains().

2732 {
2733  return StrInStr (val, searchField.val);
2734 }
static bool StrInStr(const char *target, const char *searchStr)
Definition: KKStr.cpp:4391
void KKStr::StrReplace ( char **  dest,
const char *  src 
)

Replaces the contents of *dest with *src.

First deletes current *dest then allocates new a new string to **dest so no memory is lost.

Definition at line 456 of file KKStr.cpp.

References Concat(), operator+(), KKB::operator+(), KKB::STRCOPY(), and KKB::StrFormatInt().

459 {
460  if (*dest)
461  delete [] *dest;
462 
463  kkint32 spaceNeeded;
464 
465  if (src)
466  {
467  spaceNeeded = (kkint32)strlen (src) + 1;
468  *dest = new char[spaceNeeded];
469 
470  if (*dest == NULL)
471  {
472  KKStr errMsg = "KKStr::StrReplace ***ERROR*** Failed to allocate SpaceNeeded[" + StrFormatInt (spaceNeeded, "#####0") + "].";
473  cerr << errMsg << std::endl << std::endl;
474  throw errMsg;
475  }
476 
477  STRCOPY (*dest, spaceNeeded, src);
478  }
479  else
480  {
481  *dest = new char[1];
482 
483  if (*dest == NULL)
484  {
485  KKStr errMsg = "StrReplace ***ERROR*** Failed to allocate Empty KKStr.";
486  cerr << std::endl << errMsg << std::endl;
487  throw errMsg;
488  }
489 
490  (*dest)[0] = 0;
491  }
492 } /* StrReplace */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
char * STRCOPY(char *dest, kkint32 destSize, const char *src)
Definition: KKStr.cpp:46
KKStr StrFormatInt(kkint32 val, const char *mask)
Definition: KKStr.cpp:5004
wchar_t * KKStr::StrWide ( ) const

Returns a Wide Character version of the string. The caller will be responsible for deleting this string.

Definition at line 1264 of file KKStr.cpp.

1265 {
1266  wchar_t* w = NULL;
1267 
1268  if (!val)
1269  {
1270  w = new wchar_t[1];
1271  w[0] = 0;
1272  return w;
1273  }
1274 
1275  kkint32 x;
1276  w = new wchar_t[len + 1];
1277  for (x = 0; x < len; x++)
1278  w[x] = (wchar_t) val[x];
1279  return w;
1280 } /* StrWide */
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr KKStr::SubStrPart ( kkint32  firstChar) const

returns a SubString consisting of all characters starting at index 'firstChar' until the end of the string.

If the index 'firstChar' is past the end of the string a empty string will be returned.

Parameters
[in]firstCharFirst character in string to include in the sub-string.
Returns
Sub-string.

Definition at line 2780 of file KKStr.cpp.

References Append(), Concat(), and KKStr().

Referenced by KKMLL::FeatureFileIODstWeb::AttrDescLine::AttrDescLine(), KKMLL::DuplicateImage::ExampleWithSmallestScanLine(), ExtractAttribute(), KKMLL::MLClassList::ExtractTwoTitleLines(), KKB::PointList::FromDelStr(), KKMLL::FeatureFileIODstWeb::GetFileDesc(), KKMLL::FeatureFileIOC45::GetFileDesc(), GetNextToken2(), KKMLL::FeatureFileIOC45::LoadFeatureFile(), KKMLL::FeatureFileIODstWeb::LoadFile(), KKB::osCreateDirectoryPath(), KKB::osGetFileNamePartOfFile(), KKB::osGetRootName(), KKB::osGetRootNameOfDirectory(), KKB::osGetRootNameWithExtension(), KKB::osParseFileName(), KKB::osParseFileSpec(), KKB::osSubstituteInEnvironmentVariables(), SVM233::svm_parameter::ProcessSvmParameter(), KKLSC::Variables::SubstituteInEnvironmentVariables(), Tail(), ToLatitude(), ToLongitude(), and ToVectorInt32().

2781 {
2782  #ifdef KKDEBUG
2783  ValidateLen ();
2784  #endif
2785 
2786  if ((kkuint16)firstChar >= len)
2787  return "";
2788 
2789  if (firstChar < 0)
2790  firstChar = 0;
2791 
2792  kkuint16 subStrLen = len - (kkuint16)firstChar;
2793  KKStr subStr (subStrLen + 1);
2794  subStr.Append (((char*)&(val[firstChar])), subStrLen);
2795 
2796  return subStr;
2797 } /* SubStrPart */
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
KKStr KKStr::SubStrPart ( kkint32  firstChar,
kkint32  lastChar 
) const

returns a SubString consisting of all characters starting at index 'firstChar' and ending at 'lastIndex'

If the index 'firstChar' is past the end of the string a empty string will be returned. If 'lastIndex is past the end of the string then will only include characters until the end of the string.
The length of the substring will be (lastChar - firstChar) + 1.

Parameters
[in]firstCharFirst character in string to include in the sub-string.
[in]lastCharLast character in include in the string.
Returns
Sub-string.

Definition at line 2802 of file KKStr.cpp.

References Concat(), and KKStr().

Referenced by KKMLL::DuplicateImage::ExampleWithSmallestScanLine(), ExtractAttribute(), KKMLL::MLClassList::ExtractTwoTitleLines(), KKB::PointList::FromDelStr(), KKMLL::MLClass::GetClassNameFromDirName(), KKMLL::FeatureFileIODstWeb::GetFileDesc(), KKMLL::FeatureFileIOC45::GetFileDesc(), KKMLL::FeatureFileIOUCI::GetFileDesc(), KKMLL::FeatureFileIOSparse::GetFileDesc(), KKMLL::FeatureFileIOC45::LoadFeatureFile(), KKMLL::FeatureFileIOUCI::LoadFile(), MaxLen(), KKB::osGetParentDirectoryOfDirPath(), KKB::osGetParentDirPath(), KKB::osGetPathPartOfFile(), KKB::osGetRootName(), KKB::osParseFileName(), KKB::osParseFileSpec(), KKB::osRemoveExtension(), KKB::osSubstituteInEnvironmentVariables(), KKJobManagment::KKJobManager::StatusFileProcessLine(), StripOutAnyComments(), KKLSC::Variables::SubstituteInEnvironmentVariables(), KKB::TimeType::TimeType(), ToLatitude(), ToLongitude(), ToPercentage(), and ToVectorInt32().

2805 {
2806  #ifdef KKDEBUG
2807  ValidateLen ();
2808  #endif
2809 
2810  if (((kkuint16)firstChar >= len) || (lastChar < firstChar))
2811  return "";
2812 
2813  if (firstChar < 0)
2814  firstChar = 0;
2815 
2816  if (lastChar >= len)
2817  lastChar = len - 1;
2818 
2819 
2820  kkuint16 subStrLen = ((kkuint16)lastChar - (kkuint16)firstChar) + 1;
2821  KKStr subStr (subStrLen + 2);
2822 
2823  kkuint16 x = (kkuint16)firstChar;
2824  kkuint16 y = 0;
2825 
2826  for (x = (kkuint16)firstChar; x <= (kkuint16)lastChar; x++, y++)
2827  {
2828  subStr.val[y] = val[x];
2829  }
2830 
2831  subStr.val[y] = 0;
2832  subStr.len = subStrLen;
2833  return subStr;
2834 } /* SubStrPart */
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
KKStr KKStr::Tail ( kkint32  tailLen) const

Returns a string consisting of the 'tailLen' characters from the end of the string.

Return back the last 'tailLen' characters.

*ex:
if test = "Hello World.";
test.Tail (2) will return "d.".

Definition at line 2847 of file KKStr.cpp.

References SubStrPart().

2848 {
2849  if (tailLen <= 0)
2850  return "";
2851 
2852  kkuint16 firstChar = Max ((kkuint16)(len - (kkuint16)tailLen), (kkuint16)0);
2853  return SubStrPart (firstChar);
2854 } /* Tail */
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
T Max(T a, T b)
generic Max function, Both parameters must be of the same type.
Definition: KKBaseTypes.h:181
KKStr SubStrPart(kkint32 firstChar) const
returns a SubString consisting of all characters starting at index &#39;firstChar&#39; until the end of the s...
Definition: KKStr.cpp:2780
bool KKStr::ToBool ( ) const

Returns the bool equivalent of the string, ex 'Yes' = true, 'No' = false, 'True' = true, etc.

Definition at line 3523 of file KKStr.cpp.

References KKB::STRICMP().

Referenced by KKLSC::ScannerFile::ExtractHeaderField(), KKB::KKStrParser::GetNextTokenBool(), SVM289_BFS::svm_parameter::ProcessSvmParameter(), SVM289_MFS::svm_parameter::ProcessSvmParameter(), KKB::KKStrListIndexed::ReadXML(), KKB::XmlElementBool::XmlElementBool(), and KKMLL::XmlElementMLClass::XmlElementMLClass().

3524 {
3525  if (len < 1)
3526  return false;
3527 
3528  if ((STRICMP (val, "y") == 0) ||
3529  (STRICMP (val, "yes") == 0) ||
3530  (STRICMP (val, "t") == 0) ||
3531  (STRICMP (val, "true") == 0) ||
3532  (STRICMP (val, "1") == 0)
3533  )
3534  return true;
3535  else
3536  return false;
3537 }
kkint32 STRICMP(const char *left, const char *right)
Definition: KKStr.cpp:92
kkint16 KKStr::ToInt16 ( ) const

Definition at line 3576 of file KKStr.cpp.

Referenced by KKMLL::MLClassIndexList::ParseClassIndexList().

3577 {
3578  if (!val)
3579  return 0;
3580 
3581  kkint16 i = (kkint16)atoi (val);
3582  return i;
3583 } /* ToInt32*/
__int16 kkint16
16 bit signed integer.
Definition: KKBaseTypes.h:85
kkint32 KKStr::ToInt32 ( ) const

Definition at line 3587 of file KKStr.cpp.

Referenced by KKB::XmlAttributeList::AttributeValueInt32(), KKLSC::ScannerFile::ExtractHeaderField(), KKLSC::ScannerHeaderFields::GetValueInt32(), KKB::osGetNumberOfProcessors(), SVM233::svm_parameter::ProcessSvmParameter(), KKB::ReadImagePPM(), and ToVectorInt32().

3588 {
3589  if (!val)
3590  return 0;
3591 
3592  kkint32 i = atoi (val);
3593  return i;
3594 } /* ToInt32*/
__int32 kkint32
Definition: KKBaseTypes.h:88
KKB::kkint64 KKStr::ToInt64 ( ) const

Definition at line 3598 of file KKStr.cpp.

3599 {
3600  if (!val) return 0;
3601 
3602  #if defined(__GNUC__)
3603  return atoll (val);
3604  #else
3605  return (kkint64)_atoi64 (val);
3606  #endif
3607 }
__int64 kkint64
Definition: KKBaseTypes.h:90
KKStrPtr KKStr::ToKKStrPtr ( ) const

Instatiates a new instance of KKStr with Allocated optimized for current string length.

Definition at line 2541 of file KKStr.cpp.

References Concat(), and KKStr().

2542 {
2543  return new KKStr (*this);
2544 }
double KKStr::ToLatitude ( ) const

Processes string as if a standard latitude; ex: "15:32.2S" = -15.53833.

Definition at line 3725 of file KKStr.cpp.

References ChopFirstChar(), ChopLastChar(), Concat(), FirstChar(), KKStr(), LocateCharacter(), operator=(), SubStrPart(), ToDouble(), Trim(), TrimLeft(), and TrimRight().

3726 {
3727  KKStr latitudeStr (*this);
3728  latitudeStr.Trim ();
3729 
3730  bool north = true;
3731  char lastChar = (char)toupper (latitudeStr.LastChar ());
3732  if (lastChar == 'N')
3733  {
3734  north = true;
3735  latitudeStr.ChopLastChar ();
3736  }
3737  else if (lastChar == 'S')
3738  {
3739  north = false;
3740  latitudeStr.ChopLastChar ();
3741  }
3742  latitudeStr.TrimRight ();
3743 
3744  if (latitudeStr.FirstChar () == '-')
3745  {
3746  latitudeStr.ChopFirstChar ();
3747  north = !north;
3748  latitudeStr.TrimLeft ();
3749  }
3750 
3751  double degrees = 0.0;
3752  double minutes = 0.0;
3753  double seconds = 0.0;
3754 
3755  KKStr degreesStr = "";
3756  KKStr minutesStr = "";
3757  KKStr secondsStr = "";
3758 
3759  kkint32 x = latitudeStr.LocateCharacter (':');
3760  if (x >= 0)
3761  {
3762  degreesStr = latitudeStr.SubStrPart (0, x - 1);
3763  degreesStr.TrimRight ();
3764  minutesStr = latitudeStr.SubStrPart (x + 1);
3765  minutesStr.Trim ();
3766  }
3767  else
3768  {
3769  x = latitudeStr.LocateCharacter (' ');
3770  if (x >= 0)
3771  {
3772  degreesStr = latitudeStr.SubStrPart (0, x - 1);
3773  degreesStr.TrimRight ();
3774  minutesStr = latitudeStr.SubStrPart (x + 1);
3775  minutesStr.Trim ();
3776  }
3777  else
3778  {
3779  degreesStr = latitudeStr;
3780  minutesStr = "";
3781  }
3782  }
3783 
3784  x = minutesStr.LocateCharacter (':');
3785  if (x >= 0)
3786  {
3787  secondsStr = minutesStr.SubStrPart (x + 1);
3788  minutesStr = minutesStr.SubStrPart (0, x - 1);
3789  secondsStr.Trim ();
3790  }
3791  else
3792  {
3793  x = minutesStr.LocateCharacter (' ');
3794  if (x >= 0)
3795  {
3796  secondsStr = minutesStr.SubStrPart (x + 1);
3797  minutesStr = minutesStr.SubStrPart (0, x - 1);
3798  secondsStr.Trim ();
3799  }
3800  }
3801 
3802  degrees = degreesStr.ToDouble ();
3803  minutes = minutesStr.ToDouble ();
3804  seconds = secondsStr.ToDouble ();
3805 
3806  double latitude = degrees + (minutes / 60.0) + (seconds / 3600.0);
3807  while (latitude > 90.0)
3808  latitude = latitude - 180.0;
3809 
3810  if (!north)
3811  latitude = 0.0 - latitude;
3812 
3813  return latitude;
3814 } /* ToLatitude */
KKStr & Trim(const char *whiteSpaceChars="\n\r\t ")
Definition: KKStr.cpp:1686
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr & TrimRight(const char *whiteSpaceChars="\n\r\t ")
Definition: KKStr.cpp:1695
kkint32 LocateCharacter(char ch) const
Returns index of 1st occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2021
double ToDouble() const
Definition: KKStr.cpp:3541
KKStr SubStrPart(kkint32 firstChar) const
returns a SubString consisting of all characters starting at index &#39;firstChar&#39; until the end of the s...
Definition: KKStr.cpp:2780
long KKStr::ToLong ( ) const

Definition at line 3611 of file KKStr.cpp.

Referenced by KKB::KKStrParser::GetNextTokenLong().

3612 {
3613  if (!val)
3614  return 0;
3615 
3616  long l = atol (val);
3617  return l;
3618 } /* ToLong */
double KKStr::ToLongitude ( ) const

Processes string as if a standard longitude; ex: "95:32.2E" = 95.53833.

Definition at line 3819 of file KKStr.cpp.

References ChopFirstChar(), ChopLastChar(), Concat(), FirstChar(), KKStr(), LocateCharacter(), operator=(), SubStrPart(), ToDouble(), Trim(), and TrimRight().

3820 {
3821  KKStr longitudeStr (*this);
3822  bool east = true;
3823  char lastChar = (char)toupper (longitudeStr.LastChar ());
3824  if (lastChar == 'E')
3825  {
3826  east = true;
3827  longitudeStr.ChopLastChar ();
3828  }
3829  else if (lastChar == 'W')
3830  {
3831  east = false;
3832  longitudeStr.ChopLastChar ();
3833  }
3834 
3835  if (longitudeStr.FirstChar () == '-')
3836  {
3837  longitudeStr.ChopFirstChar ();
3838  east = !east;
3839  }
3840 
3841  double degrees = 0.0;
3842  double minutes = 0.0;
3843  double seconds = 0.0;
3844 
3845  KKStr degreesStr = "";
3846  KKStr minutesStr = "";
3847  KKStr secondsStr = "";
3848 
3849  kkint32 x = longitudeStr.LocateCharacter (':');
3850  if (x >= 0)
3851  {
3852  degreesStr = longitudeStr.SubStrPart (0, x - 1);
3853  degreesStr.TrimRight ();
3854  minutesStr = longitudeStr.SubStrPart (x + 1);
3855  minutesStr.Trim ();
3856  }
3857  else
3858  {
3859  x = longitudeStr.LocateCharacter (' ');
3860  if (x >= 0)
3861  {
3862  degreesStr = longitudeStr.SubStrPart (0, x - 1);
3863  degreesStr.TrimRight ();
3864  minutesStr = longitudeStr.SubStrPart (x + 1);
3865  minutesStr.Trim ();
3866  }
3867  else
3868  {
3869  degreesStr = longitudeStr;
3870  minutesStr = "";
3871  }
3872  }
3873 
3874  x = minutesStr.LocateCharacter (':');
3875  if (x >= 0)
3876  {
3877  secondsStr = minutesStr.SubStrPart (x + 1);
3878  minutesStr = minutesStr.SubStrPart (0, x - 1);
3879  secondsStr.Trim ();
3880  }
3881  else
3882  {
3883  x = minutesStr.LocateCharacter (' ');
3884  if (x >= 0)
3885  {
3886  secondsStr = minutesStr.SubStrPart (x + 1);
3887  minutesStr = minutesStr.SubStrPart (0, x - 1);
3888  secondsStr.Trim ();
3889  }
3890  }
3891 
3892  degrees = degreesStr.ToDouble ();
3893  minutes = minutesStr.ToDouble ();
3894  seconds = secondsStr.ToDouble ();
3895 
3896  double longitude = degrees + (minutes / 60.0) + (seconds / 3600.0);
3897  while (longitude > 180.0)
3898  longitude = longitude - 360.0;
3899  if (!east)
3900  longitude = 0.0 - longitude;
3901 
3902  return longitude;
3903 } /* ToLongitude */
KKStr & Trim(const char *whiteSpaceChars="\n\r\t ")
Definition: KKStr.cpp:1686
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr & TrimRight(const char *whiteSpaceChars="\n\r\t ")
Definition: KKStr.cpp:1695
kkint32 LocateCharacter(char ch) const
Returns index of 1st occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2021
double ToDouble() const
Definition: KKStr.cpp:3541
KKStr SubStrPart(kkint32 firstChar) const
returns a SubString consisting of all characters starting at index &#39;firstChar&#39; until the end of the s...
Definition: KKStr.cpp:2780
KKStr KKStr::ToLower ( ) const

Definition at line 2529 of file KKStr.cpp.

References Concat(), KKStr(), and Lower().

Referenced by KKMLL::FeatureFileIO::FeatureFileIO(), and KKB::ReadImage().

2530 {
2531  if (!val)
2532  return "";
2533 
2534  KKStr lowerStr (*this);
2535  lowerStr.Lower ();
2536  return lowerStr;
2537 } /* ToLower */
float KKStr::ToPercentage ( ) const

Definition at line 3623 of file KKStr.cpp.

References Concat(), LastChar(), Len(), SubStrPart(), and ToFloat().

3624 {
3625  if (LastChar () == '%')
3626  {
3627  KKStr workStr = this->SubStrPart (0, Len () - 2);
3628  return workStr.ToFloat ();
3629  }
3630 
3631  return 100.0f * ToFloat ();
3632 }
char LastChar() const
Definition: KKStr.cpp:2007
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
float ToFloat() const
Definition: KKStr.cpp:3553
KKStr SubStrPart(kkint32 firstChar) const
returns a SubString consisting of all characters starting at index &#39;firstChar&#39; until the end of the s...
Definition: KKStr.cpp:2780
KKStr KKB::KKStr::ToQuotedStr ( ) const
inline

Definition at line 540 of file KKStr.h.

References QuotedStr().

540 {return QuotedStr ();}
KKStr QuotedStr() const
Returns a quoted version of string where special characters Line-Feed, Carriage Return, and Tab, are encoded as escape sequences.
Definition: KKStr.cpp:2890
kkuint32 KKStr::ToUint ( ) const

Definition at line 3636 of file KKStr.cpp.

Referenced by KKB::KKStrParser::GetNextTokenUint().

3637 {
3638  if (!val) return 0;
3639  return (kkuint32)atol (val);
3640 }
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
KKB::kkuint32 KKStr::ToUint32 ( ) const

Definition at line 3652 of file KKStr.cpp.

3653 {
3654  if (!val) return 0;
3655  return (kkuint32)atol (val);
3656 }
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
KKB::kkuint64 KKStr::ToUint64 ( ) const

Definition at line 3660 of file KKStr.cpp.

Referenced by ExtractTokenUint64().

3661 {
3662  if (!val) return 0;
3663  #if defined(__GNUC__)
3664  return (kkuint64)atoll (val);
3665  #else
3666  return (kkuint64)_atoi64 (val);
3667  #endif
3668 }
unsigned __int64 kkuint64
Definition: KKBaseTypes.h:91
KKB::ulong KKStr::ToUlong ( ) const

Definition at line 3644 of file KKStr.cpp.

3645 {
3646  if (!val) return 0;
3647  return (ulong)atol (val);
3648 }
unsigned long ulong
Unsigned long.
Definition: KKBaseTypes.h:80
KKStr KKStr::ToUpper ( ) const

Definition at line 2517 of file KKStr.cpp.

References Concat(), KKStr(), and Upper().

Referenced by KKMLL::MLClass::CreateNewMLClass(), KKMLL::ModelParam::EncodingMethodFromStr(), KKMLL::EncodingMethodFromStr(), KKMLL::MachineTypeFromStr(), KKMLL::Attribute::ReadXML(), and KKMLL::SelectionMethodFromStr().

2518 {
2519  if (!val)
2520  return "";
2521 
2522  KKStr upperStr (*this);
2523  upperStr.Upper ();
2524  return upperStr;
2525 } /* ToUpper */
VectorInt32 * KKStr::ToVectorInt32 ( ) const

Definition at line 3671 of file KKStr.cpp.

References Concat(), Empty(), KKB::KKStrParser::GetNextToken(), KKB::KKStrParser::KKStrParser(), LocateCharacter(), operator=(), SubStrPart(), and ToInt32().

3672 {
3673  VectorInt32* results = new VectorInt32 ();
3674 
3675  KKStrParser parser (val);
3676 
3677  KKStr field = parser.GetNextToken (",\t \n\r");
3678  while (!field.Empty ())
3679  {
3680  kkint32 dashPos = field.LocateCharacter ('-');
3681  if (dashPos < 0)
3682  {
3683  // This is not a range
3684  results->push_back (field.ToInt32 ());
3685  }
3686  else
3687  {
3688  // We are looking at a range
3689  kkint32 startNum = field.SubStrPart (0, dashPos - 1).ToInt32 ();
3690  kkint32 endNum = field.SubStrPart (dashPos + 1).ToInt32 ();
3691  for (kkint32 z = startNum; z <= endNum; ++z)
3692  results->push_back (z);
3693  }
3694  field = parser.GetNextToken (",\t \n\r");
3695  }
3696  return results;
3697 } /* ToVectorint32 */
__int32 kkint32
Definition: KKBaseTypes.h:88
bool Empty() const
Definition: KKStr.h:241
kkint32 ToInt32() const
Definition: KKStr.cpp:3587
std::vector< kkint32 > VectorInt32
Vector of signed 32 bit integers.
Definition: KKBaseTypes.h:144
kkint32 LocateCharacter(char ch) const
Returns index of 1st occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2021
Class that manages the extraction of tokens from a String without being destructive to the original s...
Definition: KKStrParser.h:18
KKStr SubStrPart(kkint32 firstChar) const
returns a SubString consisting of all characters starting at index &#39;firstChar&#39; until the end of the s...
Definition: KKStr.cpp:2780
wchar_t * KKStr::ToWchar_t ( ) const

Definition at line 3703 of file KKStr.cpp.

Referenced by KKB::ReadImageUsingGDI().

3704 {
3705  wchar_t* wa = NULL;
3706  if (val == NULL)
3707  {
3708  wa = new wchar_t[1];
3709  mbstowcs (wa, "", 1);
3710  return wa;
3711  }
3712  else
3713  {
3714  size_t wideLen = len + 1;
3715  wa = new wchar_t[wideLen];
3716  mbstowcs (wa, val, wideLen);
3717  }
3718  return wa;
3719 }
KKStr KKStr::ToXmlStr ( ) const

Definition at line 2929 of file KKStr.cpp.

References Append(), Concat(), EmptyStr(), KKStr(), and Len().

2930 {
2931  if ((!val) || (len < 1))
2932  {
2933  return KKStr::EmptyStr ();
2934  }
2935 
2936  KKStr result (Len () + 5);
2937 
2938  kkint32 idx = 0;
2939  while (idx < len)
2940  {
2941  switch (val[idx])
2942  {
2943  case '<' : result.Append ("&lt;"); break;
2944  case '>' : result.Append ("&gt;"); break;
2945  case '&' : result.Append ("&amp;"); break;
2946  case '\"': result.Append ("&quot;"); break;
2947  case '\'': result.Append ("&apos;"); 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;
2953 
2954  default: result.Append (val[idx]); break;
2955  }
2956 
2957  idx++;
2958  }
2959 
2960  return result;
2961 } /* ToXmlStr */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
static const KKStr & EmptyStr()
Static method that returns an Empty String.
Definition: KKStr.cpp:3453
KKStr & KKStr::Trim ( const char *  whiteSpaceChars = "\n\r\t ")

Definition at line 1686 of file KKStr.cpp.

References TrimLeft(), and TrimRight().

Referenced by KKB::osReadRestOfLine(), ToLatitude(), and ToLongitude().

1687 {
1688  TrimRight (whiteSpaceChars);
1689  TrimLeft(whiteSpaceChars);
1690  return *this;
1691 } /* Trim */
KKStr & TrimRight(const char *whiteSpaceChars="\n\r\t ")
Definition: KKStr.cpp:1695
void TrimLeft(const char *whiteSpaceChars="\n\r\t ")
Definition: KKStr.cpp:1745
void KKStr::TrimLeft ( const char *  whiteSpaceChars = "\n\r\t ")

Definition at line 1745 of file KKStr.cpp.

Referenced by KKMLL::FeatureFileIODstWeb::AttrDescLine::AttrDescLine(), KKB::CmdLineExpander::CmdLineExpander(), KKMLL::FeatureNumList::ExtractFeatureNumsFromStr(), KKMLL::MLClassList::ExtractThreeTitleLines(), KKB::PointList::FromDelStr(), KKMLL::FeatureFileIODstWeb::GetFileDesc(), KKMLL::FeatureFileIOUCI::GetFileDesc(), KKMLL::FeatureFileIOUCI::LoadFile(), KKB::operator>>(), Parse(), KKMLL::ModelParam::ParseCmdLine(), KKMLL::ModelParamOldSVM::ParseCmdLine(), Split(), KKJobManagment::KKJobManager::StatusFileProcessLine(), KKJobManagment::KKJobManager::StatusFileProcessLineJobStatusChange(), SVM233::svm_parameter::svm_parameter(), ToLatitude(), Trim(), and Wide().

1746 {
1747  #ifdef KKDEBUG
1748  ValidateLen ();
1749  #endif
1750 
1751 
1752  if (!val)
1753  {
1754  AllocateStrSpace (1);
1755  len = 0;
1756  return;
1757  }
1758 
1759  kkuint16 x = 0;
1760 
1761  while ((strchr (whiteSpaceChars, val[x])) && (val[x] != 0))
1762  x++;
1763 
1764  if (x == 0)
1765  return;
1766 
1767  kkuint16 y = 0;
1768 
1769  while (x < len)
1770  {
1771  val[y] = val[x];
1772  x++;
1773  y++;
1774  }
1775 
1776  len = y;
1777  val[len] = 0;
1778 } /* TrimLeft */
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
KKStr & KKStr::TrimRight ( const char *  whiteSpaceChars = "\n\r\t ")

Definition at line 1695 of file KKStr.cpp.

Referenced by KKMLL::FeatureFileIODstWeb::AttrDescLine::AttrDescLine(), KKB::CmdLineExpander::CmdLineExpander(), KKMLL::MLClassList::ExtractThreeTitleLines(), KKMLL::FeatureFileIODstWeb::GetFileDesc(), KKMLL::FeatureFileIOUCI::GetFileDesc(), KKB::KKStrParser::GetRestOfLine(), KKB::KKStrParser::GetRestOfStr(), KKMLL::MLClassList::Load(), KKMLL::FeatureFileIOUCI::LoadFile(), KKB::operator>>(), KKB::osReadRestOfLine(), Parse(), KKB::KKStrList::ParseDelimitedString(), ReadXML(), Split(), KKJobManagment::KKJobManager::StatusFileProcessLine(), KKJobManagment::KKJobManager::StatusFileProcessLineJobStatusChange(), ToLatitude(), ToLongitude(), Trim(), and Wide().

1696 {
1697  #ifdef KKDEBUG
1698  ValidateLen ();
1699  #endif
1700 
1701  if (!val)
1702  {
1703  AllocateStrSpace (1);
1704  len = 0;
1705  return *this;
1706  }
1707 
1708  kkint32 x = len - 1;
1709  while ((len > 0) && (strchr (whiteSpaceChars, val[x])))
1710  {
1711  val[x] = 0;
1712  x--;
1713  len--;
1714  }
1715 
1716  return *this;
1717 } /* TrimRight */
__int32 kkint32
Definition: KKBaseTypes.h:88
void KKStr::TrimRightChar ( )

Definition at line 1723 of file KKStr.cpp.

1724 {
1725  #ifdef KKDEBUG
1726  ValidateLen ();
1727  #endif
1728 
1729  if (!val)
1730  {
1731  AllocateStrSpace (1);
1732  len = 0;
1733  return;
1734  }
1735 
1736  if (len > 0)
1737  {
1738  len--;
1739  val[len] = 0;
1740  }
1741 } /* TrimRightChar */
bool KKStr::ValidInt ( kkint32 value)

returns true if KKStr is formated as a valid integer otherwise false.

Parameters
[out]valueof string as interpreted as a integer.

Definition at line 2548 of file KKStr.cpp.

2549 {
2550 
2551  kkint32 sign = 1;
2552 
2553  value = 0;
2554 
2555  if (!val)
2556  return false;
2557  else
2558  {
2559  char* ch = val;
2560 
2561  // Skip over white space
2562 
2563  while ((strchr (" \n\t", *ch)) && (*ch))
2564  ch++;
2565 
2566  if (!(*ch))
2567  return false;
2568 
2569  if (*ch == '-')
2570  {
2571  ch++;
2572  sign = -1;
2573  }
2574 
2575  kkint32 digit;
2576 
2577  digit = (*ch - '0');
2578 
2579  while ((digit >= 0) && (digit <= 9))
2580  {
2581  value = value * 10 + digit;
2582  ch++;
2583  digit = (*ch - '0');
2584  }
2585 
2586  value = value * sign;
2587 
2588  return (*ch == 0);
2589  }
2590 }
__int32 kkint32
Definition: KKBaseTypes.h:88
bool KKStr::ValidMoney ( float &  value) const

Definition at line 2594 of file KKStr.cpp.

2595 {
2596  kkint32 digit = 0;
2597  kkint32 sign = 1;
2598  value = 0;
2599  if (!val)
2600  return false;
2601 
2602  char* ch = val;
2603 
2604  // Skip over white space
2605  while ((strchr (" \n\t", *ch)) && (*ch))
2606  ch++;
2607  if (!(*ch))
2608  return false;
2609 
2610  bool decimalFound = false;
2611  kkint32 decimalDigits = 0;
2612 
2613  if (*ch == '-')
2614  {
2615  ch++;
2616  sign = -1;
2617  }
2618 
2619  digit = (*ch - '0');
2620  while (((digit >= 0) && (digit <= 9)) || (*ch == '.'))
2621  {
2622  if (*ch == '.')
2623  {
2624  if (decimalFound)
2625  return false;
2626  decimalFound = true;
2627  }
2628  else
2629  {
2630  if (decimalFound)
2631  decimalDigits++;
2632  value = value * 10 + digit;
2633  }
2634  ch++;
2635  digit = (*ch - '0');
2636  }
2637 
2638  if (decimalDigits > 2)
2639  return false;
2640 
2641  while (decimalDigits > 0)
2642  {
2643  value = value / 10;
2644  decimalDigits--;
2645  }
2646 
2647  value = value * sign;
2648  return (*ch == 0);
2649 } // ValidMoney
__int32 kkint32
Definition: KKBaseTypes.h:88
bool KKStr::ValidNum ( double &  value) const

Returns true if String is a valid number, ex 1.0 or -3.123, etc

Definition at line 2653 of file KKStr.cpp.

2654 {
2655  kkint32 digit = 0;
2656  kkint32 sign = 1;
2657  value = 0.0;
2658  value = 0;
2659  if (!val)
2660  return false;
2661 
2662  char* ch = val;
2663 
2664  // Skip over white space
2665  while ((strchr (" \n\t", *ch)) && (*ch))
2666  ch++;
2667  if (!(*ch))
2668  return false;
2669 
2670  bool decimalFound = false;
2671  kkint32 decimalDigits = 0;
2672 
2673  if (*ch == '-')
2674  {
2675  ch++;
2676  sign = -1;
2677  }
2678 
2679  digit = (*ch - '0');
2680 
2681  while (((digit >= 0) && (digit <= 9)) || (*ch == '.'))
2682  {
2683  if (*ch == '.')
2684  {
2685  if (decimalFound)
2686  return false;
2687  decimalFound = true;
2688  }
2689  else
2690  {
2691  if (decimalFound)
2692  decimalDigits++;
2693  value = value * 10 + digit;
2694  }
2695  ch++;
2696  digit = (*ch - '0');
2697  }
2698 
2699  while (decimalDigits > 0)
2700  {
2701  value = value / 10;
2702  decimalDigits--;
2703  }
2704 
2705  value = value * sign;
2706  return (*ch == 0);
2707 } /* ValidNum */
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr 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, right, or center as specified by 'dir'. If KKStr Already greater than 'width' will truncate new string. /summary> param name='width'> Width of KKStr; will pad KKStr with spaces until it is width long. param name='dir'>Direction to pad from 'L' - Pad on the left side, 'R' - Pad on the right side, and 'C' - Pad on left and Right so that text is centered.

Definition at line 2203 of file KKStr.cpp.

References Concat(), KKStr(), LeftPad(), Len(), KKB::operator+(), operator=(), RightPad(), Spaces(), Str(), TrimLeft(), and TrimRight().

2206 {
2207  #ifdef KKDEBUG
2208  ValidateLen ();
2209  #endif
2210 
2211 
2212  KKStr str (val);
2213  if ((dir == 'L') || (dir == 'l'))
2214  str.LeftPad (width, ' ');
2215 
2216  else if ((dir == 'C') || (dir == 'c'))
2217  {
2218  str.TrimRight ();
2219  str.TrimLeft ();
2220 
2221  kkint32 x = (width - str.Len ()) / 2;
2222 
2223  if (x > 0)
2224  {
2225  str = Spaces (x).Str () + str;
2226  str.RightPad (width, ' ');
2227  }
2228  }
2229 
2230  else
2231  str.RightPad (width, ' ');
2232 
2233  return str;
2234 } /* Wide */
__int32 kkint32
Definition: KKBaseTypes.h:88
static KKStr Spaces(kkint32 c)
Returns a string of spaces &#39;c&#39; characters long.
Definition: KKStr.cpp:4329
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
void KKStr::WriteXML ( const KKStr varName,
std::ostream &  o 
) const

Definition at line 4420 of file KKStr.cpp.

References KKB::XmlTag::AddAtribute(), Empty(), KKB::XmlTag::tagEnd, KKB::XmlTag::tagStart, KKB::XmlTag::WriteXML(), KKB::XmlContent::WriteXml(), and KKB::XmlTag::XmlTag().

Referenced by KKMLL::Model::WriteModelXMLFields(), KKMLL::ModelParamSvmBase::WriteXML(), KKMLL::ModelParamDual::WriteXML(), KKMLL::FeatureEncoder::WriteXML(), KKMLL::ModelParamOldSVM::WriteXML(), KKMLL::TrainingClassList::WriteXML(), SVM233::SvmModel233::WriteXML(), SVM289_MFS::Svm_Model::WriteXML(), KKMLL::ModelOldSVM::WriteXML(), KKMLL::SVMModel::WriteXML(), KKMLL::TrainingProcess2::WriteXML(), and KKMLL::ModelParam::WriteXMLFields().

4423 {
4424  XmlTag startTag ("KKStr", XmlTag::TagTypes::tagStart);
4425  if (!varName.Empty ())
4426  startTag.AddAtribute ("VarName", varName);
4427  startTag.AddAtribute ("Len", len);
4428  startTag.WriteXML (o);
4429  XmlContent::WriteXml (val, o);
4430  XmlTag endTag ("KKStr", XmlTag::TagTypes::tagEnd);
4431  endTag.WriteXML (o);
4432  o << endl;
4433 } /* WriteXML */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
bool Empty() const
Definition: KKStr.h:241
static void WriteXml(const KKStr &s, std::ostream &o)
Definition: XmlStream.cpp:853

The documentation for this class was generated from the following files: