KSquare Utilities
KKB Namespace Reference

KKB The namespace for KKBase Library supporting general functionality needed by almost any application. More...

Classes

class  Application
 The base class for all standalone application. More...
 
class  Atom
 Base class of all other classes that are meant to be managed by 'KKBase'. More...
 
class  BitString
 Allows you to manage very long bit strings. More...
 
class  Blob
 Used by the Raster object to identify a distinct blob; where it is in the raster and its unique id. More...
 
class  BlobList
 Maintains a list of blobs. More...
 
class  BmpImage
 Used to encode and decode BMP Images. More...
 
class  Chart
 Used to Create chart's from defined series of data. More...
 
class  CmdLineExpander
 Expands command line parameters, by parsing for special parameters and expanding them to their full value. More...
 
class  Compressor
 Simple class that will compress and decompress specified buffers using the routines provided in zlib. More...
 
class  Configuration
 General purpose Configuration File manager class. More...
 
class  ContourFollower
 
class  ConvexHull
 Operator that will create a Convex Hull of a supplied image. More...
 
class  DateTime
 
class  DateType
 Represents a calendar date consisting of three fields, Year, Month, and Day. More...
 
class  GlobalGoalKeeper
 Maintains one instance of a GoalKeeper object that can be used anywhere in the application. More...
 
class  GoalKeeper
 
class  GoalKeeperList
 
class  GoalKeeperSimple
 A simple/ light-weight implementation of critical section blocking. More...
 
class  GoalKeeperSimpleList
 
class  HashTable
 
class  Histogram
 Used to manage the construction of a Histogram. More...
 
class  HTMLReport
 
class  ImageDirTree
 Creates a index of all images in a specified directory structure. More...
 
class  Iterator
 
class  KK_DFT1D
 
class  KK_DFT2D
 
class  KKException
 
class  KKObservable
 The base class to be used by Observer classes. More...
 
class  KKObserver
 The base class to be used by Observer classes. More...
 
class  KKQueue
 A typed container class/template that keeps track of entries via pointers only. More...
 
class  KKStr
 
class  KKStrList
 
class  KKStrListIndexed
 
class  KKStrMatrix
 A two dimensional matrix of Strings. More...
 
class  KKStrParser
 Class that manages the extraction of tokens from a String without being destructive to the original string. More...
 
class  KKThread
 The base class to be used any thread. More...
 
class  KKThreadList
 
class  KKThreadManager
 
class  Matrix
 Supports two dimensional matrices. More...
 
class  MorphOp
 Base class for all Morphological operations. More...
 
class  MorphOpBinarize
 
class  MorphOpBmiFiltering
 
class  MorphOpDilation
 
class  MorphOpErosion
 
class  MorphOpMaskExclude
 
class  MorphOpSobel
 
class  MorphOpStretcher
 
class  MorphOpStruct
 
struct  MovDir
 
class  MsgQueue
 Will manage a buffer that will allow multiple threads to add and remove messages to a queue. More...
 
class  PixelValue
 Used by the Raster Class to represent the contents of one pixel. More...
 
class  Point
 Used by Raster class and MorphOp derived classes to denote a single pixel location in Raster image. More...
 
class  PointList
 Container object used to maintaining a list of pixel locations. More...
 
class  RandomNumGenerator
 Represents one single random number generator. More...
 
class  Raster
 A class that is used by to represent a single image in memory. More...
 
class  RasterBuffer
 Will manage a buffer that will allow multiple threads to add and remove instances of 'Raster' objects. More...
 
class  RasterList
 
class  RBnode
 
class  RBTree
 
class  Row
 
class  RunLog
 Used for logging messages. More...
 
class  SegmentorOTSU
 
class  SimpleCompressor
 
class  TimeType
 Represents a Time, consisting of three fields, Hour, Minute, and Second. summary>Represents Date and Time, consists of two member classes DateType and TimeType. More...
 
class  TokenBuffer
 
class  TokenBufferStr
 
class  TokenBufferStream
 
class  Tokenizer
 Class is meant to break down a stream into a set of logical tokens. More...
 
class  VectorKKStr
 
union  WordFormat32Bits
 Structure used to break 32 bit word into different formats;. More...
 
class  XmlAttribute
 
class  XmlAttributeList
 
class  XmlContent
 
class  XmlElement
 
class  XmlElementArrayDouble
 
class  XmlElementArrayFloat
 
class  XmlElementArrayFloat2D
 
class  XmlElementArrayFloat2DVarying
 
class  XmlElementArrayInt32
 
class  XmlElementArrayUint16
 
class  XmlElementBool
 
class  XmlElementDateTime
 
class  XmlElementDouble
 
class  XmlElementFloat
 
class  XmlElementInt32
 
class  XmlElementInt64
 
class  XmlElementKeyValuePairs
 
class  XmlElementKKStr
 
class  XmlElementTemplate
 
class  XmlElementUnKnown
 XmlElement derived class that will be used when there is no Factory defined for the element. More...
 
class  XmlElementVectorFloat
 
class  XmlElementVectorInt32
 
class  XmlFactory
 
class  XmlFactoryManager
 
class  XmlStream
 Manages the reading and writing of objects in a simple XML format. For a class to be supported by XmlStream it must implement: More...
 
class  XmlTag
 
class  XmlToken
 
class  XmlTokenizer
 Manages the break down a stream into a set of logical tokens compatible with the XML format. More...
 

Typedefs

typedef BitStringBitStringPtr
 
typedef BlobListBlobListPtr
 
typedef BlobBlobPtr
 
typedef BmpImageBmpImagePtr
 
typedef CmdLineExpanderCmdLineExpanderPtr
 
typedef std::complex< double > ComplexDouble
 
typedef ConfigurationConfigurationPtr
 
typedef char const *const *const ConstCharStarArray
 
typedef ConvexHullConvexHullPtr
 
typedef GoalKeeperListGoalKeeperListPtr
 
typedef GoalKeeperGoalKeeperPtr
 
typedef GoalKeeperSimpleListGoalKeeperSimpleListPtr
 
typedef GoalKeeperSimple::GoalKeeperSimplePtr GoalKeeperSimplePtr
 
typedef HashEntry * HashEntryPtr
 
typedef HistogramHistogramPtr
 
typedef HTMLReport::HTMLReportPtr HTMLReportPtr
 
typedef KK_DFT1D< double > KK_DFT1D_Double
 
typedef KK_DFT1D< float > KK_DFT1D_Float
 
typedef KK_DFT2D< double > KK_DFT2D_Double
 
typedef KK_DFT2D< float > KK_DFT2D_Float
 
typedef __int16 kkint16
 16 bit signed integer. More...
 
typedef __int32 kkint32
 
typedef __int64 kkint64
 
typedef __int8 kkint8
 
typedef KKObservableKKObservablePtr
 
typedef KKObserver::KKObserverPtr KKObserverPtr
 
typedef KKStr const KKStrConst
 
typedef KKStr::KKStrConstPtr KKStrConstPtr
 
typedef KKStrList::KKStrListPtr KKStrListPtr
 
typedef KKStrMatrix::KKStrMatrixPtr KKStrMatrixPtr
 
typedef std::pair< KKStr, KKStrKKStrPair
 
typedef KKStr::KKStrPtr KKStrPtr
 
typedef KKThreadListKKThreadListPtr
 
typedef KKThreadManagerKKThreadManagerPtr
 
typedef KKTHread * KKTHreadPtr
 
typedef KKThread::KKThreadPtr KKThreadPtr
 
typedef unsigned __int16 kkuint16
 16 bit unsigned integer. More...
 
typedef unsigned __int32 kkuint32
 
typedef unsigned __int64 kkuint64
 
typedef unsigned __int8 kkuint8
 
typedef MorphOp::MaskTypes MaskTypes
 
typedef MatrixMatrixPtr
 
typedef MorphOpBmiFilteringMorphBmiFilteringPtr
 
typedef KKQueue< MorphOpMorphologicalOperatorList
 
typedef MorphologicalOperatorListMorphologicalOperatorListPtr
 
typedef MorphOpMaskExcludeMorphologicalOperatorMastPtr
 
typedef MorphOpBinarizeMorphOpBinarizePtr
 
typedef MorphOpDilationMorphOpDialationPtr
 
typedef MorphOpErosionMorphOpErosionPtr
 
typedef MorphOpMorphOpPtr
 
typedef MorphOpStretcherMorphOpStretcherPtr
 
typedef MorphOpStructMorphOpStructPtr
 
typedef MsgQueueMsgQueuePtr
 
typedef long long osFilePos
 
typedef PixelValuePixelValuePtr
 
typedef PointList::PointListPtr PointListPtr
 
typedef PointPointPtr
 
typedef RasterBuffer::RasterBufferPtr RasterBufferPtr
 
typedef Raster::RasterConstPtr RasterConstPtr
 
typedef RasterListRasterListPtr
 
typedef RasterRasterPtr
 
typedef RowRowPtr
 
typedef RunLogRunLogPtr
 
typedef vector< SeriesPtrSeriesList
 
typedef Chart::SeriesPtr SeriesPtr
 
typedef KKStrList::KKStrListPtr StringListPtr
 summary> Maintains a list of ordered KKStr instances that can be recalled by either string of index. More...
 
typedef MorphOp::StructureType StructureType
 
typedef TokenBufferTokenBufferPtr
 
typedef TokenBufferStreamTokenBufferStreamPtr
 
typedef TokenizerTokenizerPtr
 
typedef unsigned char uchar
 Unsigned character. More...
 
typedef unsigned int uint
 Unsigned integer. More...
 
typedef unsigned long ulong
 Unsigned long. More...
 
typedef unsigned short ushort
 Unsigned short. More...
 
typedef std::vector< bool > VectorBool
 
typedef std::vector< char > VectorChar
 
typedef VectorCharVectorCharPtr
 
typedef std::vector< double > VectorDouble
 Vector of doubles. More...
 
typedef VectorDoubleVectorDoubletPtr
 
typedef std::vector< float > VectorFloat
 
typedef VectorFloatVectorFloatPtr
 
typedef std::vector< int > VectorInt
 
typedef std::vector< kkint16VectorInt16
 Vector of signed 16 bit integers. More...
 
typedef std::vector< kkint32VectorInt32
 Vector of signed 32 bit integers. More...
 
typedef VectorInt32VectorInt32Ptr
 
typedef std::vector< kkint64VectorInt64
 
typedef VectorInt64VectorInt64Ptr
 
typedef VectorIntVectorIntPtr
 
typedef std::vector< PointVectorPoint
 
typedef std::vector< short > VectorShort
 
typedef VectorShortVectorShortPtr
 
typedef std::vector< ucharVectorUchar
 
typedef VectorUcharVectorUcharPtr
 
typedef std::vector< uintVectorUint
 
typedef std::vector< kkuint16VectorUint16
 Vector of unsigned 16 bit integers. More...
 
typedef std::vector< kkuint32VectorUint32
 Vector of unsigned 32 bit integers. More...
 
typedef std::vector< kkuint64VectorUint64
 
typedef std::vector< ulongVectorUlong
 
typedef VectorUlongVectorUlongPtr
 
typedef volatile const bool VolConstBool
 
typedef XmlAttribute const XmlAttributeConst
 
typedef XmlAttributeConstXmlAttributeConstPtr
 
typedef XmlAttributeListXmlAttributeListPtr
 
typedef XmlAttributeXmlAttributePtr
 
typedef XmlContentXmlContentPtr
 
typedef XmlElementArrayDoubleXmlElementArrayDoublePtr
 
typedef XmlElementArrayFloat2DXmlElementArrayFloat2DPtr
 
typedef XmlElementArrayFloat2DVaryingXmlElementArrayFloat2DVaryingPtr
 
typedef XmlElementArrayFloatXmlElementArrayFloatPtr
 
typedef XmlElementArrayInt32XmlElementArrayInt32Ptr
 
typedef XmlElementArrayUint16XmlElementArrayUint16Ptr
 
typedef XmlElementTemplate< BitStringXmlElementBitString
 
typedef XmlElementBoolXmlElementBoolPtr
 
typedef XmlElementDateTimeXmlElementDateTimePtr
 
typedef XmlElementDoubleXmlElementDoublePtr
 
typedef XmlElementFloatXmlElementFloatPtr
 
typedef XmlElementInt32XmlElementInt32Ptr
 
typedef XmlElementInt64XmlElementInt64Ptr
 
typedef XmlElementKeyValuePairsXmlElementKeyValuePairsPtr
 
typedef XmlElementTemplate< KKStrListXmlElementKKStrList
 
typedef XmlElementTemplate< KKStrListIndexedXmlElementKKStrListIndexed
 
typedef XmlElementKKStrListIndexedXmlElementKKStrListIndexedPtr
 
typedef XmlElementKKStrListXmlElementKKStrListPtr
 
typedef XmlElementKKStrXmlElementKKStrPtr
 
typedef XmlElementXmlElementPtr
 
typedef XmlElementUnKnownXmlElementUnKnownPtr
 
typedef XmlElementVectorFloatXmlElementVectorFloatPtr
 
typedef XmlElementVectorInt32XmlElementVectorInt32Ptr
 
typedef XmlElementTemplate< VectorKKStrXmlElementVectorKKStr
 
typedef XmlElementVectorKKStrXmlElementVectorKKStrPtr
 
typedef XmlFactory const * XmlFactoryConstPtr
 summary>To be used for classes that implement default constructor, ReadXML, and WriteXML. More...
 
typedef XmlFactoryManagerXmlFactoryManagerPtr
 
typedef XmlFactoryXmlFactoryPtr
 
typedef XmlStreamXmlStreamPtr
 
typedef XmlTag const XmlTagConst
 
typedef XmlTag const * XmlTagConstPtr
 
typedef XmlTagXmlTagPtr
 
typedef XmlTokenizerXmlTokenizerPtr
 
typedef XmlTokenXmlTokenPtr
 

Enumerations

enum  ColorChannels { ColorChannels::Red, ColorChannels::Green, ColorChannels::Blue }
 
enum  RBcolor { RBcolor::Red, RBcolor::Black }
 

Functions

template<typename T >
Calc3TTLQC (const vector< T > &v, kkint32 b)
 
template<typename T >
CalcBQV (const vector< T > &v, kkint32 blockSize)
 
template<typename T >
void CalcMeanAndStdDev (const vector< T > &v, T &mean, T &stdDev)
 
template<typename T >
CalcPQV (const vector< T > &v, kkint32 distance)
 
template<typename T >
CalcTTLQC (const vector< T > &v, kkint32 b)
 
template<typename T >
void CalcVectorStats (const vector< T > &v, T &total, T &mean, T &stdDev, T &min, T &max)
 
ColorChannels ColorChannelFromKKStr (const KKStr &s)
 
KKStr ColorChannelToKKStr (ColorChannels c)
 
void DefineImageIoAtExit ()
 
void DisplayImage (const Raster &raster, const KKStr &title)
 
void DisplayImage (const Raster &image)
 
HTMLReport &__cdecl endl (HTMLReport &htmlReport)
 
void FFT (float data[], kkuint32 number_of_complex_samples, kkint32 isign)
 
float FloatAbs (float f)
 
void ImageIoFinaleCleanUp ()
 
bool IsFinite (const float &f)
 
bool IsFinite (const double &f)
 
bool IsNaN (const float &f)
 
bool IsNaN (const double &d)
 
template<typename T >
T * kkReallocateArray (T *oldA, kkint32 oldSize, kkint32 newSize)
 
float LLoydsIndexOfPatchiness (const KKB::VectorInt &bins)
 
float Log2 (float x)
 
kkint32 LRand48 ()
 A implementations of the Unix version of rand48 returning a 32 bit integer. More...
 
template<class T >
Max (T a, T b)
 generic Max function, Both parameters must be of the same type. More...
 
template<class T >
Max (T a, T b, T c)
 Generic Max function, that takes three parameters. All three parameters must be of the same type. More...
 
template<class T >
Max (T a, T b, T c, T d)
 Generic Max function, that takes four parameters. All four parameters must be of the same type. More...
 
template<class T >
Max (T x0, T x1, T x2, T x3, T x4)
 Generic Max function, that takes five parameters of the same type. More...
 
template<class T >
Max (T x0, T x1, T x2, T x3, T x4, T x5)
 Generic Max function, that takes six parameters of the same type. More...
 
template<class T >
Max (T x0, T x1, T x2, T x3, T x4, T x5, T x6)
 Generic Max function, that takes seven parameters of the same type. More...
 
template<class T >
Max (T x0, T x1, T x2, T x3, T x4, T x5, T x6, T x7)
 Generic Max function, that takes eight parameters of the same type. More...
 
float McNemarsTest (kkint32 size, const bool *classedCorrectly1, const bool *classedCorrectly2)
 
template<class T >
Min (T a, T b)
 Generic Min function, Both parameters must be of the same type. More...
 
KKStr operator+ (const char left, const KKStr &right)
 
KKStr operator+ (const char *left, const KKStr &right)
 
Matrix operator- (double left, const Matrix &right)
 
HTMLReport &__cdecl operator<< (HTMLReport &htmlReport, HTMLReport &(__cdecl *mf)(HTMLReport &))
 
HTMLReportoperator<< (HTMLReport &htmlReport, kkint32 right)
 
HTMLReportoperator<< (HTMLReport &htmlReport, kkuint32 right)
 
HTMLReportoperator<< (HTMLReport &htmlReport, kkint64 right)
 
HTMLReportoperator<< (HTMLReport &htmlReport, kkuint64 right)
 
HTMLReportoperator<< (HTMLReport &htmlReport, double right)
 
HTMLReportoperator<< (HTMLReport &htmlReport, char right)
 
HTMLReportoperator<< (HTMLReport &htmlReport, const char *right)
 
KKStroperator<< (KKStr &left, const Point &right)
 
HTMLReportoperator<< (HTMLReport &htmlReport, const KKStr &right)
 
std::ostream & operator<< (std::ostream &left, const Point &right)
 
HTMLReportoperator<< (HTMLReport &htmlReport, KKStrConstPtr right)
 
HTMLReportoperator<< (HTMLReport &htmlReport, const DateTime &right)
 
KKStroperator<< (KKB::KKStr &left, const DateType &right)
 
KKStroperator<< (KKB::KKStr &left, const TimeType &right)
 
KKStroperator<< (KKB::KKStr &left, const DateTime &right)
 
std::ostream & operator<< (std::ostream &os, const DateType &right)
 
std::ostream & operator<< (std::ostream &os, const TimeType &right)
 
std::ostream & operator<< (std::ostream &os, const DateTime &right)
 
std::ostream &__cdecl operator<< (std::ostream &os, const KKStr &str)
 
std::istream &__cdecl operator>> (std::istream &is, KKStr &str)
 
void osAddLastSlash (KKStr &fileSpec)
 Will add the appropriate Directory separator character to the end of fileSpec if one is not there already. More...
 
KKB::KKStr osAddSlash (const KKStr &fileSpec)
 
void osChangeDir (const KKStr &dirName, bool &successful)
 
bool osCopyFile (const KKStr &srcFileName, const KKStr &destFileName)
 
bool osCopyFileBetweenDirectories (const KKStr &_fileName, const KKStr &_srcDir, const KKStr &_destDir)
 
bool osCreateDirectory (const KKStr &dirName)
 
bool osCreateDirectoryPath (KKStr _pathName)
 Will create the whole Directory Path not just the final part of the path. More...
 
KKStr osCreateUniqueFileName (KKStr fileName)
 Get a unique file name based off file spec 'fileName'. More...
 
bool osDeleteFile (KKStr _fileName)
 
void osDisplayWarning (KKStr _message)
 
bool osFileExists (const KKStr &_fileName)
 
FILE * osFOPEN (const char *fileName, const char *mode)
 
int osFSEEK (FILE *f, kkint64 offset, int origin)
 
kkint64 osFTELL (FILE *f)
 Calls the appropriate 64 bit function for operating system. More...
 
KKStr osGetCurrentDirectory ()
 
KKStr osGetDirNameFromPath (KKStr dirPath)
 Extracts the final sub-directory name of the fill directory specification. More...
 
char osGetDriveLetter (const KKStr &pathName)
 Given a full drive with path and name return the drive letter specified. More...
 
KKStrPtr osGetEnvVariable (const KKStr &_varName)
 
KKStr osGetErrorNoDesc (kkint32 errorNo)
 
KKB::DateTime osGetFileDateTime (const KKStr &fileName)
 
KKStr osGetFileExtension (KKStr fullFileName)
 
KKStr osGetFileNamePartOfFile (KKStr fullFileName)
 osGetFileNamePartOfFile, retrieves the file name part of the file spec. More...
 
kkint64 osGetFileSize (const KKStr &fileName)
 
KKStr osGetFullPathOfApplication ()
 returns the name and path of the current running application. More...
 
KKStr osGetHostName ()
 
double osGetKernalTimeUsed ()
 
KKStrListPtr osGetListOfDirectories (KKStr fileSpec)
 
KKStrListPtr osGetListOfFiles (const KKStr &fileSpec)
 Returns a list of files that match the provided file specification. More...
 
void osGetListOfFilesInDirectoryTree (const KKStr &rootDir, KKStr fileSpec, VectorKKStr &fileNames)
 
KKStrListPtr osGetListOfImageFiles (KKStr fileSpec)
 
KKB::DateTime osGetLocalDateTime ()
 Returned the current local date and time. More...
 
kkint32 osGetNumberOfProcessors ()
 returns the number of CPU's or number of simultaneous threads that you can have. More...
 
KKStr osGetParentDirectoryOfDirPath (KKStr path)
 
KKStr osGetParentDirPath (KKStr dirPath)
 Returns the Parent directory path to 'dirPath'. More...
 
KKStr osGetPathPartOfFile (KKStr fullFileName)
 Get the path part of a full file name specification. More...
 
kkint32 osGetProcessId ()
 
KKStr osGetProgName ()
 
KKStr osGetRootName (const KKStr &fullFileName)
 
KKStr osGetRootNameOfDirectory (KKStr fullDirName)
 
KKStr osGetRootNameWithExtension (const KKStr &fullFileName)
 
kkuint64 osGetSystemTimeInMiliSecs ()
 Returns mili-secs that system (Windows = has been started, Linux time in epoch). More...
 
double osGetSystemTimeUsed ()
 Returns the number of CPU seconds used by current process. More...
 
kkint32 osGetThreadId ()
 
KKStr osGetUserName ()
 
double osGetUserTimeUsed ()
 
template<class T >
T * osGrowAllocation (T *src, kkint32 origSize, kkint32 newSize)
 
bool osIsBackGroundProcess ()
 
kkint32 osLocateFirstSlashChar (const KKStr &fileSpec)
 
kkint32 osLocateLastSlashChar (const KKStr &fileSpec)
 
KKStr osLookForFile (const KKStr &fileName, const KKStr &srcDir)
 Look for a specified file in a sub-directory structure. More...
 
KKStr osMakeFullFileName (const KKStr &_dirName, const KKStr &_fileName)
 
bool osMoveFileBetweenDirectories (const KKStr &_fileName, const KKStr &_srcDir, const KKStr &_destDir)
 
void osParseFileName (KKStr _fileName, KKStr &_dirPath, KKStr &_rootName, KKStr &_extension)
 
void osParseFileSpec (KKStr fullFileName, KKStr &driveLetter, KKStr &path, KKStr &root, KKStr &extension)
 
KKStrPtr osReadNextLine (FILE *in)
 Read the next line from the file and return a c-String(NULL terminated). More...
 
KKB::KKStr osReadNextQuotedStr (FILE *in, const char *whiteSpaceCharacters, bool &eof)
 Read the next Quoted String from the file. More...
 
KKB::KKStr osReadNextToken (FILE *in, const char *delimiters, bool &eof, bool &eol)
 Read the next logical token from a file using characters in 'delimiters' to separate tokens. More...
 
KKStr osReadNextToken (FILE *in, const char *delimiters, bool &eof)
 Read the next logical token from a file using characters in 'delimiters' to separate tokens where '
'(end of line) is just another whitespace character. More...
 
KKB::KKStr osReadNextToken (std::istream &in, const char *delimiters, bool &eof, bool &eol)
 Read the next logical token from a file using characters in 'delimiters' to separate tokens. More...
 
KKB::KKStrPtr osReadRestOfLine (std::istream &in, bool &eof)
 Extracts text up to and including the next end-of-line character and returns pointer to dynamical allocated str that caller will own. More...
 
KKB::KKStrPtr osReadRestOfLine (FILE *in, bool &eof)
 
KKB::KKStr osReadRestOfLine2 (std::istream &in, bool &eof)
 
KKB::KKStr osReadRestOfLine2 (FILE *in, bool &eof)
 
KKStr osRemoveExtension (const KKStr &_fullFileName)
 
bool osRenameFile (const KKStr &oldName, const KKStr &newName)
 
void osRunAsABackGroundProcess ()
 
void osSkipRestOfLine (FILE *in, bool &eof)
 Skips rest of the characters in the current line in the file. More...
 
void osSkipRestOfLine (std::istream &in, bool &eof)
 Skips rest of the characters in the current line in the input stream. More...
 
void osSleep (float numOfSecs)
 
void osSleepMiliSecs (kkuint32 numMiliSecs)
 
VectorKKStr osSplitDirectoryPathIntoParts (const KKStr &path)
 
KKB::KKStr osSubstituteInEnvironmentVariables (const KKStr &src)
 Substitute in the value of the environment variables into 'src'. More...
 
bool osValidDirectory (KKStrConstPtr _name)
 
bool osValidDirectory (const KKStr &_name)
 
bool osValidFileName (const KKStr &_name)
 
KKStrListPtr osValidFileNameErrors (const KKStr &_name)
 Returns list of errors in '_name' with respect to it being a valid file name for the O/S. More...
 
void osWaitForEnter ()
 
float PairedTTest (const KKB::VectorFloat &set1, const KKB::VectorFloat &set2)
 
RasterPtr ReadImage (const KKStr &imageFileName)
 
RasterPtr ReadImagePGM (const KKStr &imageFileName)
 
RasterPtr ReadImagePPM (const KKStr &imageFileName)
 
KKStr ReadImagePpmField (FILE *in, bool &eof)
 
RasterPtr ReadImageUsingGDI (const KKStr &imageFileName)
 
void SaveImage (const Raster &image, const KKStr &imageFileName)
 
void SaveImageGrayscaleInverted4Bit (const Raster &image, const KKStr &_fileName)
 Saves image as BMP file using 4 bit compressed gray-scale where Background = 255 and foreground = 0. More...
 
void SaveImageGrayscaleInverted8Bit (const Raster &image, const KKStr &_fileName)
 Saves image as BMP using compressed gray-scale where Background = 255 and foreground = 0. More...
 
void SaveImageInverted (Raster &raster, const KKStr &imageFileName)
 
void SaveImagePGM (const Raster &image, const KKStr &imageFileName)
 
void SaveImagePNG (const Raster &image, const KKStr &imageFileName)
 
void SaveImagePPM (const Raster &image, const KKStr &imageFileName)
 
kkint32 SPRINTF (char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
 
kkint32 SPRINTF (char *buff, kkint32 buffSize, const char *formatSpec, kkuint16 right)
 
kkint32 SPRINTF (char *buff, kkint32 buffSize, const char *formatSpec, kkint32 right)
 
kkint32 SPRINTF (char *buff, kkint32 buffSize, const char *formatSpec, kkuint32 right)
 
kkint32 SPRINTF (char *buff, kkint32 buffSize, const char *formatSpec, kkint64 right)
 
kkint32 SPRINTF (char *buff, kkint32 buffSize, const char *formatSpec, kkuint64 right)
 
kkint32 SPRINTF (char *buff, kkint32 buffSize, const char *formatSpec, kkint32 precision, double d)
 
kkint32 SPRINTF (char *buff, kkint32 buffSize, char const *formatSpec, double d)
 
void SRand48 (kkint64 _seed)
 Seeds the Lrand48 functions with the parameters passed to it. More...
 
char * STRCAT (char *dest, kkint32 destSize, const char *src)
 
char * STRCOPY (char *dest, kkint32 destSize, const char *src)
 
char * STRCOPY (char *dest, kkuint16 destSize, const char *src)
 
char * STRDUP (const char *src)
 
KKStr StrFormatDouble (double val, const char *mask)
 
KKStr StrFormatInt (kkint32 val, const char *mask)
 
KKStr StrFormatInt64 (kkint64 val, const char *mask)
 
KKStr StrFromDouble (double d)
 
KKStr StrFromFloat (float f)
 
KKStr StrFromInt16 (kkint16 i)
 
KKStr StrFromInt32 (kkint32 i)
 
KKStr StrFromInt64 (kkint64 i)
 
KKStr StrFromUint16 (kkuint16 ui)
 
KKStr StrFromUint32 (kkuint32 ui)
 
KKStr StrFromUint64 (kkuint64 ui)
 
kkint32 STRICMP (const char *left, const char *right)
 
kkint32 STRNICMP (const char *left, const char *right, kkint32 len)
 
bool SupportedImageFileFormat (const KKStr &imageFileName)
 
template<class T >
Swap (T &x, T &y)
 
unsigned int ThreadStartCallBack (void *param)
 
void tqli (kkint32 n, double *d, double *e, double z[2][2])
 
void Tred2 (kkint32 n, double a[2][2], double *d, double *e)
 
XmlFactoryPtr XmlElementKKStrFactoryInstance ()
 
XmlFactoryPtr XmlElementUnKnownFactoryInstance ()
 

Variables

double DoubleMax = DBL_MAX
 
double DoubleMin = DBL_MIN
 
float FloatMax = FLT_MAX
 
float FloatMin = FLT_MIN
 
bool imageIoAtExitDefined = false
 

Detailed Description

KKB The namespace for KKBase Library supporting general functionality needed by almost any application.

Kurt Kramer Utilities This namespace is intended to gather BaseBibrary Classes together.

Author
Kurt Kramer.
( mail : kurtkramer@gmail.com )

Introduction

The KKBase Librery is my tool box of handy objects that I have been building since 1994. It contains classes for string management(KKStr), Floating point Matrix operations, Image Processing Routines, common operating system routines, Statistics, Histogramming, etc. These classes are meant to be Operating System(OS) neutral in that from the outside of the library they perform identically no matter what OS you are on.

Platform Independence

All classes are meant to be Platform independent. That is from the outside there should be no need to worry about which O/S platform you are building for. All O/S specific code will be internal to KKBaseLibrery (KKB) classes. For the most part all functions that require O/S specific knowledge are implemented in OSServices.h. There are a couple of exceptions such as GoalKeeper and ImageIO.h.

Outside Libraries FFTW and ZLIB.

To use all the classes in this Library you will need the libraries fftw and zlib123. "fftw" stands for "Fastest Fourier Transform in The West". It can be downloaded from http://www.fftw.org/. "zlib123" is a library that is used to compress and uncompress data. can be found at http://www.zlib.net/. It is used by the Compressor class.

Macros that should be defined. 'FFTW_AVAILABLE' - Indicates that you want to utilize the FFTW library. otherwise a simple Fourier transform will be utilized. 'ZLIB_AVAILABLE' - Indicates that 'zlib' library is available. If not defined the class Compressor will not do anything.

KKQueue

I have a container template called KKQueue that is derived from the std::vector<> template. It is specifically meant to work with pointers to its contents and understands the concept of ownership. That is a instance of a KKQueue template either owns its contents or it does not. If it owns them it will call the individual destructors for each item that it contains when its destructor is called. Many classes that I have written use this template so it would be worth reading its documentation.

Image Processing

There are several classes that aid in Image Processing. The primary class is Raster which can handle both Grayscale and Color images. It supports various morphological operations as well as Connected Component Analysis, Fourier transform, etc. Other classes that work with Raster are Blob, BMPheader, BMPheader.h, ContourFollower, Histogram, ImageIO.h, PixelValue, Point, and Sobel.

Base class for applications.

Contains basic support for applications such as command-line processing and logging. There is logic to process specified text files for additional parameters. A RunLog instance will be created and inherited by all derived classes; the command line will process and -Log parameter specified. Derived classes can intercept command line parameters simple y implementing the virtual method ProcessCmdLineParameter

Typedef Documentation

Definition at line 187 of file BitString.h.

Definition at line 130 of file Blob.h.

typedef Blob * KKB::BlobPtr

Definition at line 70 of file Blob.h.

Definition at line 290 of file BMPImage.h.

Definition at line 85 of file CmdLineExpander.h.

typedef std::complex<double> KKB::ComplexDouble

Definition at line 29 of file ContourFollower.h.

Definition at line 167 of file Configuration.h.

typedef char const* const* const KKB::ConstCharStarArray

Definition at line 161 of file KKBaseTypes.h.

Definition at line 123 of file ConvexHull.h.

summary> Used to deal with issues related to thread synchronization issues when sharing the same variables.

remarks> Use the GoalKeeper::Create method to create an instance of this class. The Create method will ensure that two different threads don't accidentally create two different instances of the same GoalKeeper object.

GoalKeeper has a concept of levels of depth. That is a particular thread may call StartBlock more than once, each time doing so it would be one level deeper. In this case it would have to call EndBlock an equal number of times to actually release the block. Imagine that you have a function that Starts and Ends a Block but can be called from the middle of another function that also Starts and Ends a block on the same GoalKeeper object.

This class is meant to function the same under Windows or Linux /remarks>

Definition at line 23 of file GoalKeeper.h.

typedef HashEntry* KKB::HashEntryPtr

Definition at line 15 of file HashTable.h.

Definition at line 83 of file Raster.h.

Definition at line 64 of file HTMLReport.h.

typedef KK_DFT1D<double> KKB::KK_DFT1D_Double

Definition at line 173 of file kku_fftw.h.

typedef KK_DFT1D<float> KKB::KK_DFT1D_Float

Definition at line 172 of file kku_fftw.h.

typedef KK_DFT2D<double> KKB::KK_DFT2D_Double

Definition at line 225 of file kku_fftw.h.

typedef KK_DFT2D<float> KKB::KK_DFT2D_Float

Definition at line 224 of file kku_fftw.h.

typedef __int16 KKB::kkint16

16 bit signed integer.

Definition at line 85 of file KKBaseTypes.h.

typedef __int32 KKB::kkint32

Definition at line 88 of file KKBaseTypes.h.

typedef __int64 KKB::kkint64

Definition at line 90 of file KKBaseTypes.h.

typedef __int8 KKB::kkint8

Definition at line 83 of file KKBaseTypes.h.

Definition at line 57 of file KKObserver.h.

typedef KKStr const KKB::KKStrConst

Definition at line 19 of file Atom.h.

Definition at line 718 of file KKStr.h.

Definition at line 827 of file KKStr.h.

Definition at line 92 of file KKStrMatrix.h.

typedef std::pair< KKStr, KKStr > KKB::KKStrPair

Definition at line 719 of file KKStr.h.

typedef KKStr * KKB::KKStrPtr

Definition at line 717 of file KKStr.h.

Definition at line 19 of file KKThread.h.

Definition at line 15 of file KKThread.h.

typedef KKTHread* KKB::KKTHreadPtr

Definition at line 20 of file KKThreadManager.h.

Definition at line 209 of file KKThread.h.

typedef unsigned __int16 KKB::kkuint16

16 bit unsigned integer.

Definition at line 86 of file KKBaseTypes.h.

typedef unsigned __int32 KKB::kkuint32

Definition at line 89 of file KKBaseTypes.h.

typedef unsigned __int64 KKB::kkuint64

Definition at line 91 of file KKBaseTypes.h.

typedef unsigned __int8 KKB::kkuint8

Definition at line 84 of file KKBaseTypes.h.

Definition at line 60 of file Raster.h.

Definition at line 50 of file Raster.h.

Definition at line 136 of file MorphOp.h.

Definition at line 48 of file MorphOpBinarize.h.

Definition at line 43 of file MorphOpDilation.h.

Definition at line 42 of file MorphOpErosion.h.

Definition at line 134 of file MorphOp.h.

Definition at line 67 of file MorphOpStretcher.h.

Definition at line 62 of file MorphOpStruct.h.

Definition at line 45 of file RunLog.h.

typedef long long KKB::osFilePos

Definition at line 21 of file OSservices.h.

Definition at line 28 of file BMPImage.h.

Definition at line 107 of file Point.h.

typedef Point * KKB::PointPtr

Definition at line 66 of file Point.h.

typedef Raster const * KKB::RasterConstPtr

Definition at line 1373 of file Raster.h.

Definition at line 75 of file Raster.h.

Definition at line 25 of file BMPImage.h.

typedef Row* KKB::RowPtr

Definition at line 33 of file Matrix.h.

Definition at line 198 of file RunLog.h.

typedef vector<SeriesPtr> KKB::SeriesList

Definition at line 85 of file Chart.cpp.

Definition at line 83 of file Chart.cpp.

summary> Maintains a list of ordered KKStr instances that can be recalled by either string of index.

For comparability with previous version.

Definition at line 828 of file KKStr.h.

Definition at line 61 of file Raster.h.

Definition at line 31 of file TokenBuffer.h.

Definition at line 85 of file TokenBuffer.h.

Definition at line 89 of file Tokenizer.h.

typedef unsigned char KKB::uchar

Unsigned character.

Definition at line 77 of file KKBaseTypes.h.

typedef unsigned int KKB::uint

Unsigned integer.

Definition at line 78 of file KKBaseTypes.h.

typedef unsigned long KKB::ulong

Unsigned long.

Definition at line 80 of file KKBaseTypes.h.

typedef unsigned short KKB::ushort

Unsigned short.

Definition at line 79 of file KKBaseTypes.h.

typedef std::vector<bool> KKB::VectorBool

Definition at line 135 of file KKBaseTypes.h.

typedef std::vector<char> KKB::VectorChar

Definition at line 136 of file KKBaseTypes.h.

Definition at line 151 of file KKBaseTypes.h.

typedef std::vector<double> KKB::VectorDouble

Vector of doubles.

Definition at line 148 of file KKBaseTypes.h.

Definition at line 158 of file KKBaseTypes.h.

typedef std::vector<float> KKB::VectorFloat

Definition at line 149 of file KKBaseTypes.h.

Definition at line 157 of file KKBaseTypes.h.

typedef std::vector<int> KKB::VectorInt

Definition at line 138 of file KKBaseTypes.h.

typedef std::vector<kkint16> KKB::VectorInt16

Vector of signed 16 bit integers.

Definition at line 140 of file KKBaseTypes.h.

typedef std::vector<kkint32> KKB::VectorInt32

Vector of signed 32 bit integers.

Definition at line 144 of file KKBaseTypes.h.

Definition at line 154 of file KKBaseTypes.h.

typedef std::vector<kkint64> KKB::VectorInt64

Definition at line 146 of file KKBaseTypes.h.

Definition at line 155 of file KKBaseTypes.h.

Definition at line 153 of file KKBaseTypes.h.

typedef std::vector<Point> KKB::VectorPoint

Definition at line 68 of file Point.h.

typedef std::vector<short> KKB::VectorShort

Definition at line 142 of file KKBaseTypes.h.

Definition at line 159 of file KKBaseTypes.h.

typedef std::vector<uchar> KKB::VectorUchar

Definition at line 137 of file KKBaseTypes.h.

Definition at line 152 of file KKBaseTypes.h.

typedef std::vector<uint> KKB::VectorUint

Definition at line 139 of file KKBaseTypes.h.

typedef std::vector<kkuint16> KKB::VectorUint16

Vector of unsigned 16 bit integers.

Definition at line 141 of file KKBaseTypes.h.

typedef std::vector<kkuint32> KKB::VectorUint32

Vector of unsigned 32 bit integers.

Definition at line 145 of file KKBaseTypes.h.

typedef std::vector<kkuint64> KKB::VectorUint64

Definition at line 147 of file KKBaseTypes.h.

typedef std::vector<ulong> KKB::VectorUlong

Definition at line 143 of file KKBaseTypes.h.

Definition at line 156 of file KKBaseTypes.h.

typedef volatile const bool KKB::VolConstBool

Commonly used for passing Cancel Flag in multi threaded environment.

Definition at line 163 of file KKBaseTypes.h.

Definition at line 131 of file XmlStream.h.

Definition at line 132 of file XmlStream.h.

Definition at line 170 of file XmlStream.h.

Definition at line 130 of file XmlStream.h.

Definition at line 24 of file XmlStream.h.

Definition at line 919 of file XmlStream.h.

Definition at line 915 of file XmlStream.h.

Definition at line 524 of file XmlStream.h.

Definition at line 560 of file XmlStream.h.

Definition at line 909 of file XmlStream.h.

Definition at line 908 of file XmlStream.h.

Definition at line 906 of file XmlStream.h.

Definition at line 907 of file XmlStream.h.

Definition at line 679 of file XmlStream.h.

Definition at line 670 of file XmlStream.h.

Definition at line 21 of file XmlStream.h.

Definition at line 490 of file XmlStream.h.

summary>To be used for classes that implement default constructor, ReadXML, and WriteXML.

Definition at line 411 of file XmlStream.h.

Definition at line 30 of file XmlStream.h.

Definition at line 27 of file XmlStream.h.

Definition at line 29 of file Atom.h.

typedef XmlTag const KKB::XmlTagConst

Definition at line 33 of file Atom.h.

Definition at line 45 of file KKStr.h.

Definition at line 31 of file Atom.h.

Definition at line 117 of file XmlTokenizer.h.

Summary>Parent class to all XmlElements

remarks> When XmlStream encounters the start of a element it looks up the appropriate ElementFactory that will construct an instance of a XmlElement derived class. The constructor of that class will be provided the XmlTag that starts the element plus a pointer to the XmlStream instance that is reading the XML file. The XmlElement derived classes constructor will the be responsible for creating an instance of the class that the XmnlElement wraps.

Definition at line 18 of file XmlStream.h.

Enumeration Type Documentation

enum KKB::ColorChannels
strong
Enumerator
Red 
Green 
Blue 

Definition at line 64 of file Raster.h.

enum KKB::RBcolor
strong
Enumerator
Red 
Black 

Definition at line 30 of file RBTree.h.

Function Documentation

template<typename T >
T KKB::Calc3TTLQC ( const vector< T > &  v,
kkint32  b 
)

Definition at line 235 of file StatisticalFunctions.h.

238  {
239  kkint32 i = 0;
240  kkint32 n = (kkint32)v.size ();
241 
242  double squareSun = 0.0;
243 
244  vector<T> sumArray (v.size (), (T)0.0);
245  sumArray[0] = v[0];
246  for (i = 1; i < n; i++)
247  sumArray[i] = sumArray[i - 1] + v[i];
248 
249  kkint32 end = n + 1 - (3 * b);
250 
251  for (i = 0; i < end; i++)
252  {
253  T plusSide = sumArray[i + b - 1];
254  T minusSide = 2 * sumArray[i + b + b - 1];
255  T plusSide2 = sumArray[i + 2 * b];
256 
257  T delta = plusSide - minusSide + plusSide2;
258  double deltaSquared = delta * delta;
259  squareSun += deltaSquared;
260  }
261 
262  double divisor = 8.0 * (double)b * ((double)n + 1.0 - 3.0 * (double)b);
263 
264  double result = squareSun / divisor;
265 
266  return (T)result;
267  } /* Calc3TTLQC */
__int32 kkint32
Definition: KKBaseTypes.h:88
template<typename T >
T KKB::CalcBQV ( const vector< T > &  v,
kkint32  blockSize 
)

Definition at line 114 of file StatisticalFunctions.h.

117  {
118  //typedef long double uld;
119 
120  kkint32 zed = 0;
121  kkint32 x = 0;
122 
123  double totalSquare = (T)0.0;
124 
125  double divisorFactor = 1.0 / pow(2.0, blockSize);
126 
127  while (zed < (kkint32)(v.size () - 2 * blockSize))
128  {
129  T plusSide = (T)0.0;
130  T minusSide = (T)0.0;
131 
132  double delta = 0.0;
133 
134  for (x = 0; x < blockSize; x++)
135  {
136  delta += v[zed];
137  zed++;
138  }
139 
140  for (x = 0; x < blockSize; x++)
141  {
142  delta -= v[zed];
143  zed++;
144  }
145 
146  double deltaSquared = delta * delta;
147 
148 
149  totalSquare += divisorFactor * deltaSquared;
150  }
151 
152 
153  double result = pow (2.0, blockSize) * totalSquare / zed;
154 
155  return (T)result;
156  } /* CalcBQV */
__int32 kkint32
Definition: KKBaseTypes.h:88
template<typename T >
void KKB::CalcMeanAndStdDev ( const vector< T > &  v,
T &  mean,
T &  stdDev 
)

Definition at line 14 of file StatisticalFunctions.h.

18  {
19  typedef long double uld;
20 
21  if (v.size () < 1)
22  {
23  mean = T (0);
24  stdDev = T (0);
25  return;
26  }
27 
28  kkuint32 idx;
29  T total = T(0);
30 
31  for (idx = 0; idx < v.size (); idx++)
32  total = total + v[idx];
33 
34  mean = total / T (v.size ());
35 
36  uld deltaSqrTotal = 0.0;
37  uld deltaSquared = 0.0;
38  uld delta = 0.0;
39 
40 
41  for (idx = 0; idx < v.size (); idx++)
42  {
43  delta = (uld)fabs (mean - v[idx]);
44  deltaSquared = delta * delta;
45  deltaSqrTotal += deltaSquared;
46  }
47 
48  uld varience = deltaSqrTotal / (uld)(v.size ());
49 
50  stdDev = (T)sqrt (varience);
51 
52  return;
53  } /* CalcMeanAndStdDev */
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
template<typename T >
T KKB::CalcPQV ( const vector< T > &  v,
kkint32  distance 
)

Definition at line 164 of file StatisticalFunctions.h.

167  {
168  //typedef long double uld;
169 
170  kkint32 x = 0;
171  kkint32 y = x + distance;
172 
173  double totalDeltaSquared = 0.0;
174 
175  while (y < (kkint32)v.size ())
176  {
177  T delta = v[x] - v[y];
178  double deltaSquared = delta * delta;
179  totalDeltaSquared += deltaSquared;
180 
181  x++;
182  y++;
183  }
184 
185  double result = totalDeltaSquared / (2 * (v.size () - distance));
186 
187  return (T)result;
188  } /* CalcPQV */
__int32 kkint32
Definition: KKBaseTypes.h:88
template<typename T >
T KKB::CalcTTLQC ( const vector< T > &  v,
kkint32  b 
)

Definition at line 196 of file StatisticalFunctions.h.

199  {
200  kkint32 i = 0;
201  kkint32 n = (kkint32)v.size ();
202 
203  double squareSun = 0.0;
204 
205  vector<T> sumArray (v.size (), (T)0.0);
206  sumArray[0] = v[0];
207  for (i = 1; i < n; i++)
208  sumArray[i] = sumArray[i - 1] + v[i];
209 
210  kkint32 end = n + 1 - (2 * b);
211 
212  for (i = 0; i < end; i++)
213  {
214  T plusSide = sumArray[i + b - 1];
215  T minusSide = sumArray[i + b + b - 1] - sumArray[i + b - 1];
216  T delta = plusSide - minusSide;
217  double deltaSquared = delta * delta;
218  squareSun += deltaSquared;
219  }
220 
221  double divisor = 2.0 * (double)b * ((double)n + 1.0 - 2.0 * (double)b);
222 
223  double result = squareSun / divisor;
224 
225  return (T)result;
226  } /* CalcTTLQC */
__int32 kkint32
Definition: KKBaseTypes.h:88
template<typename T >
void KKB::CalcVectorStats ( const vector< T > &  v,
T &  total,
T &  mean,
T &  stdDev,
T &  min,
T &  max 
)

Definition at line 58 of file StatisticalFunctions.h.

65  {
66  typedef long double uld;
67 
68  total = 0;
69 
70  if (v.size () < 1)
71  {
72  mean = T (0);
73  stdDev = T (0);
74  min = 0.0;
75  max = 0.0;
76  return;
77  }
78 
79  kkuint32 idx;
80  total = T(0);
81 
82  min = max = v[0];
83 
84  for (idx = 0; idx < v.size (); idx++)
85  {
86  total = total + v[idx];
87  if (v[idx] < min) min = v[idx];
88  if (v[idx] > max) max = v[idx];
89  }
90 
91  mean = total / T (v.size ());
92 
93  uld deltaSqrTotal = 0.0;
94  uld deltaSquared = 0.0;
95  uld delta = 0.0;
96 
97  for (idx = 0; idx < v.size (); idx++)
98  {
99  delta = (uld)fabs (mean - v[idx]);
100  deltaSquared = delta * delta;
101  deltaSqrTotal += deltaSquared;
102  }
103 
104  uld varience = deltaSqrTotal / (uld)(v.size ());
105 
106  stdDev = (T)sqrt (varience);
107 
108  return;
109  } /* CalcMeanAndStdDev */
#define min(X, Y)
Definition: UsfCasCor.h:244
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
#define max(X, Y)
Definition: UsfCasCor.h:248
ColorChannels KKB::ColorChannelFromKKStr ( const KKStr s)

Definition at line 68 of file Raster.cpp.

References Blue, Green, and Red.

69 {
70  char c = tolower(s.FirstChar());
71  if (c == 'r') return ColorChannels::Red;
72  if (c == 'g') return ColorChannels::Green;
73  if (c == 'b') return ColorChannels::Blue;
74  return ColorChannels::Green;
75 }
char FirstChar() const
Definition: KKStr.cpp:1970
KKStr KKB::ColorChannelToKKStr ( ColorChannels  c)

Definition at line 56 of file Raster.cpp.

References Blue, Green, and Red.

Referenced by KKB::Raster::Histogram().

57 {
58  switch (c) {
59  case ColorChannels::Red: return "Red";
60  case ColorChannels::Green: return "Green";
61  case ColorChannels::Blue: return "Blue";
62  default:
63  return "";
64  }
65 }
void KKB::DefineImageIoAtExit ( )

Definition at line 70 of file ImageIO.cpp.

References imageIoAtExitDefined.

Referenced by ReadImageUsingGDI().

71 {
73  {
74  atexit (ImageIoFinaleCleanUp);
75  imageIoAtExitDefined = true;
76  }
77 }
void ImageIoFinaleCleanUp()
Definition: ImageIO.cpp:963
bool imageIoAtExitDefined
Definition: ImageIO.cpp:65
void KKB::DisplayImage ( const Raster raster,
const KKStr title 
)

Definition at line 99 of file ImageIO.cpp.

References DisplayImage().

102 {
103  DisplayImage (raster);
104 }
void DisplayImage(const Raster &raster, const KKStr &title)
Definition: ImageIO.cpp:99
void KKB::DisplayImage ( const Raster image)

Definition at line 81 of file ImageIO.cpp.

References KKB::Raster::Height(), and KKB::Raster::Width().

Referenced by DisplayImage().

82 {
83  kkint32 col, row;
84 
85  for (row = 0; row < image.Height (); row++)
86  {
87  for (col = 0; col < image.Width (); col++)
88  {
89  cout << image.GetPixelValue ( row, col) << " ";
90  }
91 
92  cout << std::endl;
93  }
94 } /* DisplayImage */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 Height() const
Definition: Raster.h:319
kkint32 Width() const
Definition: Raster.h:324
uchar GetPixelValue(kkint32 row, kkint32 col) const
Definition: Raster.cpp:1289
HTMLReport &__cdecl KKB::endl ( HTMLReport htmlReport)

Definition at line 240 of file HTMLReport.cpp.

References KKB::HTMLReport::Append().

241 {
242  htmlReport.Append ("\n");
243  return htmlReport;
244 }
void Append(const char *str)
Definition: HTMLReport.cpp:88
void KKB::FFT ( float  data[],
kkuint32  number_of_complex_samples,
kkint32  isign 
)

Definition at line 143 of file kku_fftw.cpp.

References SWAP().

147 {
148  //variables for trigonometric recurrences
149  kkuint32 n = 0;
150  kkuint32 mmax = 0;
151  kkuint32 m = 0;
152  kkuint32 j = 0;
153  kkuint32 istep = 0;
154  kkuint32 i = 0;
155 
156  float wtemp = 0.0;
157  float wr = 0.0;
158  float wpr = 0.0;
159  float wpi = 0.0;
160  float wi = 0.0;
161  float theta = 0.0;
162  float tempr = 0.0;
163  float tempi = 0.0;
164 
165  /*
166  * The Bit-Reversal Method
167  *
168  * First, the original array must be transformed in order to perform the Danielson-Lanzcos
169  * algorithm. For example, the complex[index] will swap places with the
170  * complex[bit-reverse-order-index]. If the index (in binary) is 0b00001, the
171  * bit-reverse-order-index will be 0b10000. In figure 1, you can see what happens to the
172  * data array after the transformation.
173  *
174  * The implementation of this method according to Numerical Recipes In C goes like this:
175  */
176 
177  //the complex array is real+complex so the array
178  //as a size n = 2* number of complex samples
179  // real part is the data[index] and
180  //the complex part is the data[index+1]
181  n = number_of_complex_samples * 2;
182 
183  //binary inversion (note that the indexes
184  //start from 0 witch means that the
185  //real part of the complex is on the even-indexes
186  //and the complex part is on the odd-indexes
187  j = 0;
188  for (i = 0; i < n / 2; i += 2)
189  {
190  if (j > i)
191  {
192  //swap the real part
193  SWAP (data[j], data[i]);
194 
195  //swap the complex part
196  SWAP (data[j + 1],data[i + 1]);
197 
198  // checks if the changes occurs in the first half
199  // and use the mirrored effect on the second half
200  if ((j / 2) < (n / 4))
201  {
202  //swap the real part
203  SWAP (data[(n - (i + 2))], data[(n - (j + 2))]);
204  //swap the complex part
205  SWAP (data[(n - (i + 2)) + 1], data[(n - (j + 2)) + 1]);
206  }
207  }
208  m = n / 2;
209  while (m >= 2 && j >= m)
210  {
211  j -= m;
212  m = m / 2;
213  }
214  j += m;
215  }
216 
217  //Danielson-Lanzcos routine
218  mmax = 2;
219  //external loop
220  while (n > mmax)
221  {
222  istep = mmax << 1;
223  theta = isign * (2 * (float)PIE / mmax);
224  wtemp = sin (0.5f * theta);
225  wpr = -2.0f * wtemp * wtemp;
226  wpi = sin (theta);
227  wr = 1.0f;
228  wi = 0.0f;
229  //internal loops
230  for (m = 1; m < mmax; m += 2)
231  {
232  for (i = m; i <= n; i += istep)
233  {
234  j = i + mmax;
235  tempr = wr * data[j - 1] - wi * data[j];
236  tempi = wr * data[j] + wi * data[j - 1];
237  data[j - 1] = data[i - 1] - tempr;
238  data[j] = data[i] - tempi;
239  data[i - 1] += tempr;
240  data[i] += tempi;
241  }
242  wr = (wtemp = wr) * wpr - wi * wpi + wr;
243  wi = wi * wpr + wtemp * wpi + wi;
244  }
245  mmax = istep;
246  }
247 } /* FFT */
#define PIE
Definition: KKBaseTypes.h:52
void SWAP(float &a, float &b)
Definition: kku_fftw.cpp:130
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
float KKB::FloatAbs ( float  f)

Definition at line 25 of file KKBaseTypes.cpp.

26 {
27  return (float)abs (f);
28 }
void KKB::ImageIoFinaleCleanUp ( )

Definition at line 963 of file ImageIO.cpp.

References gdiStarted.

964 {
965  if (gdiStarted)
966  {
967  GdiplusShutdown(gdiplusToken);
968  gdiStarted = false;
969  }
970 }
ULONG_PTR gdiplusToken
Definition: ImageIO.cpp:235
bool gdiStarted
Definition: ImageIO.cpp:233
bool KKB::IsFinite ( const float &  f)

Definition at line 100 of file KKBaseTypes.cpp.

101 {
102  return (std::isfinite(f) != 0);
103 }
bool KKB::IsFinite ( const double &  f)

Definition at line 106 of file KKBaseTypes.cpp.

107 {
108  return (std::isfinite(f) != 0);
109 }
bool KKB::IsNaN ( const float &  f)

Definition at line 86 of file KKBaseTypes.cpp.

87 {
88  bool notANum = std::isnan (f) != 0;
89  return notANum;
90 }
bool KKB::IsNaN ( const double &  d)

Definition at line 93 of file KKBaseTypes.cpp.

94 {
95  bool notANum = std::isnan (d) != 0;
96  return notANum;
97 }
template<typename T >
T* KKB::kkReallocateArray ( T *  oldA,
kkint32  oldSize,
kkint32  newSize 
)

Definition at line 306 of file KKBaseTypes.h.

310  {
311  T* newA = new T[newSize];
312  kkint32 x = 0;
313  while (x < Min(oldSize, newSize)) {
314  newA[x] = oldA[x];
315  ++x;
316  }
317  while (x < Max(oldSize, newSize)) {
318  newA[x] = NULL;
319  ++x;
320  }
321  delete[] oldA;
322  oldA = NULL;
323  return newA;
324  } /* namespace KKB */
__int32 kkint32
Definition: KKBaseTypes.h:88
T Max(T x0, T x1, T x2, T x3, T x4, T x5, T x6, T x7)
Generic Max function, that takes eight parameters of the same type.
Definition: KKBaseTypes.h:248
kkint32 Min(kkint32 x1, kkint32 x2)
Definition: Raster.cpp:229
float KKB::LLoydsIndexOfPatchiness ( const KKB::VectorInt bins)

Definition at line 166 of file StatisticalFunctions.cpp.

167 {
168  // As defined by Andrew Remsen
169  // also look at http://www.pmel.noaa.gov/pubs/outstand/stab1646/statistics.shtml
170 
171  if (bins.size () < 1)
172  return 0.0f;
173 
174  kkuint32 x;
175  double total = 0.0;
176  double mean = 0.0;
177 
178  for (x = 0; x < bins.size (); x++)
179  total += bins[x];
180 
181  mean = total / double (bins.size ());
182 
183  double totalDeltaSquared = 0.0;
184 
185  for (x = 0; x < bins.size (); x++)
186  {
187  double delta = double (bins[x]) - mean;
188  totalDeltaSquared += delta * delta;
189  }
190 
191  double var = totalDeltaSquared / bins.size ();
192 
193 
194  double varDivMean = var / mean;
195  double oneDivMean = 1.0 / mean;
196 
197  float p = float ((varDivMean - 1.0 + mean) * oneDivMean);
198 
199  return p;
200 } /* LLoydsIndexOfPatchiness */
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
float KKB::Log2 ( float  x)

Definition at line 250 of file kku_fftw.cpp.

251 {
252  return log10 (x) / log10 (2.0f);
253 }
kkint32 KKB::LRand48 ( )

A implementations of the Unix version of rand48 returning a 32 bit integer.

Definition at line 36 of file KKBaseTypes.cpp.

References _lrand48_sequence.

Referenced by KKMLL::FeatureNumList::RandomlySelectFeatures().

37 {
38  static const kkint64 a = 0x5DEECE66DLL;
39  static const kkint64 c = 0xBLL;
40  static const kkint64 m = 281474976710656LL;
41  kkint64 mask = 281474976710655LL;
42 
43  _lrand48_sequence = ( ((a * _lrand48_sequence) & mask) + c ) % m;
44  return (kkint32)(_lrand48_sequence >> 17);
45 }
__int32 kkint32
Definition: KKBaseTypes.h:88
__int64 kkint64
Definition: KKBaseTypes.h:90
kkint64 _lrand48_sequence
Definition: KKBaseTypes.cpp:32
template<class T >
T KKB::Max ( a,
b 
)

generic Max function, Both parameters must be of the same type.

Definition at line 181 of file KKBaseTypes.h.

184  {
185  if (a >= b)
186  return a;
187  else
188  return b;
189  }
template<class T >
T KKB::Max ( a,
b,
c 
)

Generic Max function, that takes three parameters. All three parameters must be of the same type.

Definition at line 195 of file KKBaseTypes.h.

199  {
200  if ((a >= b) && (a >= c))
201  return a;
202 
203  if (b >= c)
204  return b;
205  else
206  return c;
207  }
template<class T >
T KKB::Max ( a,
b,
c,
d 
)

Generic Max function, that takes four parameters. All four parameters must be of the same type.

Definition at line 213 of file KKBaseTypes.h.

218  {
219  return Max (Max (a, b), Max (c, d));
220  }
T Max(T x0, T x1, T x2, T x3, T x4, T x5, T x6, T x7)
Generic Max function, that takes eight parameters of the same type.
Definition: KKBaseTypes.h:248
template<class T >
T KKB::Max ( x0,
x1,
x2,
x3,
x4 
)

Generic Max function, that takes five parameters of the same type.

Definition at line 225 of file KKBaseTypes.h.

226  {
227  return Max (Max(x0, x1, x2, x3), x4);
228  }
T Max(T x0, T x1, T x2, T x3, T x4, T x5, T x6, T x7)
Generic Max function, that takes eight parameters of the same type.
Definition: KKBaseTypes.h:248
template<class T >
T KKB::Max ( x0,
x1,
x2,
x3,
x4,
x5 
)

Generic Max function, that takes six parameters of the same type.

Definition at line 233 of file KKBaseTypes.h.

234  {
235  return Max (Max(x0, x1, x2), Max (x3, x4, x5));
236  }
T Max(T x0, T x1, T x2, T x3, T x4, T x5, T x6, T x7)
Generic Max function, that takes eight parameters of the same type.
Definition: KKBaseTypes.h:248
template<class T >
T KKB::Max ( x0,
x1,
x2,
x3,
x4,
x5,
x6 
)

Generic Max function, that takes seven parameters of the same type.

Definition at line 240 of file KKBaseTypes.h.

241  {
242  return Max (Max(x0, x1, x2, x3), Max (x4, x5, x6));
243  }
T Max(T x0, T x1, T x2, T x3, T x4, T x5, T x6, T x7)
Generic Max function, that takes eight parameters of the same type.
Definition: KKBaseTypes.h:248
template<class T >
T KKB::Max ( x0,
x1,
x2,
x3,
x4,
x5,
x6,
x7 
)

Generic Max function, that takes eight parameters of the same type.

Definition at line 248 of file KKBaseTypes.h.

249  {
250  return Max (Max(x0, x1, x2, x3), Max (x4, x5, x6, x7));
251  }
T Max(T x0, T x1, T x2, T x3, T x4, T x5, T x6, T x7)
Generic Max function, that takes eight parameters of the same type.
Definition: KKBaseTypes.h:248
float KKB::McNemarsTest ( kkint32  size,
const bool *  classedCorrectly1,
const bool *  classedCorrectly2 
)

Definition at line 109 of file StatisticalFunctions.cpp.

113 {
114  kkint32 n00 = 0;
115  kkint32 n01 = 0;
116  kkint32 n10 = 0;
117  kkint32 n11 = 0;
118 
119  kkint32 x;
120 
121  for (x = 0; x < size; x++)
122  {
123  bool ca = classedCorrectly1[x];
124  bool cb = classedCorrectly2[x];
125 
126  if (!ca && !cb)
127  n00++; // true neg.
128 
129  else if (!ca && cb)
130  n01++; // false pos.
131 
132  else if (ca && !cb)
133  n10++; // false neg.
134 
135  else if (ca && cb)
136  n11++; // true pos
137  }
138 
139  float y = (float)fabs ((float)(n01 - n10)) - 1.0f; // (false pos - false neg) - 1.0;
140 
141  float mcNemars = 0.0;
142  float divisor = (float)n01 + (float)n10;
143 
144  if (divisor != 0.0f)
145  mcNemars = y * y / divisor;
146 
147  return mcNemars;
148 } /* McNemarsTest */
__int32 kkint32
Definition: KKBaseTypes.h:88
template<class T >
T KKB::Min ( a,
b 
)

Generic Min function, Both parameters must be of the same type.

Definition at line 168 of file KKBaseTypes.h.

171  {
172  if (a <= b)
173  return a;
174  else
175  return b;
176  }
KKStr KKB::operator+ ( const char  left,
const KKStr right 
)

Definition at line 3964 of file KKStr.cpp.

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

3967 {
3968  KKStr result (right.Len () + 3);
3969  result.Append (left);
3970  result.Append (right);
3971  return result;
3972 }
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
void Append(const char *buff)
Definition: KKStr.cpp:1783
KKStr KKB::operator+ ( const char *  left,
const KKStr right 
)

Definition at line 3976 of file KKStr.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::KKStr(), and KKB::KKStr::operator+().

Referenced by KKB::KKStr::Append(), KKB::BmpImage::BlueRow(), KKMLL::GrayScaleImagesFVProducer::ComputeFeatureVector(), KKMLL::Model::CreateAModel(), KKLSC::ScannerFile::CreateGoalie(), KKMLL::ModelSvmBase::Description(), KKMLL::ModelOldSVM::Description(), KKMLL::ModelDual::Description(), KKB::GoalKeeperSimple::EndBlock(), KKB::GoalKeeper::EndBlock(), KKMLL::FeatureFileIOColumn::GetFileDesc(), KKMLL::FeatureFileIOUCI::GetFileDesc(), KKMLL::FeatureFileIOSparse::GetFileDesc(), KKB::BmpImage::ImageRow(), KKB::KKStr::KKStr(), KKB::MsgQueue::MsgQueue(), osSubstituteInEnvironmentVariables(), KKMLL::ClassProbList::PushOnBack(), KKMLL::ClassProbList::PushOnFront(), KKB::RasterBuffer::RasterBuffer(), KKB::BmpImage::RedRow(), KKB::KKStr::RightPad(), KKB::BmpImage::Save(), KKB::BmpImage::SaveGrayscaleInverted4Bit(), KKB::BmpImage::SaveGrayscaleInverted8Bit(), SaveImage(), SaveImageGrayscaleInverted4Bit(), SaveImageGrayscaleInverted8Bit(), SaveImagePNG(), SaveImagePPM(), KKB::Raster::SegmentImage(), KKB::KKStr::StrReplace(), KKMLL::ModelParam::ToCmdLineStr(), KKB::PixelValue::ToStr(), KKMLL::SVMparam::ToString(), tqli(), KKMLL::ModelSvmBase::TrainModel(), KKMLL::ModelDual::TrainModel(), Tred2(), KKB::KKStr::Wide(), KKMLL::SVMModel::WriteXML(), and KKB::XmlElementArrayFloat2DVarying::WriteXML().

3979 {
3980  return KKStr (left) + right;
3981 }
Matrix KKB::operator- ( double  left,
const Matrix right 
)

Definition at line 456 of file Matrix.cpp.

References KKB::Matrix::Matrix(), KKB::Matrix::NumOfCols(), and KKB::Matrix::NumOfRows().

Referenced by KKB::SegmentorOTSU::SegmentImage(), and KKB::SegmentorOTSU::SegmentMaskedImage().

459 {
460  kkint32 numOfRows = right.NumOfRows ();
461  kkint32 numOfCols = right.NumOfCols ();
462  kkint32 totNumCells = right.totNumCells;
463 
464  Matrix result (numOfRows, numOfCols);
465  double* resultDataArea = result.dataArea;
466  double* rightDataArea = right.dataArea;
467 
468  for (kkint32 x = 0; x < totNumCells; ++x)
469  resultDataArea[x] = left - rightDataArea[x];
470 
471  return result;
472 } /* operator- */
kkint32 NumOfRows() const
Definition: Matrix.h:128
__int32 kkint32
Definition: KKBaseTypes.h:88
Supports two dimensional matrices.
Definition: Matrix.h:46
kkint32 NumOfCols() const
Definition: Matrix.h:126
HTMLReport &__cdecl KKB::operator<< ( KKB::HTMLReport htmlReport,
KKB::HTMLReport __cdecl *mf)(HTMLReport & 
)

Definition at line 230 of file HTMLReport.cpp.

233 {
234  mf (htmlReport);
235  return htmlReport;
236 }
HTMLReport & KKB::operator<< ( HTMLReport htmlReport,
kkint32  right 
)

Definition at line 106 of file HTMLReport.cpp.

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

109 {
110  KKStr s (30);
111  s = StrFormatInt (right, "0");
112  htmlReport.Append (s.Str ());
113  return htmlReport;
114 }
void Append(const char *str)
Definition: HTMLReport.cpp:88
KKStr StrFormatInt(kkint32 val, const char *mask)
Definition: KKStr.cpp:5004
HTMLReport & KKB::operator<< ( HTMLReport htmlReport,
kkuint32  right 
)

Definition at line 118 of file HTMLReport.cpp.

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

121 {
122  KKStr s (30);
123  s = StrFormatInt (right, "0");
124  htmlReport.Append (s.Str ());
125  return htmlReport;
126 }
void Append(const char *str)
Definition: HTMLReport.cpp:88
KKStr StrFormatInt(kkint32 val, const char *mask)
Definition: KKStr.cpp:5004
HTMLReport & KKB::operator<< ( HTMLReport htmlReport,
kkint64  right 
)

Definition at line 130 of file HTMLReport.cpp.

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

133 {
134  KKStr s (30);
135  s = StrFormatInt64 (right, "0");
136  htmlReport.Append (s.Str ());
137  return htmlReport;
138 }
KKStr StrFormatInt64(kkint64 val, const char *mask)
Definition: KKStr.cpp:5013
void Append(const char *str)
Definition: HTMLReport.cpp:88
HTMLReport & KKB::operator<< ( HTMLReport htmlReport,
kkuint64  right 
)

Definition at line 142 of file HTMLReport.cpp.

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

145 {
146  KKStr s (30);
147  s = StrFormatInt64 (right, "0");
148  htmlReport.Append (s.Str ());
149  return htmlReport;
150 }
KKStr StrFormatInt64(kkint64 val, const char *mask)
Definition: KKStr.cpp:5013
void Append(const char *str)
Definition: HTMLReport.cpp:88
HTMLReport & KKB::operator<< ( HTMLReport htmlReport,
double  right 
)

Definition at line 154 of file HTMLReport.cpp.

References KKB::HTMLReport::Append().

157 {
158  char buff[50];
159 
160 # ifdef USE_SECURE_FUNCS
161  sprintf_s (buff, sizeof (buff), "%f", right);
162 # else
163  sprintf (buff, "%f", right);
164 # endif
165 
166  htmlReport.Append (buff);
167  return htmlReport;
168 }
void Append(const char *str)
Definition: HTMLReport.cpp:88
HTMLReport & KKB::operator<< ( HTMLReport htmlReport,
char  right 
)

Definition at line 172 of file HTMLReport.cpp.

References KKB::HTMLReport::Append().

175 {
176  char buff[20];
177  buff[0] = right;
178  buff[1] = 0;
179  htmlReport.Append (buff);
180  return htmlReport;
181 }
void Append(const char *str)
Definition: HTMLReport.cpp:88
HTMLReport & KKB::operator<< ( HTMLReport htmlReport,
const char *  right 
)

Definition at line 185 of file HTMLReport.cpp.

References KKB::HTMLReport::Append().

188 {
189  htmlReport.Append (right);
190  return htmlReport;
191 }
void Append(const char *str)
Definition: HTMLReport.cpp:88
KKStr & KKB::operator<< ( KKStr left,
const Point right 
)

Definition at line 265 of file Point.cpp.

References KKB::Point::Col(), and KKB::Point::Row().

268 {
269  left << "[" << right.Row () << ", " << right.Col () << "]";
270  return left;
271 }
kkint32 Col() const
Definition: Point.h:40
kkint32 Row() const
Definition: Point.h:39
HTMLReport & KKB::operator<< ( HTMLReport htmlReport,
const KKStr right 
)

Definition at line 196 of file HTMLReport.cpp.

References KKB::HTMLReport::Append(), and KKB::KKStr::Str().

199 {
200  htmlReport.Append (right.Str ());
201  return htmlReport;
202 }
void Append(const char *str)
Definition: HTMLReport.cpp:88
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
ostream & KKB::operator<< ( std::ostream &  left,
const Point right 
)

Definition at line 275 of file Point.cpp.

References KKB::Point::Col(), operator<<(), and KKB::Point::Row().

278 {
279  left << "[" << right.Row () << ", " << right.Col () << "]";
280  return left;
281 }
kkint32 Col() const
Definition: Point.h:40
kkint32 Row() const
Definition: Point.h:39
HTMLReport & KKB::operator<< ( HTMLReport htmlReport,
KKStrConstPtr  right 
)

Definition at line 207 of file HTMLReport.cpp.

References KKB::HTMLReport::Append(), and KKB::KKStr::Str().

210 {
211  if (right)
212  htmlReport.Append (right->Str ());
213  return htmlReport;
214 }
void Append(const char *str)
Definition: HTMLReport.cpp:88
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
HTMLReport & KKB::operator<< ( HTMLReport htmlReport,
const DateTime right 
)

Definition at line 218 of file HTMLReport.cpp.

References KKB::HTMLReport::Append(), KKB::KKStr::Concat(), KKB::DateTime::Date(), KKB::TimeType::HH_MM_SS(), KKB::KKStr::operator+(), KKB::KKStr::Str(), KKB::DateTime::Time(), and KKB::DateType::YYYY_MM_DD().

221 {
222  KKStr s = right.Date ().YYYY_MM_DD () + "-" + right.Time ().HH_MM_SS ();
223  htmlReport.Append (s.Str ());
224  return htmlReport;
225 }
KKStr HH_MM_SS() const
Definition: DateTime.cpp:841
KKStr YYYY_MM_DD() const
Convert into displayable string; ex: 20011/05/17.
Definition: DateTime.cpp:701
void Append(const char *str)
Definition: HTMLReport.cpp:88
const KKB::DateType & Date() const
Definition: DateTime.h:230
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
const TimeType & Time() const
Definition: DateTime.h:232
KKStr & KKB::operator<< ( KKB::KKStr left,
const DateType right 
)

Definition at line 737 of file DateTime.cpp.

References KKB::DateType::YYYY_MMM_DD().

740 {
741  left << right.YYYY_MMM_DD ();
742  return left;
743 }
KKStr YYYY_MMM_DD() const
Convert into displayable string; ex: 20011/May/17.
Definition: DateTime.cpp:712
KKStr & KKB::operator<< ( KKB::KKStr left,
const TimeType right 
)

Definition at line 969 of file DateTime.cpp.

References KKB::TimeType::Hour(), KKB::TimeType::Minute(), KKB::TimeType::Second(), and StrFormatInt().

972 {
973  left << StrFormatInt (right.Hour (), "00") << ":"
974  << StrFormatInt (right.Minute (), "00") << ":"
975  << StrFormatInt (right.Second (), "00");
976 
977  return left;
978 }
uchar Hour() const
Definition: DateTime.h:165
uchar Second() const
Definition: DateTime.h:167
KKStr StrFormatInt(kkint32 val, const char *mask)
Definition: KKStr.cpp:5004
uchar Minute() const
Definition: DateTime.h:166
KKStr & KKB::operator<< ( KKB::KKStr left,
const DateTime right 
)

Definition at line 1319 of file DateTime.cpp.

References KKB::DateTime::Date(), and KKB::DateTime::Time().

1322 {
1323  left << right.Date () << "-" << right.Time ();
1324  return left;
1325 }
const KKB::DateType & Date() const
Definition: DateTime.h:230
const TimeType & Time() const
Definition: DateTime.h:232
std::ostream & KKB::operator<< ( std::ostream &  os,
const DateType right 
)

Definition at line 747 of file DateTime.cpp.

References operator<<(), and KKB::DateType::YYYY_MMM_DD().

750 {
751  os << right.YYYY_MMM_DD ();
752  return os;
753 }
KKStr YYYY_MMM_DD() const
Convert into displayable string; ex: 20011/May/17.
Definition: DateTime.cpp:712
std::ostream & KKB::operator<< ( std::ostream &  os,
const TimeType right 
)

Definition at line 982 of file DateTime.cpp.

References KKB::TimeType::Hour(), KKB::TimeType::Minute(), operator<<(), KKB::TimeType::Second(), and StrFormatInt().

985 {
986  os << StrFormatInt (right.Hour (), "00") << ":"
987  << StrFormatInt (right.Minute (), "00") << ":"
988  << StrFormatInt (right.Second (), "00");
989 
990  return os;
991 }
uchar Hour() const
Definition: DateTime.h:165
uchar Second() const
Definition: DateTime.h:167
KKStr StrFormatInt(kkint32 val, const char *mask)
Definition: KKStr.cpp:5004
uchar Minute() const
Definition: DateTime.h:166
std::ostream & KKB::operator<< ( std::ostream &  os,
const DateTime right 
)

Definition at line 1330 of file DateTime.cpp.

References KKB::DateTime::Date(), operator<<(), and KKB::DateTime::Time().

1333 {
1334  os << right.Date () << "-" << right.Time ();
1335  return os;
1336 }
const KKB::DateType & Date() const
Definition: DateTime.h:230
const TimeType & Time() const
Definition: DateTime.h:232
std::istream &__cdecl KKB::operator>> ( std::istream &  is,
KKStr str 
)

Definition at line 4287 of file KKStr.cpp.

References KKB::KKStr::operator=(), KKB::KKStr::TrimLeft(), and KKB::KKStr::TrimRight().

4290 {
4291  char buff[10240];
4292  is >> buff;
4293  str = buff;
4294  str.TrimLeft ();
4295  str.TrimRight ();
4296  return is;
4297 }
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 KKB::osAddLastSlash ( KKStr fileSpec)

Will add the appropriate Directory separator character to the end of fileSpec if one is not there already.

Definition at line 1045 of file OSservices.cpp.

References KKB::KKStr::LastChar().

Referenced by KKMLL::FeatureFileIO::LoadInSubDirectoryTree(), osCopyFileBetweenDirectories(), osMakeFullFileName(), KKMLL::GrayScaleImagesFVList::RecalcFeatureValuesFromImagesInDirTree(), and KKB::Raster::SegmentImage().

1046 {
1047  char c = fileSpec.LastChar ();
1048 
1049  if ((c != '\\') && (c != '/'))
1050  fileSpec << DS;
1051 } /* osAddLastSlash */
#define DS
Definition: OSservices.h:505
char LastChar() const
Definition: KKStr.cpp:2007
void KKB::osChangeDir ( const KKStr dirName,
bool &  successful 
)

Definition at line 793 of file OSservices.cpp.

796 {
797 #ifdef WIN32
798 
799 
800  BOOL changeOk = SetCurrentDirectory(dirName.Str ());
801  if (changeOk)
802  successful = true;
803  else
804  successful = false;
805 
806 #else
807  kkint32 errorCd = chdir (dirName.Str ());
808  successful = (errorCd == 0);
809 
810  if (!successful)
811  {
812  cerr << std::endl << std::endl << std::endl
813  << "osChangeDir *** ERROR *** DirPath[" << dirName << "]" << std::endl
814  << std::endl;
815  }
816 
817 #endif
818 
819 
820  return;
821 } /* osChangeDir */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
bool KKB::osCopyFile ( const KKStr srcFileName,
const KKStr destFileName 
)

Definition at line 689 of file OSservices.cpp.

References KKB::KKStr::Concat().

692 {
693  BOOL fail = 1;
694 
695  bool result = (CopyFile (srcFileName.Str (),
696  destFileName.Str (),
697  fail) != 0);
698 
699 
700  if (result)
701  {
702  return true;
703  }
704 
705  else
706  {
707  DWORD lastError = GetLastError ();
708 
709  KKStr errorMessage = StrFormatInt (lastError, "#,###,##0");
710 
711  cerr << std::endl
712  << "osCopyFile *** ERROR ***" << std::endl
713  << " srcFileName [" << srcFileName << "]" << std::endl
714  << " destFileName[" << destFileName << "]" << std::endl
715  << " Error Code [" << lastError << "]" << std::endl
716  << " Error Msg [" << errorMessage << "]" << std::endl;
717  return false;
718  }
719 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
KKStr StrFormatInt(kkint32 val, const char *mask)
Definition: KKStr.cpp:5004
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
bool KKB::osCopyFileBetweenDirectories ( const KKStr _fileName,
const KKStr _srcDir,
const KKStr _destDir 
)

Definition at line 643 of file OSservices.cpp.

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

647 {
648  KKStr existingFile (_srcDir);
649  KKStr destinationName (_destDir);
650  BOOL fail = 1;
651 
652  osAddLastSlash (existingFile);
653  existingFile << _fileName;
654 
655  osAddLastSlash (destinationName);
656  destinationName << _fileName;
657 
658  bool result = (CopyFile (existingFile.Str (),
659  destinationName.Str (),
660  fail) != 0);
661 
662  if (result)
663  return true;
664  else
665  return false;
666 }
void osAddLastSlash(KKStr &fileSpec)
Will add the appropriate Directory separator character to the end of fileSpec if one is not there alr...
bool KKB::osCreateDirectory ( const KKStr dirName)

Definition at line 875 of file OSservices.cpp.

Referenced by osCreateDirectoryPath().

876 {
877  #ifdef WIN32
878  return (CreateDirectory (_dirName.Str (), NULL) != 0);
879 
880  #else
881 
882  kkint32 result;
883 
884  mode_t mode = S_IRWXU + S_IRWXG;
885 
886  result = mkdir (_dirName.Str (), mode);
887  return result == 0;
888 
889  #endif
890 }
__int32 kkint32
Definition: KKBaseTypes.h:88
bool KKB::osCreateDirectoryPath ( KKStr  _pathName)

Will create the whole Directory Path not just the final part of the path.

For example if you need a directory path "C:\\Temp\\Temple\\DataFiles" created this function will create a directory in the specified path if they do not already exists.

Definition at line 825 of file OSservices.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::Empty(), KKB::KKStr::ExtractToken(), KKB::KKStr::FirstChar(), KKB::KKStr::LastChar(), KKB::KKStr::operator=(), osCreateDirectory(), osValidDirectory(), and KKB::KKStr::SubStrPart().

Referenced by KKB::Raster::SegmentImage().

826 {
827  KKStr nextPartOfPath;
828 
829  if (_pathName.FirstChar () == DSchar)
830  {
831  nextPartOfPath = DS;
832  _pathName = _pathName.SubStrPart (1);
833  nextPartOfPath << _pathName.ExtractToken (DS);
834  }
835  else
836  {
837  nextPartOfPath = _pathName.ExtractToken (DS);
838  }
839 
840  KKStr pathNameSoFar;
841 
842  while (!nextPartOfPath.Empty ())
843  {
844  if (!pathNameSoFar.Empty ())
845  {
846  if (pathNameSoFar.LastChar () != DSchar)
847  pathNameSoFar << DS;
848  }
849 
850  pathNameSoFar << nextPartOfPath;
851 
852  if (!KKB::osValidDirectory (pathNameSoFar))
853  {
854  bool createdSucessfully = osCreateDirectory (pathNameSoFar);
855  if (!createdSucessfully)
856  {
857  cerr << std::endl
858  << "osCreateDirectoryPath Error Creating Directory[" << pathNameSoFar << "]"
859  << std::endl;
860  return false;
861  }
862  }
863 
864  nextPartOfPath = _pathName.ExtractToken (DS);
865  }
866 
867 
868  return true;
869 } /* osCreateDirectoryPath */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
KKStr ExtractToken(const char *delStr="\n\t\r ")
Definition: KKStr.cpp:2969
char FirstChar() const
Definition: KKStr.cpp:1970
#define DS
Definition: OSservices.h:505
char LastChar() const
Definition: KKStr.cpp:2007
bool Empty() const
Definition: KKStr.h:241
bool osValidDirectory(KKStrConstPtr _name)
Definition: OSservices.cpp:382
bool osCreateDirectory(const KKStr &dirName)
Definition: OSservices.cpp:875
#define DSchar
Definition: OSservices.h:506
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::osCreateUniqueFileName ( KKStr  fileName)

Get a unique file name based off file spec 'fileName'.

Make sure that fileName is unique, if file name already is used will add a sequence num to the root part of the name, starting with 0 and incrementing until file name is unique.

Definition at line 2226 of file OSservices.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::Empty(), KKB::KKStr::operator+(), KKB::KKStr::operator=(), osAddSlash(), osFileExists(), osParseFileName(), and StrFormatInt().

2227 {
2228  if (fileName.Empty ())
2229  fileName = "Temp.txt";
2230 
2231  KKStr dirPath, rootName, extension;
2232 
2233  osParseFileName (fileName, dirPath, rootName, extension);
2234 
2235  kkint32 seqNum = 0;
2236  bool fileNameExists = osFileExists (fileName);
2237  while (fileNameExists)
2238  {
2239  if (dirPath.Empty ())
2240  {
2241  fileName = rootName + "_" + StrFormatInt (seqNum, "ZZ00") + "." + extension;
2242  }
2243  else
2244  {
2245  fileName = osAddSlash (dirPath) +
2246  rootName + "_" + StrFormatInt (seqNum, "ZZ00") +
2247  "." + extension;
2248  }
2249 
2250  fileNameExists = osFileExists (fileName);
2251  seqNum++;
2252  }
2253 
2254  return fileName;
2255 } /* osCreateUniqueFileName */
__int32 kkint32
Definition: KKBaseTypes.h:88
KKB::KKStr osAddSlash(const KKStr &fileSpec)
void osParseFileName(KKStr _fileName, KKStr &_dirPath, KKStr &_rootName, KKStr &_extension)
bool Empty() const
Definition: KKStr.h:241
KKStr StrFormatInt(kkint32 val, const char *mask)
Definition: KKStr.cpp:5004
bool osFileExists(const KKStr &_fileName)
Definition: OSservices.cpp:568
bool KKB::osDeleteFile ( KKStr  _fileName)

Definition at line 523 of file OSservices.cpp.

References KKB::KKStr::Str().

524 {
525  #ifdef WIN32
526 
527  const char* fileName = _fileName.Str ();
528 
529  if (DeleteFile (fileName))
530  {
531  return true;
532  }
533  else
534  {
535  DWORD fileAttributes = GetFileAttributes (fileName);
536  fileAttributes = FILE_ATTRIBUTE_NORMAL;
537  if (!SetFileAttributes (fileName, fileAttributes))
538  {
539  return false;
540  }
541 
542  else
543  {
544  // At this point we can either delete this file or not.
545  return (DeleteFile (fileName) != 0);
546  }
547  }
548 
549 
550  #else
551  kkint32 returnCd;
552 
553  // We are in Unix Environment.
554  returnCd = unlink (_fileName.Str ());
555  return (returnCd == 0);
556  #endif
557 } /* DeleteFile */
__int32 kkint32
Definition: KKBaseTypes.h:88
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
void KKB::osDisplayWarning ( KKStr  _message)

Definition at line 2131 of file OSservices.cpp.

Referenced by KKMLL::FeatureVectorList::BinarySearchByName(), and KKMLL::FeatureVectorList::ExtractExamplesForAGivenClass().

2132 {
2133  MessageBox (NULL,
2134  _message.Str (),
2135  "Warning",
2136  (MB_OK + MB_SETFOREGROUND)
2137  );
2138 /*
2139  cerr << endl
2140  << " *** WARNING ***" << endl
2141  << endl
2142  << _message << endl
2143  << endl;
2144  osWaitForEnter ();
2145 */
2146 }
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
bool KKB::osFileExists ( const KKStr _fileName)

Definition at line 568 of file OSservices.cpp.

References KKB::KKStr::Str().

Referenced by KKMLL::TrainingConfiguration2::ConfigFileExists(), KKMLL::TrainingConfiguration2::CreateFromDirectoryStructure(), KKLSC::ScannerFile::CreateScannerFileForOutput(), KKMLL::TrainingConfiguration2::GetEffectiveConfigFileName(), KKJobManagment::KKJobManager::InitilizeJobManager(), KKMLL::TrainingProcess2::LoadExistingTrainingProcess(), KKMLL::FeatureFileIOC45::LoadFeatureFile(), KKMLL::Orderings::Orderings(), and osCreateUniqueFileName().

569 {
570  const char* fileName = _fileName.Str ();
571 
572  #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
573 
574  DWORD fileAttributes = GetFileAttributes (fileName);
575  if (fileAttributes == INVALID_FILE_ATTRIBUTES)
576  {
577  // Error getting Attributes. File may not exist.
578  DWORD lastErrorNum = GetLastError ();
579  if ((lastErrorNum == ERROR_FILE_NOT_FOUND) || (lastErrorNum == 3))
580  return false;
581  }
582 
583  return true;
584 }
#define INVALID_FILE_ATTRIBUTES
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
FILE * KKB::osFOPEN ( const char *  fileName,
const char *  mode 
)
int KKB::osFSEEK ( FILE *  f,
kkint64  offset,
int  origin 
)

Definition at line 104 of file OSservices.cpp.

108 {
109 #if defined(OS_WINDOWS)
110  return _fseeki64(f, offset, origin);
111 #else
112  return fseeko (f, offset, origin);
113 #endif
114 }
KKStr KKB::osGetCurrentDirectory ( )

Definition at line 319 of file OSservices.cpp.

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

Referenced by KKMLL::TrainingConfiguration2::GetEffectiveConfigFileName().

320 {
321  DWORD buffLen = 0;
322  char* buff = NULL;
323  DWORD reqLen = 1000;
324 
325  while (reqLen > buffLen)
326  {
327  buffLen = reqLen;
328 
329  if (buff)
330  delete[] buff;
331 
332  buff = new char[buffLen];
333 
334  reqLen = GetCurrentDirectory (buffLen, buff);
335  }
336 
337  KKStr curDir (buff);
338 
339  delete[] buff;
340 
341  return curDir;
342 } /* GetCurrentDirectory */
KKStr KKB::osGetDirNameFromPath ( KKStr  dirPath)

Extracts the final sub-directory name of the fill directory specification.

ex:Input Returns
----------------------- ----------------------
c:\an\Example\FileSpec\Romeo Romeo
/usr/kkramer/Kinsey/Release_2 Release_2
/usr/kkramer/Thesis/ Thesis
/usr/kkramer/Thesis.dat/ Thesis.dat
Parameters
[in]dirPathDirectory path to get dir name from .

Definition at line 1081 of file OSservices.cpp.

References KKB::KKStr::ChopLastChar(), KKB::KKStr::Concat(), KKB::KKStr::Empty(), KKB::KKStr::LastChar(), KKB::KKStr::operator+(), and osParseFileName().

1082 {
1083  if (dirPath.LastChar () == DSchar)
1084  dirPath.ChopLastChar ();
1085 
1086  KKStr path, root, ext;
1087  osParseFileName (dirPath, path, root, ext);
1088 
1089  if (ext.Empty ())
1090  return root;
1091  else
1092  return root + "." + ext;
1093 } /* osGetDirNameFromPath */
void ChopLastChar()
Definition: KKStr.cpp:1668
char LastChar() const
Definition: KKStr.cpp:2007
void osParseFileName(KKStr _fileName, KKStr &_dirPath, KKStr &_rootName, KKStr &_extension)
bool Empty() const
Definition: KKStr.h:241
#define DSchar
Definition: OSservices.h:506
char KKB::osGetDriveLetter ( const KKStr pathName)

Given a full drive with path and name return the drive letter specified.

If not on a Windows system returns x'00'= char(0)

Parameters
[in]pathNameFile path to extract driver letter from.
Returns
Drive Letter ('A' - 'Z').

Definition at line 297 of file OSservices.cpp.

References KKB::KKStr::Len(), and KKB::KKStr::operator[]().

298 {
299 #ifndef WIN32
300  return 0;
301 #else
302  if (pathName.Len () < 3)
303  return 0;
304 
305  if (pathName[(kkint16)1] == ':')
306  return pathName[(kkint16)0];
307 
308  return 0;
309 #endif
310 } /* osGetDriveLetter */
__int16 kkint16
16 bit signed integer.
Definition: KKBaseTypes.h:85
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
KKStrPtr KKB::osGetEnvVariable ( const KKStr _varName)

Definition at line 897 of file OSservices.cpp.

Referenced by KKLSC::Variables::HomeDir(), osGetNumberOfProcessors(), osSubstituteInEnvironmentVariables(), and KKLSC::Variables::SubstituteInEnvironmentVariables().

898 {
899  char buff[1024];
900  DWORD varLen;
901 
902  varLen = GetEnvironmentVariable (_varName.Str (), buff, sizeof (buff));
903 
904  if (varLen == 0)
905  {
906  return NULL;
907  }
908  else
909  {
910  return new KKStr (buff);
911  }
912 } /* GetEnvVariable */
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
KKStr KKB::osGetErrorNoDesc ( kkint32  errorNo)

Definition at line 45 of file OSservices.cpp.

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

46 {
47  KKStr desc;
48 
49 # ifdef WIN32
50 # ifdef USE_SECURE_FUNCS
51  char buff[100];
52  buff[0] = 0;
53  strerror_s (buff, sizeof (buff), errorNo);
54  desc = buff;
55 # else
56  const char* buff = _sys_errlist[errorNo];
57  if (buff)
58  desc = buff;
59 # endif
60 # else
61  const char* buff = strerror (errorNo);
62  if (buff)
63  desc = buff;
64 # endif
65 
66  return desc;
67 } /* osGetErrorNoDesc */
DateTime KKB::osGetFileDateTime ( const KKStr fileName)

Definition at line 2037 of file OSservices.cpp.

Referenced by KKMLL::TrainingProcess2::CreateTrainingProcess(), and KKMLL::FeatureFileIO::FeatureDataReSink().

2038 {
2039  WIN32_FIND_DATA wfd;
2040 
2041  HANDLE handle = FindFirstFile (fileName.Str (), &wfd);
2042  if (handle == INVALID_HANDLE_VALUE)
2043  {
2044  return DateTime (0, 0, 0, 0 ,0 ,0);
2045  }
2046 
2047 
2048  SYSTEMTIME fileTime;
2049  SYSTEMTIME stLocal;
2050 
2051 
2052  FileTimeToSystemTime (&(wfd.ftLastWriteTime), &fileTime);
2053  SystemTimeToTzSpecificLocalTime(NULL, &fileTime, &stLocal);
2054 
2055  return DateTime ((short)stLocal.wYear,
2056  (uchar)stLocal.wMonth,
2057  (uchar)stLocal.wDay,
2058  (uchar)stLocal.wHour,
2059  (uchar)stLocal.wMinute,
2060  (uchar)stLocal.wSecond
2061  );
2062 
2063 } /* osGetFileDateTime */
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
KKStr KKB::osGetFileExtension ( KKStr  fullFileName)

Definition at line 1323 of file OSservices.cpp.

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

Referenced by KKMLL::TrainingConfiguration2::GetEffectiveConfigFileName(), ReadImage(), SaveImage(), SaveImageGrayscaleInverted4Bit(), SaveImageGrayscaleInverted8Bit(), and SupportedImageFileFormat().

1324 {
1325  KKStr fileName, dirPath, rootName, extension;
1326  osParseFileName (fullFileName, dirPath, rootName, extension);
1327  return extension;
1328 } /* osGetFileExtension */
void osParseFileName(KKStr _fileName, KKStr &_dirPath, KKStr &_rootName, KKStr &_extension)
KKStr KKB::osGetFileNamePartOfFile ( KKStr  fullFileName)

osGetFileNamePartOfFile, retrieves the file name part of the file spec.

ex: Input (fullFileName) Returned
--------------------------------_ ---------------
c:\KurtUtilities\KKBase\KKStr.cpp KKStr.cpp
/bin/usr/KKramer/Dictionary.dat Dictionary.dat
dataFile.data dataFile.data
Parameters
[in]fullFileNameSting that contains the full file name specification.
Returns
File Name.

Definition at line 1471 of file OSservices.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::KKStr(), KKB::KKStr::LastChar(), KKB::KKStr::LocateCharacter(), osLocateLastSlashChar(), and KKB::KKStr::SubStrPart().

1472 {
1473  if (fullFileName.LastChar () == DSchar)
1474  return KKStr ("");
1475 
1476  kkint32 lastSlash = osLocateLastSlashChar (fullFileName);
1477  if (lastSlash < 0)
1478  {
1479  kkint32 colon = fullFileName.LocateCharacter (':');
1480  if (colon < 0)
1481  return fullFileName;
1482  else
1483  return fullFileName.SubStrPart (colon + 1);
1484  }
1485  else
1486  {
1487  return fullFileName.SubStrPart (lastSlash + 1);
1488  }
1489 } /* FileNamePartOfFile */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 osLocateLastSlashChar(const KKStr &fileSpec)
char LastChar() const
Definition: KKStr.cpp:2007
kkint32 LocateCharacter(char ch) const
Returns index of 1st occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2021
#define DSchar
Definition: OSservices.h:506
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
kkint64 KKB::osGetFileSize ( const KKStr fileName)

Definition at line 2096 of file OSservices.cpp.

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

2097 {
2098  WIN32_FIND_DATA wfd;
2099 
2100  HANDLE handle = FindFirstFile (fileName.Str (), &wfd);
2101  if (handle == INVALID_HANDLE_VALUE)
2102  {
2103  return -1;
2104  }
2105 
2106  return (kkint64)(wfd.nFileSizeHigh) * (kkint64)MAXDWORD + (kkint64)(wfd.nFileSizeLow);
2107 }
__int64 kkint64
Definition: KKBaseTypes.h:90
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
KKStr KKB::osGetFullPathOfApplication ( )

returns the name and path of the current running application.

Definition at line 2843 of file OSservices.cpp.

2844 {
2845 #if defined(WIN32)
2846  char szAppPath[MAX_PATH] = "";
2847  DWORD result = ::GetModuleFileName (0, szAppPath, MAX_PATH);
2848  return szAppPath;
2849 #else
2850  return KKStr::EmptyStr ();
2851 #endif
2852 }
KKStr KKB::osGetHostName ( )

Definition at line 1354 of file OSservices.cpp.

References KKB::KKStr::Concat().

1355 {
1356 #if defined(OS_WINDOWS)
1357  char buff[1024];
1358  DWORD buffSize = sizeof (buff) - 1;
1359  memset (buff, 0, sizeof(buff));
1360 
1361  KKStr compName = "";
1362 
1363  //BOOL returnCd = GetComputerNameEx (ComputerNameDnsFullyQualified, buff, &buffSize);
1364  BOOL returnCd = GetComputerNameA (buff, &buffSize);
1365  if (returnCd != 0)
1366  {
1367  compName = buff;
1368  }
1369  else
1370  {
1371  KKStrPtr compNameStr = osGetEnvVariable ("COMPUTERNAME");
1372  if (compNameStr)
1373  {
1374  compName = *compNameStr;
1375  delete compNameStr;
1376  compNameStr = NULL;
1377  }
1378  else
1379  {
1380  compName = "";
1381  }
1382  }
1383 
1384  return compName;
1385 
1386 
1387 #else
1388 
1389  char buff[1024];
1390  memset (buff, 0, sizeof (buff));
1391  kkint32 returnCd = gethostname (buff, sizeof (buff) - 2);
1392  if (returnCd != 0)
1393  return "";
1394  else
1395  return buff;
1396 
1397 #endif
1398 } /* osGetHostName */
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStrPtr osGetEnvVariable(const KKStr &_varName)
Definition: OSservices.cpp:897
double KKB::osGetKernalTimeUsed ( )

Definition at line 1938 of file OSservices.cpp.

1939 {
1940  HANDLE h = GetCurrentProcess ();
1941 
1942  FILETIME creationTime, exitTime, kernelTime, userTime;
1943 
1944  BOOL ok = GetProcessTimes (h, &creationTime, &exitTime, &kernelTime, &userTime);
1945 
1946  if (!ok)
1947  return 0.0;
1948 
1949  SYSTEMTIME st;
1950 
1951  FileTimeToSystemTime(&kernelTime, &st);
1952  double kt = st.wHour * 3600 +
1953  st.wMinute * 60 +
1954  st.wSecond +
1955  st.wMilliseconds / 1000.0;
1956 
1957 
1958  return kt;
1959 } /* osGetSystemTimeUsed */
KKStrListPtr KKB::osGetListOfDirectories ( KKStr  fileSpec)

Definition at line 1743 of file OSservices.cpp.

References KKB::KKStrList::KKStrList(), KKB::KKStr::LastChar(), KKB::KKStr::LocateCharacter(), and osValidDirectory().

Referenced by KKMLL::FeatureFileIO::LoadInSubDirectoryTree(), osGetListOfFilesInDirectoryTree(), and osLookForFile().

1744 {
1745  WIN32_FIND_DATA wfd;
1746 
1747 
1748  if (fileSpec.LastChar () == DSchar)
1749  {
1750  fileSpec << "*.*";
1751  }
1752 
1753  else if (fileSpec.LocateCharacter ('*') < 0)
1754  {
1755  if (osValidDirectory (&fileSpec))
1756  {
1757  fileSpec << "\\*.*";
1758  }
1759  }
1760 
1761  KKStrListPtr nameList = new KKStrList (true);
1762 
1763  HANDLE handle = FindFirstFile (fileSpec.Str (), &wfd);
1764 
1765  if (handle == INVALID_HANDLE_VALUE)
1766  {
1767  delete nameList;
1768  return NULL;
1769  }
1770 
1771 
1772  BOOL moreFiles = true;
1773  while (moreFiles)
1774  {
1775  if ((wfd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) == 0)
1776  {
1777  if ((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
1778  {
1779  KKStrPtr dirName = new KKStr (wfd.cFileName);
1780 
1781  if ((*dirName != ".") && (*dirName != ".."))
1782  nameList->PushOnBack (dirName);
1783  else
1784  delete dirName;
1785  }
1786  }
1787 
1788  moreFiles = FindNextFile (handle, &wfd);
1789  }
1790 
1791  FindClose (handle);
1792 
1793  return nameList;
1794 } /* osGetListOfDirectories */
char LastChar() const
Definition: KKStr.cpp:2007
virtual void PushOnBack(EntryPtr _entry)
Definition: KKQueue.h:398
bool osValidDirectory(KKStrConstPtr _name)
Definition: OSservices.cpp:382
kkint32 LocateCharacter(char ch) const
Returns index of 1st occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2021
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
#define DSchar
Definition: OSservices.h:506
KKStrListPtr KKB::osGetListOfFiles ( const KKStr fileSpec)

Returns a list of files that match the provided file specification.

You can provide any file specification including a directory path. If there is a failure will return NULL. The caller will be responsible for deleting the returned list. The file names returned will not include any directory path.

Definition at line 1531 of file OSservices.cpp.

References KKB::KKStrList::KKStrList().

Referenced by KKMLL::FeatureFileIO::FeatureDataReSink(), osGetListOfFilesInDirectoryTree(), osGetListOfImageFiles(), and osLookForFile().

1532 {
1533  WIN32_FIND_DATA wfd;
1534 
1535  HANDLE handle = FindFirstFile (fileSpec.Str (), &wfd);
1536 
1537  if (handle == INVALID_HANDLE_VALUE)
1538  {
1539  return NULL;
1540  }
1541 
1542  KKStrListPtr nameList = new KKStrList (true);
1543 
1544  BOOL moreFiles = true;
1545  while (moreFiles)
1546  {
1547  if ((wfd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) == 0)
1548  {
1549  if ((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
1550  {
1551  nameList->PushOnBack (new KKStr (wfd.cFileName));
1552  }
1553  }
1554 
1555  moreFiles = FindNextFile (handle, &wfd);
1556  }
1557 
1558  FindClose (handle);
1559 
1560  return nameList;
1561 } /* osGetListOfFiles */
virtual void PushOnBack(EntryPtr _entry)
Definition: KKQueue.h:398
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
void KKB::osGetListOfFilesInDirectoryTree ( const KKStr rootDir,
KKStr  fileSpec,
VectorKKStr fileNames 
)

Definition at line 1668 of file OSservices.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::Empty(), KKB::KKStr::operator+(), KKB::KKStr::operator=(), KKB::KKStr::operator==(), osAddSlash(), osGetListOfDirectories(), osGetListOfFiles(), and osGetListOfFilesInDirectoryTree().

Referenced by osGetListOfFilesInDirectoryTree().

1672 {
1673  if (fileSpec.Empty ())
1674  fileSpec = "*.*";
1675 
1676  {
1677  KKStrListPtr filesInThisDirectory = osGetListOfFiles (osAddSlash (rootDir) + fileSpec);
1678  if (filesInThisDirectory)
1679  {
1680  KKStrList::iterator idx;
1681  for (idx = filesInThisDirectory->begin (); idx != filesInThisDirectory->end (); idx++)
1682  {
1683  KKStrPtr fn = *idx;
1684  KKStr fullName = osAddSlash (rootDir) + (*fn);
1685  fileNames.push_back (fullName);
1686  }
1687  delete filesInThisDirectory; filesInThisDirectory = NULL;
1688  }
1689  }
1690 
1691  // Lets now process all sub directories below 'rootDir'
1692  KKStrListPtr subDirectories = osGetListOfDirectories (osAddSlash (rootDir) + "*.*");
1693  if (subDirectories)
1694  {
1695  KKStrList::iterator idx;
1696  for (idx = subDirectories->begin (); idx != subDirectories->end (); idx++)
1697  {
1698  KKStr subDirName = **idx;
1699  if ((subDirName == ".") || (subDirName == ".."))
1700  continue;
1701 
1702 
1703  KKStr dirToSearch = osAddSlash (rootDir) + subDirName;
1704  osGetListOfFilesInDirectoryTree (dirToSearch, fileSpec, fileNames);
1705  }
1706 
1707  delete subDirectories; subDirectories = NULL;
1708  }
1709 
1710  return;
1711 } /* osGetListOfFilesInDirectoryTree */
void osGetListOfFilesInDirectoryTree(const KKStr &rootDir, KKStr fileSpec, VectorKKStr &fileNames)
KKStrListPtr osGetListOfFiles(const KKStr &fileSpec)
Returns a list of files that match the provided file specification.
KKB::KKStr osAddSlash(const KKStr &fileSpec)
bool Empty() const
Definition: KKStr.h:241
KKStrListPtr osGetListOfDirectories(KKStr fileSpec)
KKStrListPtr KKB::osGetListOfImageFiles ( KKStr  fileSpec)

Definition at line 1717 of file OSservices.cpp.

References KKB::KKStr::Concat(), KKB::KKStrList::KKStrList(), and osGetListOfFiles().

1718 {
1719  KKStrListPtr imageFileNames = new KKStrList (true);
1720 
1721  KKStrListPtr filesInDir = osGetListOfFiles (fileSpec);
1722  if (filesInDir)
1723  {
1724  KKStrList::iterator fnIDX;
1725  for (fnIDX = filesInDir->begin (); fnIDX != filesInDir->end (); ++fnIDX)
1726  {
1727  KKStr fileName (**fnIDX);
1728  if (SupportedImageFileFormat (fileName))
1729  imageFileNames->PushOnBack (new KKStr (fileName));
1730  }
1731 
1732  delete filesInDir;
1733  filesInDir = NULL;
1734  }
1735 
1736  return imageFileNames;
1737 } /* osGetListOfImageFiles */
KKStrListPtr osGetListOfFiles(const KKStr &fileSpec)
Returns a list of files that match the provided file specification.
bool SupportedImageFileFormat(const KKStr &imageFileName)
Definition: ImageIO.cpp:948
virtual void PushOnBack(EntryPtr _entry)
Definition: KKQueue.h:398
DateTime KKB::osGetLocalDateTime ( )

Returned the current local date and time.

Definition at line 1993 of file OSservices.cpp.

Referenced by KKB::KKThread::AddMsg(), KKMLL::TrainingProcess2::CreateModelsFromTrainingData(), KKMLL::FeatureFileIO::FeatureDataReSink(), KKB::KKThread::WaitForThreadToStop(), and KKMLL::SVMModel::WriteXML().

1994 {
1995  SYSTEMTIME sysTime;
1996 
1997  GetLocalTime(&sysTime);
1998 
1999  DateTime dateTime ((short)sysTime.wYear,
2000  (uchar)sysTime.wMonth,
2001  (uchar)sysTime.wDay,
2002  (uchar)sysTime.wHour,
2003  (uchar)sysTime.wMinute,
2004  (uchar)sysTime.wSecond
2005  );
2006 
2007  return dateTime;
2008 } /* osGetCurrentDateTime */
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
kkint32 KKB::osGetNumberOfProcessors ( )

returns the number of CPU's or number of simultaneous threads that you can have.

Definition at line 1449 of file OSservices.cpp.

References osGetEnvVariable(), and KKB::KKStr::ToInt32().

1450 {
1451 #if defined(OS_WINDOWS)
1452  KKStrPtr numProcessorsStr = osGetEnvVariable ("NUMBER_OF_PROCESSORS");
1453  kkuint32 numOfProcessors = -1;
1454  if (numProcessorsStr)
1455  {
1456  numOfProcessors = numProcessorsStr->ToInt32 ();
1457  delete numProcessorsStr;
1458  numProcessorsStr = NULL;
1459  }
1460 
1461  return numOfProcessors;
1462 #else
1463  /** @todo Need to implement 'osGetNumberOfProcessors' for linux. */
1464  return 1;
1465 #endif
1466 } /* osGetNumberOfProcessors */
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
kkint32 ToInt32() const
Definition: KKStr.cpp:3587
KKStrPtr osGetEnvVariable(const KKStr &_varName)
Definition: OSservices.cpp:897
KKStr KKB::osGetParentDirectoryOfDirPath ( KKStr  path)

Definition at line 1202 of file OSservices.cpp.

References KKB::KKStr::ChopLastChar(), KKB::KKStr::Concat(), KKB::KKStr::EmptyStr(), KKB::KKStr::LastChar(), KKB::KKStr::LocateLastOccurrence(), and KKB::KKStr::SubStrPart().

1203 {
1204  if (path.LastChar () == DSchar)
1205  path.ChopLastChar ();
1206 
1207  kkint32 x1 = path.LocateLastOccurrence (DSchar);
1208  kkint32 x2 = path.LocateLastOccurrence (':');
1209 
1210  kkint32 x = Max (x1, x2);
1211  if (x < 1)
1212  return KKStr::EmptyStr ();
1213 
1214  return path.SubStrPart (0, x);
1215 } /* osGetParentDirectoryOfDirPath */
__int32 kkint32
Definition: KKBaseTypes.h:88
void ChopLastChar()
Definition: KKStr.cpp:1668
char LastChar() const
Definition: KKStr.cpp:2007
kkint32 LocateLastOccurrence(char ch) const
Returns index of last occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2118
#define DSchar
Definition: OSservices.h:506
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
KKStr KKB::osGetParentDirPath ( KKStr  dirPath)

Returns the Parent directory path to 'dirPath'.

ex:Input Returns
----------------------- ----------------------
c:\an\Example\FileSpec\Romeo c:\an\Example\FileSpec
/usr/kkramer/Kinsey/Release_2 /usr/kkramer/Kinsey
/usr/kkramer/Thesis/ /usr/kkramer
/usr/kkramer/Thesis.dat/ /usr/kkramer

Definition at line 1333 of file OSservices.cpp.

References KKB::KKStr::ChopLastChar(), KKB::KKStr::Concat(), KKB::KKStr::EmptyStr(), KKB::KKStr::LastChar(), KKB::KKStr::LocateLastOccurrence(), and KKB::KKStr::SubStrPart().

1334 {
1335  if ((dirPath.LastChar () == '\\') || (dirPath.LastChar () == '/'))
1336  dirPath.ChopLastChar ();
1337 
1338  int x = Max (dirPath.LocateLastOccurrence ('\\'), dirPath.LocateLastOccurrence ('/'));
1339 
1340  if (x < 0)
1341  {
1342  x = dirPath.LocateLastOccurrence (':');
1343  if (x >= 0)
1344  return dirPath.SubStrPart (0, x - 1);
1345  else
1346  return KKStr::EmptyStr ();
1347  }
1348 
1349  return dirPath.SubStrPart (0, x - 1);
1350 }
void ChopLastChar()
Definition: KKStr.cpp:1668
char LastChar() const
Definition: KKStr.cpp:2007
kkint32 LocateLastOccurrence(char ch) const
Returns index of last occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2118
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
KKStr KKB::osGetPathPartOfFile ( KKStr  fullFileName)

Get the path part of a full file name specification.

ex:Input Returns
----------------------- ----------------------
c:\an\Example\FileSpec\data.txt c:\an\Example\FileSpec
/usr/kkramer/Plankton/Relase_2 /usr/kkramer/Plankton
/usr/kkramer/Thesis/ /usr/kkramer/Thesis
Parameters
[in]fullFileNameThe full file specification including directory path, root-name, and extension.
Returns
Path part of fullFileName.

Definition at line 1305 of file OSservices.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::KKStr(), KKB::KKStr::LocateLastOccurrence(), osLocateLastSlashChar(), and KKB::KKStr::SubStrPart().

Referenced by KKMLL::TrainingConfiguration2::GetEffectiveConfigFileName().

1306 {
1307  kkint32 lastSlash = osLocateLastSlashChar (fullFileName);
1308 
1309  if (lastSlash >= 0)
1310  {
1311  return fullFileName.SubStrPart (0, lastSlash - 1);
1312  }
1313 
1314  kkint32 lastColon = fullFileName.LocateLastOccurrence (':');
1315  if (lastColon >= 0)
1316  return fullFileName.SubStrPart (0, lastColon);
1317  else
1318  return KKStr ("");
1319 } /* GetPathPartOfFile */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 osLocateLastSlashChar(const KKStr &fileSpec)
kkint32 LocateLastOccurrence(char ch) const
Returns index of last occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2118
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 KKB::osGetProcessId ( )

Definition at line 2736 of file OSservices.cpp.

Referenced by GetProcessId().

2737 {
2738 #ifdef WIN32
2739  //DWORD WINAPI processId = GetCurrentProcessId ();
2740  DWORD processId = GetCurrentProcessId();
2741  return processId;
2742 
2743 #else
2744  pid_t processID = getpid ();
2745  return processID;
2746 
2747 #endif
2748 }
KKStr KKB::osGetProgName ( )

Definition at line 1402 of file OSservices.cpp.

References KKB::KKStr::Concat().

1403 {
1404 #if defined(OS_WINDOWS)
1405  KKStr progName;
1406 
1407  char filename[ MAX_PATH ];
1408  DWORD size = GetModuleFileNameA (NULL, filename, MAX_PATH);
1409  if (size)
1410  progName = filename;
1411  else
1412  progName = "";
1413 
1414  return progName;
1415 
1416 #else
1417  return "NotImplemented";
1418 #endif
1419 }
KKStr KKB::osGetRootName ( const KKStr fullFileName)

Definition at line 1154 of file OSservices.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::LocateLastOccurrence(), KKB::KKStr::operator=(), osLocateLastSlashChar(), and KKB::KKStr::SubStrPart().

Referenced by KKLSC::ScannerFile::CreateGoalie(), KKMLL::TrainingProcess2::CreateModelsFromTrainingData(), KKMLL::ModelDual::Description(), KKMLL::DuplicateImage::ExampleWithSmallestScanLine(), KKB::Raster::ExtractChannel(), KKMLL::FeatureVectorList::ExtractDuplicatesByRootImageFileName(), KKMLL::ExtractExampleFileName::ExtractKey(), KKMLL::FeatureFileIO::FeatureDataReSink(), KKLSC::ScannerFileEntry::GetOrCreateScannerFileEntry(), KKMLL::TrainingConfiguration2::Load(), KKMLL::FeatureFileIODstWeb::LoadFile(), KKMLL::FeatureFileIOColumn::LoadFile(), KKMLL::FeatureFileIOUCI::LoadFile(), KKMLL::FeatureFileIOC45::LoadFile(), KKMLL::FeatureFileIOSparse::LoadFile(), KKMLL::TrainingConfiguration2List::LookUp(), KKMLL::FeatureVectorList::LookUpByRootName(), KKMLL::FeatureVectorList::RootNameComparrisonReversed::operator()(), KKLSC::ScannerFile::ScannerFile(), and KKB::Raster::SegmentImage().

1155 {
1156  kkint32 lastSlashChar = osLocateLastSlashChar (fullFileName);
1157  kkint32 lastColon = fullFileName.LocateLastOccurrence (':');
1158 
1159  kkint32 lastSlashOrColon = Max (lastSlashChar, lastColon);
1160 
1161  KKStr lastPart;
1162  if (lastSlashOrColon < 0)
1163  {
1164  lastPart = fullFileName;
1165  }
1166  else
1167  {
1168  lastPart = fullFileName.SubStrPart (lastSlashOrColon + 1);
1169  }
1170 
1171  kkint32 period = lastPart.LocateLastOccurrence ('.');
1172 
1173  if (period < 0)
1174  return lastPart;
1175 
1176  return lastPart.SubStrPart (0, period - 1);
1177 } /* osGetRootName */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 osLocateLastSlashChar(const KKStr &fileSpec)
kkint32 LocateLastOccurrence(char ch) const
Returns index of last occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2118
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
KKStr KKB::osGetRootNameOfDirectory ( KKStr  fullDirName)

Definition at line 1181 of file OSservices.cpp.

References KKB::KKStr::ChopLastChar(), KKB::KKStr::Concat(), KKB::KKStr::LastChar(), KKB::KKStr::LocateLastOccurrence(), KKB::KKStr::operator=(), osLocateLastSlashChar(), and KKB::KKStr::SubStrPart().

Referenced by KKMLL::TrainingConfiguration2::CreateFromDirectoryStructure(), KKMLL::MLClass::GetClassNameFromDirName(), and KKMLL::FeatureFileIO::LoadInSubDirectoryTree().

1182 {
1183  if (fullDirName.LastChar () == DSchar)
1184  fullDirName.ChopLastChar ();
1185 
1186  kkint32 lastSlashChar = osLocateLastSlashChar (fullDirName);
1187  kkint32 lastColon = fullDirName.LocateLastOccurrence (':');
1188 
1189  kkint32 lastSlashOrColon = Max (lastSlashChar, lastColon);
1190 
1191  KKStr lastPart;
1192  if (lastSlashOrColon < 0)
1193  lastPart = fullDirName;
1194  else
1195  lastPart = fullDirName.SubStrPart (lastSlashOrColon + 1);
1196 
1197  return lastPart;
1198 } /* osGetRootNameOfDirectory */
__int32 kkint32
Definition: KKBaseTypes.h:88
void ChopLastChar()
Definition: KKStr.cpp:1668
kkint32 osLocateLastSlashChar(const KKStr &fileSpec)
char LastChar() const
Definition: KKStr.cpp:2007
kkint32 LocateLastOccurrence(char ch) const
Returns index of last occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2118
#define DSchar
Definition: OSservices.h:506
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
KKStr KKB::osGetRootNameWithExtension ( const KKStr fullFileName)

Definition at line 1219 of file OSservices.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::LocateLastOccurrence(), KKB::KKStr::operator=(), osLocateLastSlashChar(), and KKB::KKStr::SubStrPart().

Referenced by KKMLL::TrainingConfiguration2::GetEffectiveConfigFileName(), and KKMLL::FeatureVectorList::RootNameComparrison::operator()().

1220 {
1221  kkint32 lastSlashChar = osLocateLastSlashChar (fullFileName);
1222  kkint32 lastColon = fullFileName.LocateLastOccurrence (':');
1223 
1224  kkint32 lastSlashOrColon = Max (lastSlashChar, lastColon);
1225 
1226  KKStr lastPart;
1227  if (lastSlashOrColon < 0)
1228  {
1229  lastPart = fullFileName;
1230  }
1231  else
1232  {
1233  lastPart = fullFileName.SubStrPart (lastSlashOrColon + 1);
1234  }
1235 
1236  return lastPart;
1237 } /* osGetRootNameWithExtension */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 osLocateLastSlashChar(const KKStr &fileSpec)
kkint32 LocateLastOccurrence(char ch) const
Returns index of last occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2118
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
kkuint64 KKB::osGetSystemTimeInMiliSecs ( )

Returns mili-secs that system (Windows = has been started, Linux time in epoch).

Definition at line 1976 of file OSservices.cpp.

1977 {
1978  return timeGetTime();
1979 } /* osGetSystemTimeInMiliSecs */
double KKB::osGetSystemTimeUsed ( )

Returns the number of CPU seconds used by current process.

This consists of both User and Kernel Time. When used to get timing data of some function, Call this method before and after running the function and use the difference.

Definition at line 1855 of file OSservices.cpp.

Referenced by KKMLL::FeatureEncoder::CompressExamples(), KKJobManagment::KKJobManager::InitilizeJobManager(), KKMLL::Model::TrainingTimeEnd(), KKMLL::Model::TrainingTimeStart(), and KKMLL::Model::TrainModel().

1856 {
1857  HANDLE h = GetCurrentProcess ();
1858 
1859  FILETIME creationTime, exitTime, kernelTime, userTime;
1860 
1861  BOOL ok = GetProcessTimes (h, &creationTime, &exitTime, &kernelTime, &userTime);
1862 
1863  if (!ok)
1864  return 0;
1865 
1866  SYSTEMTIME st;
1867 
1868  FileTimeToSystemTime(&kernelTime, &st);
1869  double kt = st.wHour * 3600 + st.wMinute * 60 + st.wSecond;
1870  kt += ((double)st.wMilliseconds / 1000.0);
1871 
1872  FileTimeToSystemTime(&userTime, &st);
1873  double ut = st.wHour * 3600 + st.wMinute * 60 + st.wSecond;
1874  ut += ((double)st.wMilliseconds / 1000.0);
1875 
1876  double numOfSecs = kt + ut;
1877 
1878  // (kernelTime.dwLowDateTime + userTime.dwLowDateTime) / 10000000 + 0.5;
1879  return numOfSecs;
1880 } /* osGetSystemTimeUsed */
kkint32 KKB::osGetThreadId ( )

Definition at line 2752 of file OSservices.cpp.

Referenced by KKB::KKThread::AddMsg(), KKB::RunLog::Append(), KKB::GoalKeeperSimple::BlockedByAnotherThread(), KKB::GoalKeeper::BlockedByAnotherThread(), KKB::GoalKeeperSimple::EndBlock(), KKB::GoalKeeper::EndBlock(), KKB::GoalKeeperSimple::StartBlock(), and KKB::GoalKeeper::StartBlock().

2753 {
2754 #ifdef WIN32
2755  //DWORD WINAPI threadId = GetCurrentThreadId ();
2756  DWORD threadId = GetCurrentThreadId();
2757  return threadId;
2758 #else
2759  return 0;
2760 #endif
2761 }
KKStr KKB::osGetUserName ( )

Definition at line 1426 of file OSservices.cpp.

References KKB::KKStr::Concat().

1427 {
1428 #if defined(OS_WINDOWS)
1429  TCHAR name [ UNLEN + 1 ];
1430  DWORD size = UNLEN + 1;
1431 
1432  KKStr userName = "";
1433  if (GetUserName ((TCHAR*)name, &size))
1434  userName = name;
1435  else
1436  userName = "***ERROR***";
1437 
1438  return userName;
1439 #else
1440 
1441  return "NoImplemented";
1442 #endif
1443 } /* osGetUserName */
double KKB::osGetUserTimeUsed ( )

Definition at line 1897 of file OSservices.cpp.

1898 {
1899  HANDLE h = GetCurrentProcess ();
1900 
1901  FILETIME creationTime, exitTime, kernelTime, userTime;
1902 
1903  BOOL ok = GetProcessTimes (h, &creationTime, &exitTime, &kernelTime, &userTime);
1904 
1905  if (!ok)
1906  return 0;
1907 
1908 
1909  SYSTEMTIME st;
1910 
1911  FileTimeToSystemTime(&userTime, &st);
1912  double ut = st.wHour * 3600 +
1913  st.wMinute * 60 +
1914  st.wSecond +
1915  st.wMilliseconds / 1000.0;
1916 
1917  return ut;
1918 } /* osGetSystemTimeUsed */
template<class T >
T* KKB::osGrowAllocation ( T *  src,
kkint32  origSize,
kkint32  newSize 
)
inline

Definition at line 489 of file OSservices.h.

493  {
494  kkint32 zed = 0;
495  T* dest = new T[newSize];
496  while (zed < origSize) {dest[zed] = src[zed]; zed++;}
497  while (zed < newSize) {dest[zed] = (T)0; zed++;}
498  delete src;
499  return dest;
500  } /* GrowAllocation */
__int32 kkint32
Definition: KKBaseTypes.h:88
bool KKB::osIsBackGroundProcess ( )

Definition at line 1506 of file OSservices.cpp.

References backGroundProcess.

1507 {
1508  return backGroundProcess;
1509 }
bool backGroundProcess
kkint32 KKB::osLocateFirstSlashChar ( const KKStr fileSpec)

Definition at line 1027 of file OSservices.cpp.

References KKB::KKStr::LocateCharacter().

1028 {
1029  kkint32 firstForewardSlash = fileSpec.LocateCharacter ('/');
1030  kkint32 firstBackSlash = fileSpec.LocateCharacter ('\\');
1031 
1032  if (firstForewardSlash < 0)
1033  return firstBackSlash;
1034 
1035  else if (firstBackSlash < 0)
1036  return firstForewardSlash;
1037 
1038  return Min (firstForewardSlash, firstBackSlash);
1039 } /* LastSlashChar */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 LocateCharacter(char ch) const
Returns index of 1st occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2021
kkint32 Min(kkint32 x1, kkint32 x2)
Definition: Raster.cpp:229
kkint32 KKB::osLocateLastSlashChar ( const KKStr fileSpec)

Definition at line 1017 of file OSservices.cpp.

References KKB::KKStr::LocateLastOccurrence().

Referenced by osGetFileNamePartOfFile(), osGetPathPartOfFile(), osGetRootName(), osGetRootNameOfDirectory(), osGetRootNameWithExtension(), osParseFileName(), osParseFileSpec(), and osRemoveExtension().

1018 {
1019  kkint32 lastLeftSlash = fileSpec.LocateLastOccurrence ('\\');
1020  kkint32 lastRightSlash = fileSpec.LocateLastOccurrence ('/');
1021 
1022  return Max (lastLeftSlash, lastRightSlash);
1023 } /* LastSlashChar */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 LocateLastOccurrence(char ch) const
Returns index of last occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2118
T Max(T a, T b)
generic Max function, Both parameters must be of the same type.
Definition: KKBaseTypes.h:181
KKStr KKB::osLookForFile ( const KKStr fileName,
const KKStr srcDir 
)

Look for a specified file in a sub-directory structure.

Parameters
[in]fileNameName of file we are looking for.
[in]srcDirSub Directory tree we want to search.
Returns
Full directory path to where first occurrence of fileName is located. If not found will return back an empty string.

Definition at line 2174 of file OSservices.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::Empty(), KKB::KKStr::KKStr(), KKB::KKStr::operator+(), osAddSlash(), osGetListOfDirectories(), osGetListOfFiles(), osLookForFile(), KKB::KKStr::Str(), KKB::KKStr::StrEqualNoCase(), and KKB::KKStr::Upper().

Referenced by osLookForFile().

2177 {
2178  KKStr fileNameUpper (fileName);
2179  fileNameUpper.Upper ();
2180 
2181  KKStr fileSpec = osAddSlash (srcDir) + fileName;
2182  //KKStr fileSpec = osAddSlash (srcDir) + "*.*";
2183 
2184  // We will first look at contents of 'srcDir' and if not there then look at sub directories
2185  KKStrListPtr files = osGetListOfFiles (fileSpec);
2186  if (files)
2187  {
2188  for (KKStrList::iterator nIDX = files->begin (); nIDX != files->end (); nIDX++)
2189  {
2190  KKStrPtr fnPtr = *nIDX;
2191  if (KKStr::StrEqualNoCase (fileName.Str (), fnPtr->Str ()))
2192  {
2193  delete files;
2194  files = NULL;
2195  return srcDir;
2196  }
2197  }
2198  delete files;
2199  files = NULL;
2200  }
2201 
2202  KKStrListPtr subDirs = osGetListOfDirectories (srcDir);
2203  if (subDirs)
2204  {
2205  for (KKStrList::iterator sdIDX = subDirs->begin (); sdIDX != subDirs->end (); sdIDX++)
2206  {
2207  KKStr subDirName = osAddSlash (srcDir) + **sdIDX;
2208  KKStr resultDir = osLookForFile (fileName, subDirName);
2209  if (!resultDir.Empty ())
2210  {
2211  delete subDirs;
2212  subDirs = NULL;
2213  return resultDir;
2214  }
2215  }
2216 
2217  delete subDirs; subDirs = NULL;
2218  }
2219 
2220  return "";
2221 } /* osLookForFile */
KKStrListPtr osGetListOfFiles(const KKStr &fileSpec)
Returns a list of files that match the provided file specification.
KKB::KKStr osAddSlash(const KKStr &fileSpec)
KKStr osLookForFile(const KKStr &fileName, const KKStr &srcDir)
Look for a specified file in a sub-directory structure.
bool Empty() const
Definition: KKStr.h:241
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
KKStrListPtr osGetListOfDirectories(KKStr fileSpec)
KKStr KKB::osMakeFullFileName ( const KKStr _dirName,
const KKStr _fileName 
)

Definition at line 1066 of file OSservices.cpp.

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

1069 {
1070  KKStr fullFileName (_dirName);
1071 
1072  osAddLastSlash (fullFileName);
1073 
1074  fullFileName << _fileName;
1075 
1076  return fullFileName;
1077 }
void osAddLastSlash(KKStr &fileSpec)
Will add the appropriate Directory separator character to the end of fileSpec if one is not there alr...
bool KKB::osMoveFileBetweenDirectories ( const KKStr _fileName,
const KKStr _srcDir,
const KKStr _destDir 
)

Definition at line 609 of file OSservices.cpp.

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

613 {
614  #ifdef WIN32
615 
616  KKStr srcName (_srcDir);
617  KKStr destName (_destDir);
618 
619  if (srcName.LastChar () != '\\')
620  srcName << "\\";
621 
622  if (destName.LastChar () != '\\')
623  destName << "\\";
624 
625  srcName << _fileName;
626  destName << _fileName;
627 
628  return (MoveFile (srcName.Str (), destName.Str ()) != 0);
629 
630  #else
631  cerr << std::endl;
632  cerr << "*** osMoveFileBetweenDirectories ***" << std::endl;
633  cerr << std::endl;
634  cerr << "*** Not yet implemented ***" << std::endl;
635  osWaitForEnter ();
636  exit (-1);
637  #endif
638 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
void osWaitForEnter()
void KKB::osParseFileName ( KKStr  _fileName,
KKStr _dirPath,
KKStr _rootName,
KKStr _extension 
)

Definition at line 1097 of file OSservices.cpp.

References KKB::KKStr::LocateLastOccurrence(), KKB::KKStr::operator=(), osLocateLastSlashChar(), and KKB::KKStr::SubStrPart().

Referenced by osCreateUniqueFileName(), osGetDirNameFromPath(), and osGetFileExtension().

1102 {
1103  kkint32 x;
1104 
1105  x = osLocateLastSlashChar (_fileName);
1106 
1107  if (x < 0)
1108  {
1109  _dirPath = "";
1110  }
1111 
1112  else
1113  {
1114  _dirPath = _fileName.SubStrPart (0, x - 1);
1115  _fileName = _fileName.SubStrPart (x + 1);
1116  }
1117 
1118 
1119  x = _fileName.LocateLastOccurrence ('.');
1120  if (x < 0)
1121  {
1122  _rootName = _fileName;
1123  _extension = "";
1124  }
1125  else
1126  {
1127  _rootName = _fileName.SubStrPart (0, x - 1);
1128  _extension = _fileName.SubStrPart (x + 1);
1129  }
1130 
1131  return;
1132 } /* ParseFileName */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 osLocateLastSlashChar(const KKStr &fileSpec)
kkint32 LocateLastOccurrence(char ch) const
Returns index of last occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2118
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
void KKB::osParseFileSpec ( KKStr  fullFileName,
KKStr driveLetter,
KKStr path,
KKStr root,
KKStr extension 
)

Definition at line 1243 of file OSservices.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::LastChar(), KKB::KKStr::LocateCharacter(), KKB::KKStr::LocateLastOccurrence(), KKB::KKStr::operator=(), osLocateLastSlashChar(), and KKB::KKStr::SubStrPart().

1249 {
1250  path = "";
1251  root = "";
1252  extension = "";
1253  driveLetter = "";
1254 
1255  // Look for Drive Letter
1256  kkint32 driveLetterPos = fullFileName.LocateCharacter (':');
1257  if (driveLetterPos >= 0)
1258  {
1259  driveLetter = fullFileName.SubStrPart (0, driveLetterPos - 1);
1260  fullFileName = fullFileName.SubStrPart (driveLetterPos + 1);
1261  }
1262 
1263  KKStr fileName;
1264 
1265  if (fullFileName.LastChar () == DSchar)
1266  {
1267  // FileSpec must look like 'c:\xxx\xx\'
1268  path = fullFileName;
1269  root = "";
1270  extension = "";
1271  return;
1272  }
1273 
1274  kkint32 lastSlash = osLocateLastSlashChar (fullFileName);
1275  if (lastSlash < 0)
1276  {
1277  path = "";
1278  fileName = fullFileName;
1279  }
1280  else
1281  {
1282  path = fullFileName.SubStrPart (0, lastSlash - 1);
1283  fileName = fullFileName.SubStrPart (lastSlash + 1);
1284  }
1285 
1286  kkint32 period = fileName.LocateLastOccurrence ('.');
1287  if (period <= 0)
1288  {
1289  root = fileName;
1290  extension = "";
1291  }
1292  else
1293  {
1294  root = fileName.SubStrPart (0, period - 1);
1295  extension = fileName.SubStrPart (period + 1);
1296  }
1297 
1298  return;
1299 } /* osParseFileSpec */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 osLocateLastSlashChar(const KKStr &fileSpec)
char LastChar() const
Definition: KKStr.cpp:2007
kkint32 LocateLastOccurrence(char ch) const
Returns index of last occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2118
kkint32 LocateCharacter(char ch) const
Returns index of 1st occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2021
#define DSchar
Definition: OSservices.h:506
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
KKStrPtr KKB::osReadNextLine ( FILE *  in)

Read the next line from the file and return a c-String(NULL terminated).

Will read in characters from 'in' until a line feed character is read. The caller will own the string returned and be responsible for deleting it.

Parameters
[in]inFile to read from.
Returns
A dynamically allocated c-string (NULL Terminated) containing the next line in the file. If end-of-file reached will return a NULL pointer.

Definition at line 2261 of file OSservices.cpp.

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

2262 {
2263  if (feof (in))
2264  return NULL;
2265 
2266  KKStrPtr buff = new KKStr (100);
2267  while (true)
2268  {
2269  if (feof (in))
2270  break;
2271 
2272  char ch = fgetc (in);
2273  if (ch == '\r')
2274  {
2275  if (!feof (in))
2276  {
2277  char nextCh = fgetc (in);
2278  if (nextCh != '\n')
2279  ungetc (nextCh, in);
2280  break;
2281  }
2282  }
2283  else if (ch == '\n')
2284  {
2285  break;
2286  }
2287 
2288  buff->Append (ch);
2289  if (buff->Len () >= uint16_max)
2290  break;
2291  }
2292 
2293  return buff;
2294 } /* osReadNextLine */
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
void Append(const char *buff)
Definition: KKStr.cpp:1783
#define uint16_max
Definition: KKBaseTypes.h:118
KKStr KKB::osReadNextQuotedStr ( FILE *  in,
const char *  whiteSpaceCharacters,
bool &  eof 
)

Read the next Quoted String from the file.

If the first non whitespace character is a quote (") character will read in rest of string until the next occurrence of a Quote character. Otherwise it will read in characters until another whitespace character occurs.

Parameters
[in]inFile to read from.
[in]whiteSpaceCharactersc-string (NULL Terminated) list of white space characters.
[out]eofWill be set to true if we are at the end of file when you make the call.
Returns
A String containing the next String in the file.

Definition at line 2598 of file OSservices.cpp.

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

2602 {
2603  if (feof (in))
2604  {
2605  eof = true;
2606  return KKStr::EmptyStr ();
2607  }
2608 
2609  // Skip leading white space and find first character in Token
2610  kkint32 ch = fgetc (in);
2611 
2612  while ((!feof (in)) && (strchr (whiteSpaceCharacters, ch) != NULL))
2613  {
2614  ch = fgetc (in);
2615  }
2616 
2617  if (feof (in))
2618  {
2619  eof = true;
2620  return KKStr::EmptyStr ();
2621  }
2622 
2623 
2624  KKStr result (10);
2625 
2626  bool lookForTerminatingQuote = false;
2627 
2628  if (ch == '"')
2629  {
2630  // We are going to read in a quoted string. In this case we include all characters until
2631  // we find the terminating quote
2632  lookForTerminatingQuote = true;
2633  ch = fgetc (in);
2634  }
2635 
2636  // Search for matching terminating Quote
2637 
2638  while (!feof (in))
2639  {
2640  if (lookForTerminatingQuote)
2641  {
2642  if (ch == '"')
2643  {
2644  break;
2645  }
2646  }
2647 
2648  else
2649  {
2650  if (strchr (whiteSpaceCharacters, ch))
2651  {
2652  // We found the next terminating white space character.
2653  break;
2654  }
2655  }
2656 
2657  if ((ch == '\\') && (lookForTerminatingQuote))
2658  {
2659  if (!feof (in))
2660  {
2661  ch = fgetc (in);
2662  switch (ch)
2663  {
2664  case '"': result.Append ('"'); break;
2665  case 't': result.Append ('\t'); break;
2666  case 'n': result.Append ('\n'); break;
2667  case 'r': result.Append ('\r'); break;
2668  case '\\': result.Append ('\\'); break;
2669  case '0': result.Append (char (0)); break;
2670  case 0: break;
2671  default: result.Append (ch); break;
2672  }
2673  }
2674  }
2675  else
2676  {
2677  result.Append (ch);
2678  }
2679 
2680  ch = fgetc (in);
2681  }
2682 
2683  // Eliminate all trailing white space
2684  if (!feof (in))
2685  {
2686  ch = fgetc (in);
2687  while ((!feof (in)) && (strchr (whiteSpaceCharacters, ch) != NULL))
2688  {
2689  ch = fgetc (in);
2690  }
2691 
2692  if (!feof (in))
2693  {
2694  ungetc (ch, in);
2695  }
2696  }
2697 
2698 
2699  return result;
2700 } /* osReadNextQuotedStr */
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr KKB::osReadNextToken ( FILE *  in,
const char *  delimiters,
bool &  eof,
bool &  eol 
)

Read the next logical token from a file using characters in 'delimiters' to separate tokens.

Use this function to read logical tokens from a file. It recognizes the concept of a line that is terminated by the line feed ('
') character. When end of line is reached it will return an empty string setting 'eol' to true; the very next call will return the first token on the next line. The leading whitespace characters ' ' and '\r' will be skipped before reading the next token. Tokens will be separated by any one of the characters specified in 'delimiters'. Two or more delimiters that occur consecutively will not be treated as one separator. You will need to call this method for each one.

ex: the string "Apple\tPeer\t\tGrape\t\n" with the delimiters = "\t" will generate the following tokens when "Apple", "Peer", "", "Grape", "", ""(eol = True)

Parameters
[in]inFile handle to read from.
[in]delimitersc string listing delimiter characters.
[out]eofEnd of file flag. When this goes true so will eol, also no token will be returned.
[out]eolWill be set to true when the end-of-line is reached ('\n'). No token will be returned. The next call to this method will start at the next line.
Returns
The next token read from the file. You must also monitor the 'eol' and 'eof' variables. If either one is true the no token will be returned.

Definition at line 2374 of file OSservices.cpp.

2379 {
2380  eof = false;
2381  eol = false;
2382 
2383  char token[1024];
2384  kkint32 maxTokenLen = sizeof (token) - 1;
2385 
2386  kkint32 ch = fgetc (in); eof = (feof (in) != 0);
2387 
2388  if (eof)
2389  {
2390  eol = true;
2391  return "";
2392  }
2393 
2394  // lets skip leading white space
2395  while ((!eof) && ((ch == ' ') || (ch == '\r')) && (ch != '\n'))
2396  {ch = fgetc (in); eof = (feof (in)!= 0);}
2397 
2398  if (ch == '\n')
2399  {
2400  eol = true;
2401  return "";
2402  }
2403 
2404  kkint32 tokenLen = 0;
2405 
2406  // Read till first delimiter or eof
2407  while ((!eof) && (!strchr (delimiters, ch)))
2408  {
2409  if (ch == '\n')
2410  {
2411  ungetc (ch, in);
2412  break;
2413  }
2414  else
2415  {
2416  token[tokenLen] = ch;
2417  tokenLen++;
2418 
2419  if (tokenLen >= maxTokenLen)
2420  break;
2421 
2422  ch = fgetc (in); eof = (feof (in)!= 0);
2423  }
2424  }
2425 
2426  token[tokenLen] = 0; // Terminating NULL character.
2427 
2428 
2429  // Remove Trailing whitespace
2430  while (tokenLen > 0)
2431  {
2432  if (strchr (" \r", token[tokenLen - 1]) == 0)
2433  break;
2434  tokenLen--;
2435  token[tokenLen] = 0;
2436  }
2437 
2438  return token;
2439 } /* ReadNextToken */
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr KKB::osReadNextToken ( FILE *  in,
const char *  delimiters,
bool &  eof 
)

Read the next logical token from a file using characters in 'delimiters' to separate tokens where '
'(end of line) is just another whitespace character.

Use this function to read logical tokens from a file. Leading whitespace characters ' ', '\n', and '\r' will be skipped before reading the next token. Tokens will be separated by any one of the characters specified in 'delimiters'. Two or more delimiters that occur consecutively will not be treated as one separator. You will need to call this method for each one. Note that whitespace characters are not treated as delimiters but characters that are to be ignored before and after the token.

ex: the string "Apple\tPeer\t\tGrape\t\n" with the delimiters = "\t" will generate the following tokens when "Apple", "Peer", "", "Grape", "", ""(eol = True)

Parameters
[in]inFile handle to read from.
[in]delimitersc string listing delimiter characters.
[out]eofEnd of file flag. When this goes true so will eol, also no token will be returned.
Returns
The next token read from the file. You must also monitor the 'eol' and 'eof' variables. If either one is true the no token will be returned.

Definition at line 2444 of file OSservices.cpp.

Referenced by ReadImagePPM().

2448 {
2449  eof = false;
2450  char token[1024];
2451  kkint32 maxTokenLen = sizeof (token) - 1;
2452 
2453  kkint32 ch = fgetc (in); eof = (feof (in) != 0);
2454 
2455  if (eof)
2456  return "";
2457 
2458  // lets skip leading white space
2459  while ((!eof) && ((ch == ' ') || (ch == '\r')) && (ch != '\n'))
2460  {ch = fgetc (in); eof = (feof (in)!= 0);}
2461 
2462  kkint32 tokenLen = 0;
2463 
2464  // Read till first delimiter or eof
2465  while ((!eof) && (!strchr (delimiters, ch)))
2466  {
2467  token[tokenLen] = ch;
2468  tokenLen++;
2469 
2470  if (tokenLen >= maxTokenLen)
2471  break;
2472 
2473  ch = fgetc (in); eof = (feof (in)!= 0);
2474  }
2475 
2476  token[tokenLen] = 0; // Terminating NULL character.
2477 
2478 
2479  // Remove Trailing whitespace
2480  while (tokenLen > 0)
2481  {
2482  if (strchr (" \n\r", token[tokenLen - 1]) == 0)
2483  break;
2484  tokenLen--;
2485  token[tokenLen] = 0;
2486  }
2487 
2488  return token;
2489 } /* ReadNextToken */
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr KKB::osReadNextToken ( std::istream &  in,
const char *  delimiters,
bool &  eof,
bool &  eol 
)

Read the next logical token from a file using characters in 'delimiters' to separate tokens.

Use this function to read logical tokens from a input stream. It recognizes the concept of a line that is terminated by the line feed ('
') character. When end of line is reached it will return an empty string setting 'eol' to true; the very next call will return the first token on the next line. The leading whitespace characters ' ' and ']r' will be skipped before reading the next token. Tokens will be separated by any one of the characters specified in 'delimiters'. Two or more delimiters that occur consecutively will not be treated as one separator. You will need to call this method for each one.

ex: the string "Apple\tPeer\t\tGrape\t\n" with the delimiters = "\t" will generate the following tokens when "Apple", "Peer", "", "Grape", "", ""(eol = True)

Parameters
[in]inInput Stream to read from.
[in]delimitersc string listing delimiter characters.
[out]eofEnd of file flag. When this goes true so will eol, also no token will be returned.
[out]eolWill be set to true when the end-of-line is reached ('
'). No token will be returned. The next call to this method will start at the next line.
Returns
The next token read from the file. You must also monitor the 'eol' and 'eof' variables. If either one is true the no token will be returned.

Definition at line 2301 of file OSservices.cpp.

2306 {
2307  eof = false;
2308  eol = false;
2309 
2310  char token[1024];
2311  kkint32 maxTokenLen = sizeof (token) - 1;
2312 
2313  //kkint32 ch = fgetc (in); eof = (feof (in) != 0);
2314  kkint32 ch = in.get ();
2315  eof = in.eof ();
2316  if (eof)
2317  {
2318  eol = true;
2319  return "";
2320  }
2321 
2322  // lets skip leading white space
2323  while ((!eof) && ((ch == ' ') || (ch == '\r')) && (ch != '\n'))
2324  {
2325  ch = in.get ();
2326  eof = in.eof ();
2327  }
2328 
2329  if (ch == '\n')
2330  {
2331  eol = true;
2332  return "";
2333  }
2334 
2335  kkint32 tokenLen = 0;
2336 
2337  // Read till first delimiter or eof
2338  while ((!eof) && (!strchr (delimiters, ch)))
2339  {
2340  if (ch == '\n')
2341  {
2342  in.putback (ch);
2343  break;
2344  }
2345  else
2346  {
2347  token[tokenLen] = ch;
2348  tokenLen++;
2349 
2350  if (tokenLen >= maxTokenLen)
2351  break;
2352 
2353  ch = in.get ();
2354  eof = in.eof ();
2355  }
2356  }
2357 
2358  token[tokenLen] = 0; // Terminating NULL character.
2359 
2360  // Remove Trailing whitespace
2361  while (tokenLen > 0)
2362  {
2363  if (strchr (" \r", token[tokenLen - 1]) == 0)
2364  break;
2365  tokenLen--;
2366  token[tokenLen] = 0;
2367  }
2368 
2369  return token;
2370 } /* osReadNextToken */
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStrPtr KKB::osReadRestOfLine ( std::istream &  in,
bool &  eof 
)

Extracts text up to and including the next end-of-line character and returns pointer to dynamical allocated str that caller will own.

The new-line character that terminated the nor any carriage-return will not be included. If stream [[in]] is already at end-of-file then will return NULL as well as eof being set to true.

Parameters
inStream to read text from.
eofSet to true if end-of-file is reached while reading file.

Definition at line 2511 of file OSservices.cpp.

References KKB::KKStr::Append(), KKB::KKStr::Concat(), KKB::KKStr::KKStr(), KKB::KKStr::Len(), KKB::KKStr::MaxLenSupported(), and KKB::KKStr::Trim().

Referenced by osReadRestOfLine2().

2514 {
2515  eof = false;
2516 
2517  kkint32 ch = in.get ();
2518  eof = in.eof ();
2519 
2520  if (eof)
2521  return NULL;
2522 
2523  KKStrPtr result = new KKStr (1024);
2524 
2525  // Read till first delimiter or eof
2526  while (!eof)
2527  {
2528  if (ch == '\n')
2529  {
2530  break;
2531  }
2532  else
2533  {
2534  result->Append (ch);
2535  if (result->Len () >= (result->MaxLenSupported ()))
2536  break;
2537  ch = in.get (); eof = in.eof ();
2538  }
2539  }
2540 
2541  result->Trim (" \n\r");
2542 
2543  return result;
2544 } /* osReadRestOfLine */
KKStr & Trim(const char *whiteSpaceChars="\n\r\t ")
Definition: KKStr.cpp:1686
__int32 kkint32
Definition: KKBaseTypes.h:88
kkuint32 MaxLenSupported() const
Definition: KKStr.cpp:2510
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
void Append(const char *buff)
Definition: KKStr.cpp:1783
KKStrPtr KKB::osReadRestOfLine ( FILE *  in,
bool &  eof 
)

Definition at line 2549 of file OSservices.cpp.

References KKB::KKStr::Append(), KKB::KKStr::Concat(), KKB::KKStr::KKStr(), KKB::KKStr::Len(), KKB::KKStr::MaxLenSupported(), and KKB::KKStr::TrimRight().

Referenced by KKMLL::MLClassList::Load(), KKLSC::ScannerFile::LoadIndexFile(), and osReadRestOfLine2().

2552 {
2553  eof = false;
2554 
2555  kkint32 ch = fgetc (in);
2556  eof = (feof (in) != 0);
2557  if (eof)
2558  return NULL;
2559 
2560  KKStrPtr result = new KKStr(1024);
2561  // Read till first delimiter or eof
2562  while (!eof)
2563  {
2564  if (ch == '\n')
2565  {
2566  break;
2567  }
2568  else
2569  {
2570  result->Append (ch);
2571  if (result->Len () >= result->MaxLenSupported ())
2572  break;
2573  ch = fgetc (in); eof = (feof (in) != 0);
2574  }
2575  }
2576 
2577  result->TrimRight (" \r\n");
2578 
2579  return result;
2580 } /* osReadRestOfLine */
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr & TrimRight(const char *whiteSpaceChars="\n\r\t ")
Definition: KKStr.cpp:1695
kkuint32 MaxLenSupported() const
Definition: KKStr.cpp:2510
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
void Append(const char *buff)
Definition: KKStr.cpp:1783
KKB::KKStr KKB::osReadRestOfLine2 ( std::istream &  in,
bool &  eof 
)

Definition at line 2493 of file OSservices.cpp.

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

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

2496 {
2497  KKStrPtr l = osReadRestOfLine (in, eof);
2498  if (l) {
2499  KKStr result(*l);
2500  delete l;
2501  l = NULL;
2502  return result;
2503  }
2504  else {
2505  return "";
2506  }
2507 }
KKB::KKStrPtr osReadRestOfLine(std::istream &in, bool &eof)
Extracts text up to and including the next end-of-line character and returns pointer to dynamical all...
KKB::KKStr KKB::osReadRestOfLine2 ( FILE *  in,
bool &  eof 
)

Definition at line 2584 of file OSservices.cpp.

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

Referenced by ReadImagePGM().

2587 {
2588  KKStrPtr l = osReadRestOfLine (in, eof);
2589  KKStr result(*l);
2590  delete l;
2591  l = NULL;
2592  return result;
2593 }
KKB::KKStrPtr osReadRestOfLine(std::istream &in, bool &eof)
Extracts text up to and including the next end-of-line character and returns pointer to dynamical all...
KKStr KKB::osRemoveExtension ( const KKStr _fullFileName)

Definition at line 1136 of file OSservices.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::KKStr(), KKB::KKStr::LocateLastOccurrence(), osLocateLastSlashChar(), and KKB::KKStr::SubStrPart().

Referenced by KKMLL::ClassificationBiasMatrix::ClassificationBiasMatrix(), KKMLL::Orderings::CreateOrderingsObjFromFileIfAvaliable(), KKMLL::TrainingConfiguration2::GetEffectiveConfigFileName(), KKMLL::TrainingProcess2::LoadExistingTrainingProcess(), KKLSC::ScannerFile::LoadIndexFile(), KKLSC::ScannerFile::Open(), KKMLL::Orderings::Orderings(), KKLSC::ScannerFile::SaveIndexFile(), and KKMLL::TrainingProcess2::SaveTrainingProcess().

1137 {
1138  kkint32 lastSlashChar = osLocateLastSlashChar (_fullFileName);
1139 
1140  kkint32 lastPeriodChar = _fullFileName.LocateLastOccurrence ('.');
1141 
1142  if (lastPeriodChar < lastSlashChar)
1143  return KKStr (_fullFileName);
1144 
1145  if (lastPeriodChar <= 1)
1146  return KKStr (_fullFileName);
1147 
1148  return _fullFileName.SubStrPart (0, lastPeriodChar - 1);
1149 } /* osRemoveExtension */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 osLocateLastSlashChar(const KKStr &fileSpec)
kkint32 LocateLastOccurrence(char ch) const
Returns index of last occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2118
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 KKB::osRenameFile ( const KKStr oldName,
const KKStr newName 
)

Definition at line 743 of file OSservices.cpp.

746 {
747  bool returnCd = (MoveFile (oldName.Str (), newName.Str ()) != 0);
748 
749  if (!returnCd)
750  {
751  DWORD lastError = GetLastError ();
752 
753  cerr << std::endl
754  << "osRenameFile *** ERROR ***, Rename Failed" << std::endl
755  << std::endl
756  << " oldName[" << oldName << "] NewName[" << newName << "]" << std::endl
757  << " LastError[" << lastError << "]" << std::endl
758  << std::endl;
759 
760  }
761 
762  return returnCd;
763 
764 } /* osRenameFile */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
void KKB::osRunAsABackGroundProcess ( )

Definition at line 1499 of file OSservices.cpp.

References backGroundProcess.

1500 {
1501  backGroundProcess = true;
1502 }
bool backGroundProcess
void KKB::osSkipRestOfLine ( FILE *  in,
bool &  eof 
)

Skips rest of the characters in the current line in the file.

Will skip all characters in 'in' until a '
' is read or the end of file has been reached. It is meant be be used in conjunction with 'osReadNextToken'.

Parameters
[in]inFile being read.
[out]eofWill be set to true if end of file is encountered.

Definition at line 2705 of file OSservices.cpp.

2708 {
2709  eof = false;
2710  kkint32 ch = fgetc (in); eof = (feof (in) != 0);
2711  while ((ch != '\n') && (!eof))
2712  {
2713  ch = fgetc (in); eof = (feof (in) != 0);
2714  }
2715 } /* osSkipRestOfLine */
__int32 kkint32
Definition: KKBaseTypes.h:88
void KKB::osSkipRestOfLine ( std::istream &  in,
bool &  eof 
)

Skips rest of the characters in the current line in the input stream.

Will skip all characters in 'in' until a '
' is read or the end of file has been reached. It is meant be be used in conjunction with 'osReadNextToken'.

Parameters
[in]inFile being read.
[out]eofWill be set to true if end of file is encountered.

Definition at line 2720 of file OSservices.cpp.

2723 {
2724  kkint32 ch = in.get ();
2725  eof = in.eof ();
2726 
2727  while ((ch != '\n') && (!eof))
2728  {
2729  ch = in.get ();
2730  eof = in.eof ();
2731  }
2732 } /* osSkipRestOfLine */
__int32 kkint32
Definition: KKBaseTypes.h:88
void KKB::osSleep ( float  numOfSecs)

Definition at line 2764 of file OSservices.cpp.

Referenced by KKJobManagment::KKJobManager::Block(), KKB::KKThreadManager::ManageThreads(), and KKB::KKThreadManager::ShutdownProcessing().

2765 {
2766  #ifdef WIN32
2767  kkint32 miliSecsToSleep = (kkint32)(1000.0f * secsToSleep + 0.5f);
2768  Sleep (miliSecsToSleep);
2769  #else
2770  kkint32 secsToSleepInt = (kkint32)(0.5f + secsToSleep);
2771 
2772  if (secsToSleepInt < 1)
2773  secsToSleepInt = 1;
2774 
2775  else if (secsToSleepInt > 3600)
2776  cout << "osSleep secsToSleep[" << secsToSleepInt << "]" << std::endl;
2777 
2778  sleep (secsToSleepInt);
2779  #endif
2780 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
void KKB::osSleepMiliSecs ( kkuint32  numMiliSecs)

Definition at line 2785 of file OSservices.cpp.

Referenced by KKLSC::ScannerFile::AddStartStopEntryToIndexFile(), KKLSC::ScannerFile::BuildFrameOffsets(), KKB::GoalKeeper::StartBlock(), and KKB::KKThread::WaitForThreadToStop().

2786 {
2787  #ifdef WIN32
2788  Sleep (numMiliSecs);
2789  #else
2790  int numSecsToSleep = (numMiliSecs / 1000);
2791  sleep (numSecsToSleep);
2792  #endif
2793 }
VectorKKStr KKB::osSplitDirectoryPathIntoParts ( const KKStr path)

Definition at line 2797 of file OSservices.cpp.

References KKB::KKStr::Len(), and KKB::KKStr::operator[]().

2798 {
2799  VectorKKStr parts;
2800 
2801  if (path.Len () == 0)
2802  return parts;
2803 
2804  kkuint32 zed = 0;
2805 
2806  if (path[(kkuint16)1] == ':')
2807  {
2808  parts.push_back (path.SubStrPart (0, 1));
2809  zed += 2;
2810  }
2811 
2812  while (zed < path.Len ())
2813  {
2814  if (path[zed] == '\\')
2815  {
2816  parts.push_back ("\\");
2817  zed++;
2818  }
2819  else if (path[zed] == '/')
2820  {
2821  parts.push_back ("/");
2822  zed++;
2823  }
2824  else
2825  {
2826  // Scan until we come up to another separator or end of string
2827  kkint32 startPos = zed;
2828  while (zed < path.Len ())
2829  {
2830  if ((path[zed] == '\\') || (path[zed] == '/'))
2831  break;
2832  zed++;
2833  }
2834 
2835  parts.push_back (path.SubStrPart (startPos, zed - 1));
2836  }
2837  }
2838 
2839  return parts;
2840 } /* osSplitDirectoryPathIntoParts */
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
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::osSubstituteInEnvironmentVariables ( const KKStr src)

Substitute in the value of the environment variables into 'src'.

Will scan the 'src' string for references to environment variables. The format would be $(env-var-name). These sub-strings in 'src' will be replaced by the the actual value of the environment variable. If no such environment variable exists the substring will be left as is besides parentheses '{}' or '[]' can be used, ex the string "${KinseyHomeDir}\\Reports" would be replaced by "c:\Kinsey\reports"

Parameters
[in]srcString that you want to scan for environment variables.
Returns
'src' string with environment variables expanded.

Definition at line 977 of file OSservices.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::KKStr(), KKB::KKStr::Len(), KKB::KKStr::LocateCharacter(), KKB::KKStr::operator+(), operator+(), KKB::KKStr::operator=(), KKB::KKStr::operator[](), osGetEnvVariable(), osLocateEnvStrStart(), and KKB::KKStr::SubStrPart().

Referenced by KKMLL::TrainingClass::ExpandedDirectory(), KKMLL::TrainingConfiguration2::LoadOtherClasssExamples(), KKMLL::TrainingConfiguration2::RootDir(), and KKMLL::TrainingClassList::WriteXML().

978 {
979  kkint16 x = osLocateEnvStrStart (src, 0);
980  if (x < 0) return src;
981 
982  KKStr str (src);
983 
984  while (x >= 0)
985  {
986  char startChar = src[(kkint16)(x + 1)];
987  char endChar = ')';
988 
989  if (startChar == '(') endChar = ')';
990  else if (startChar == '{') endChar = '}';
991  else if (startChar == '[') endChar = ']';
992 
993  KKStr beforeEnvStr = str.SubStrPart (0, x - 1);
994  str = str.SubStrPart (x + 2);
995  x = str.LocateCharacter (endChar);
996  if (x < 0) return src;
997 
998  KKStr envStrName = str.SubStrPart (0, x - 1);
999  KKStr afterStrName = str.SubStrPart (x + 1);
1000 
1001  KKStrPtr envStrValue = osGetEnvVariable (envStrName);
1002  if (envStrValue == NULL)
1003  envStrValue = new KKStr ("${" + envStrName + "}");
1004 
1005  kkuint32 idxToStartAtNextTime = beforeEnvStr.Len () + envStrValue->Len ();
1006  str = beforeEnvStr + (*envStrValue) + afterStrName;
1007  delete envStrValue;
1008  x = osLocateEnvStrStart (str, idxToStartAtNextTime);
1009  }
1010 
1011  return str;
1012 } /* osSubstituteInEnvironmentVariables */
__int16 kkint16
16 bit signed integer.
Definition: KKBaseTypes.h:85
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
kkint32 LocateCharacter(char ch) const
Returns index of 1st occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2021
KKStrPtr osGetEnvVariable(const KKStr &_varName)
Definition: OSservices.cpp:897
int osLocateEnvStrStart(const KKStr &str, kkint32 startIdx)
Definition: OSservices.cpp:948
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 KKB::osValidDirectory ( KKStrConstPtr  _name)

Definition at line 382 of file OSservices.cpp.

Referenced by osGetListOfDirectories().

383 {
384  DWORD returnCd = GetFileAttributes (name->Str ());
385 
386  if (returnCd == 0xFFFFFFFF)
387  {
388  return false;
389  }
390 
391  if ((FILE_ATTRIBUTE_DIRECTORY & returnCd) != FILE_ATTRIBUTE_DIRECTORY)
392  return false;
393  else
394  return true;
395 }
bool KKB::osValidDirectory ( const KKStr _name)

Definition at line 398 of file OSservices.cpp.

Referenced by osCreateDirectoryPath().

399 {
400  #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
401  DWORD returnCd = GetFileAttributes (name.Str ());
402 
403  if (returnCd == INVALID_FILE_ATTRIBUTES)
404  return false;
405 
406 
407  if ((FILE_ATTRIBUTE_DIRECTORY & returnCd) != FILE_ATTRIBUTE_DIRECTORY)
408  return false;
409  else
410  return true;
411 }
#define INVALID_FILE_ATTRIBUTES
bool KKB::osValidFileName ( const KKStr _name)

Definition at line 443 of file OSservices.cpp.

References osValidFileNameErrors().

444 {
445  KKStrListPtr errors = osValidFileNameErrors (_name);
446  if (errors == NULL)
447  return true;
448  else
449  {
450  delete errors;
451  errors = NULL;
452  return false;
453  }
454 }
KKStrListPtr osValidFileNameErrors(const KKStr &_name)
Returns list of errors in &#39;_name&#39; with respect to it being a valid file name for the O/S...
Definition: OSservices.cpp:458
KKStrListPtr KKB::osValidFileNameErrors ( const KKStr _name)

Returns list of errors in '_name' with respect to it being a valid file name for the O/S.

Definition at line 458 of file OSservices.cpp.

References KKB::KKStr::Empty(), KKB::KKStrList::KKStrList(), KKB::KKStr::Len(), and KKB::KKStr::operator[]().

Referenced by osValidFileName().

459 {
460  const char* invalidChars = "\\\" :<>!?*";
461  const char* invalidNames[] = {"CON", "PRN", "AUX", "NUL", "COM1", "COM2",
462  "COM3", "COM4", "COM5", "COM6", "COM7", "COM8",
463  "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5",
464  "LPT6", "LPT7", "LPT8", "LPT9",
465  NULL
466  };
467 
468  KKStrListPtr errors = new KKStrList (true);
469  if (_name.Empty ())
470  {
471  errors->PushOnBack (new KKStr ("Blank names are invalid!"));
472  }
473 
474  else
475  {
476  // Check for invalid names.
477  kkuint32 x = 0;
478  while (invalidNames[x] != NULL)
479  {
480  if (_name.EqualIgnoreCase (invalidNames[x]))
481  errors->PushOnBack (new KKStr ("Can not use \"" + _name + "\""));
482  ++x;
483  }
484 
485  // Check for invalid characters
486  for (x = 0; x < _name.Len (); ++x)
487  {
488  char c = _name[x];
489  if (c == 0)
490  errors->PushOnBack (new KKStr ("Null character at position: " + StrFormatInt (x, "##0")));
491 
492  else if (c == ' ')
493  errors->PushOnBack (new KKStr ("No spaces allowed."));
494 
495  else if (c < 32)
496  {
497  errors->PushOnBack (new KKStr ("Character at position: " + StrFormatInt (x, "##0") + " has ordinal value of: " + StrFormatInt (c, "##0")));
498  }
499 
500  else if (strchr (invalidChars, c) != NULL)
501  {
502  KKStr invalidStr (2);
503  invalidStr.Append (c);
504  errors->PushOnBack (new KKStr ("Invalid character: " + invalidStr + " at position: " + StrFormatInt (x, "##0")));
505  }
506  }
507  }
508 
509  if (errors->QueueSize () < 1)
510  {
511  delete errors;
512  errors = NULL;
513  }
514 
515  return errors;
516 } /* osValidFileNameErrors */
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
bool Empty() const
Definition: KKStr.h:241
virtual void PushOnBack(EntryPtr _entry)
Definition: KKQueue.h:398
KKStr StrFormatInt(kkint32 val, const char *mask)
Definition: KKStr.cpp:5004
kkint32 QueueSize() const
Definition: KKQueue.h:313
void KKB::osWaitForEnter ( )

Definition at line 1513 of file OSservices.cpp.

References backGroundProcess.

Referenced by KKB::Matrix::CalcCoFactorMatrix(), KKMLL::FeatureEncoder2::CreateEncodedFileDesc(), KKB::Raster::FourierExtractFeatures(), KKB::Raster::HistogramEqualizedImage(), KKMLL::NormalizationParms::NormalizeExamples(), KKB::Row::operator[](), KKMLL::Orderings::Save(), KKJobManagment::KKJobManager::StatusFileProcessLineJobStatusChange(), and KKMLL::SvmPredictRaw().

1514 {
1515  if (backGroundProcess)
1516  return;
1517 
1518  cout << std::endl
1519  << std::endl
1520  << "Press Enter To Continue"
1521  << std::endl;
1522 
1523  while (getchar () != '\n');
1524 
1525 } /* osWaitForEnter */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
bool backGroundProcess
float KKB::PairedTTest ( const KKB::VectorFloat set1,
const KKB::VectorFloat set2 
)

Definition at line 24 of file StatisticalFunctions.cpp.

27 {
28  // Formula was taken from MathWorld
29  // http://mathworld.wolfram.com/Pairedt-Test.html
30 
31  //ofstream out ("T-Test_Stats.txt", ios_base::app);
32  double numOfPairs = (double)set1.size ();
33 
34  if (numOfPairs != set2.size ())
35  {
36  cerr << std::endl
37  << std::endl
38  << "PairedTTest *** ERROR *** The two sets are not the same length." << std::endl
39  << std::endl
40  << " set1.size [" << set1.size () << "] set2.size [" << set2.size () << "]" << std::endl
41  << std::endl;
42  osWaitForEnter ();
43  exit (-1);
44  }
45 
46 
47  double xTotal = 0.0f;
48  double yTotal = 0.0f;
49 
50  kkint32 foldNum = 0;
51 
52 
53  //out << "X";
54  //for (foldNum = 0; foldNum < numOfPairs; foldNum++)
55  // out << "\t" << set1[foldNum];
56  //out << endl;
57 
58  //out << "Y";
59  //for (foldNum = 0; foldNum < numOfPairs; foldNum++)
60  // out << "\t" << set2[foldNum];
61  //out << endl;
62 
63 
64  for (foldNum = 0; foldNum < numOfPairs; foldNum++)
65  {
66  xTotal += set1[foldNum];
67  yTotal += set2[foldNum];
68  }
69 
70  double xMean = xTotal / numOfPairs;
71  double yMean = yTotal / numOfPairs;
72 
73  //out << endl
74  // << "X_Mean = " << xMean << endl
75  // << "Y_Mean = " << yMean << endl;
76 
77  double totalDeltaSquared = 0.0f;
78 
79  for (foldNum = 0; foldNum < numOfPairs; foldNum++)
80  {
81  double xDelta = set1[foldNum] - xMean;
82  double yDelta = set2[foldNum] - yMean;
83 
84  double deltaDelta = xDelta - yDelta;
85  totalDeltaSquared += (deltaDelta * deltaDelta);
86  }
87 
88  //out << endl
89  // << "totalDeltaSquared = "
90  // << totalDeltaSquared << endl;
91 
92 
93  double tValue = 0.0f;
94  if (totalDeltaSquared != 0.0)
95  tValue = fabs ((xMean - yMean) * sqrt ((numOfPairs * (numOfPairs - 1.0)) / totalDeltaSquared));
96 
97  //out << endl
98  // << "tValue = " << tValue << endl
99  // << endl;
100 
101  //out.close ();
102 
103  return float (tValue);
104 } /* PairedTTest */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
void osWaitForEnter()
RasterPtr KKB::ReadImage ( const KKStr imageFileName)

Definition at line 188 of file ImageIO.cpp.

References KKB::BmpImage::BmpImage(), KKB::Raster::Color(), KKB::KKStr::Concat(), KKB::KKStr::operator==(), osGetFileExtension(), KKB::Raster::Raster(), ReadImagePGM(), ReadImagePPM(), ReadImageUsingGDI(), KKB::Raster::ReverseImage(), and KKB::KKStr::ToLower().

Referenced by KKMLL::FeatureVectorProducer::ComputeFeatureVectorFromImage(), KKMLL::FeatureFileIO::FeatureDataReSink(), and KKB::Raster::Raster().

189 {
190  bool successful = false;
191  RasterPtr image = NULL;
192 
193  KKStr extension = osGetFileExtension (imageFileName).ToLower ();
194  if (extension == "pgm")
195  {
196  image = ReadImagePGM (imageFileName);
197  }
198 
199  else if (extension == "bmp")
200  {
201  BmpImage bmpImage (imageFileName, successful);
202  if (!successful)
203  return NULL;
204  image = new Raster (bmpImage);
205  }
206 
207  else if (extension == "ppm")
208  {
209  image = ReadImagePPM (imageFileName);
210  }
211 
212 #if defined(OS_WINDOWS)
213  else if ((extension == "jpg") || (extension == "tif") || (extension == "tiff"))
214  {
215  image = ReadImageUsingGDI (imageFileName);
216  if (image)
217  {
218  if (!image->Color ())
219  image->ReverseImage ();
220  }
221  }
222 #endif
223 
224  return image;
225 } /* ReadImage */
RasterPtr ReadImagePPM(const KKStr &imageFileName)
Definition: ImageIO.cpp:515
RasterPtr ReadImagePGM(const KKStr &imageFileName)
Definition: ImageIO.cpp:371
RasterPtr ReadImageUsingGDI(const KKStr &imageFileName)
Definition: ImageIO.cpp:237
A class that is used by to represent a single image in memory.
Definition: Raster.h:108
bool Color() const
Definition: Raster.h:310
KKStr osGetFileExtension(KKStr fullFileName)
Used to encode and decode BMP Images.
Definition: BMPImage.h:49
void ReverseImage()
Definition: Raster.cpp:1198
KKStr ToLower() const
Definition: KKStr.cpp:2529
RasterPtr KKB::ReadImagePGM ( const KKStr imageFileName)

Definition at line 371 of file ImageIO.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::ExtractTokenInt(), KKB::KKStr::operator=(), KKB::KKStr::operator[](), osFOPEN(), osReadRestOfLine2(), KKB::Raster::Raster(), KKB::Raster::SetPixelValue(), KKB::KKStr::Str(), and KKB::KKStr::ToInt().

Referenced by ReadImage().

372 {
373  FILE* i = osFOPEN (imageFileName.Str (), "rb");
374  if (!i)
375  return NULL;
376 
377  kkint32 height = -1;
378  kkint32 pixelSize = -1;
379  kkint32 width = -1;
380 
381  {
382  // We are going to read in header part of file.
383  KKStr nextLine = "";
384  bool eof = false;
385  nextLine = osReadRestOfLine2 (i, eof);
386  if (eof || (nextLine[(kkint16)0] != 'P') || (nextLine[(kkint16)1] != '5'))
387  {
388  fclose (i);
389  return NULL;
390  }
391 
392  kkint32 headerFieldsRead = 0;
393  nextLine = osReadRestOfLine2 (i, eof);
394  while (!eof)
395  {
396  if (nextLine[(kkint16)0] != '#')
397  {
398  if (headerFieldsRead == 0)
399  {
400  width = nextLine.ExtractTokenInt (" \t\n\r");
401  height = nextLine.ExtractTokenInt (" \t\n\r");
402  }
403  if (headerFieldsRead == 1)
404  {
405  pixelSize = nextLine.ToInt ();
406  break;
407  }
408  headerFieldsRead++;
409  }
410  nextLine = osReadRestOfLine2 (i, eof);
411  }
412  }
413 
414  if ((pixelSize < 0) || (pixelSize > 255) ||
415  (width < 1) || (height < 1)
416  )
417  {
418  fclose (i);
419  cerr << endl << endl
420  << "ReadImagePGM ***ERROR*** ImageFile[" << imageFileName << "] Invalid Header"
421  << " width[" << width << "] height[" << height << "] pixelSize[" << pixelSize << "]"
422  << endl
423  << endl;
424  return NULL;
425  }
426 
427  RasterPtr image = new Raster (height, width, false);
428 
429  kkint32 row, col;
430 
431  uchar* colBuff = new uchar[width + 10];
432 
433  for (row = 0; row < height; row++)
434  {
435  fread (colBuff, 1, width, i);
436 
437  for (col = 0; col < width; col++)
438  {
439  image->SetPixelValue (row, col, colBuff[col]);
440  }
441  }
442 
443  fclose (i);
444 
445  return image;
446 } /* ReadImagePGM */
__int16 kkint16
16 bit signed integer.
Definition: KKBaseTypes.h:85
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
A class that is used by to represent a single image in memory.
Definition: Raster.h:108
kkint32 ToInt() const
Definition: KKStr.cpp:3565
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
KKB::KKStr osReadRestOfLine2(std::istream &in, bool &eof)
void SetPixelValue(const Point &point, const PixelValue &pixVal)
Definition: Raster.cpp:1440
kkint32 ExtractTokenInt(const char *delStr)
Definition: KKStr.cpp:3129
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
FILE * osFOPEN(const char *fileName, const char *mode)
Definition: OSservices.cpp:74
RasterPtr KKB::ReadImagePPM ( const KKStr imageFileName)

Definition at line 515 of file ImageIO.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::operator=(), osFOPEN(), osReadNextToken(), KKB::Raster::Raster(), ReadImagePpmField(), KKB::Raster::RedArea(), KKB::KKStr::Str(), and KKB::KKStr::ToInt32().

Referenced by ReadImage().

516 {
517  FILE* i = osFOPEN (imageFileName.Str (), "rb");
518  if (!i)
519  return NULL;
520 
521  kkint32 height = -1;
522  kkint32 pixelDepth = -1;
523  kkint32 width = -1;
524 
525  bool eof = false;
526 
527  char buff[10];
528  kkint32 bytesRead = (kkint32)fread (buff, 1, 2, i);
529  if (bytesRead < 2)
530  {
531  fclose (i);
532  return NULL;
533  }
534 
535  bool p3Format = ((buff[0] == 'P') && (buff[1] == '3'));
536  bool p6Format = ((buff[0] == 'P') && (buff[1] == '6'));
537 
538  if (!p3Format && !p6Format)
539  {
540  fclose (i);
541  return NULL;
542  }
543 
544  kkint32 fieldNum = 0;
545  KKStr field = ReadImagePpmField (i, eof);
546  while ((fieldNum < 3) && (!eof))
547  {
548  switch (fieldNum)
549  {
550  case 0: width = field.ToInt32 (); break;
551  case 1: height = field.ToInt32 (); break;
552  case 2: pixelDepth = field.ToInt32 (); break;
553  }
554  ++fieldNum;
555  field = ReadImagePpmField (i, eof);
556  }
557 
558  if ((width < 1) || (height < 1) || (pixelDepth < 1) || (pixelDepth > 65535))
559  {
560  cerr << endl << "ReadImagePPM ***ERROR*** Invalid Header Fields: "
561  << "FileName[" << imageFileName << "] "
562  << "Width[" << width << "] Height[" << height << "] PixelDepth[" << pixelDepth << "]"
563  << endl
564  << endl;
565  fclose (i);
566  return NULL;
567  }
568 
569  RasterPtr image = new Raster (height, width, true);
570  int totalPixels = height * width;
571 
572  kkint32 pixelsRead = 0;
573 
574  uchar* red = image->RedArea ();
575  uchar* green = image->RedArea ();
576  uchar* blue = image->RedArea ();
577  if (p3Format)
578  {
579  while ((pixelsRead < totalPixels) && (!eof))
580  {
581  KKStr redField = osReadNextToken (i, "\n\r\t ", eof);
582  KKStr greenField = osReadNextToken (i, "\n\r\t ", eof);
583  KKStr blueField = osReadNextToken (i, "\n\r\t ", eof);
584 
585  kkint32 redValue = Min (redField.ToInt32 (), pixelDepth);
586  kkint32 greenValue = Min (greenField.ToInt32 (), pixelDepth);
587  kkint32 blueValue = Min (blueField.ToInt32 (), pixelDepth);
588 
589  *red = ((255 * redValue) / pixelDepth); ++red;
590  *green = ((255 * greenValue) / pixelDepth); ++green;
591  *blue = ((255 * blueValue) / pixelDepth); ++blue;
592 
593  ++pixelsRead;
594  }
595  }
596  else
597  {
598  char rgbBuff[3];
599  while ((pixelsRead < totalPixels) && (!eof))
600  {
601  fread (rgbBuff, 1, 3, i); eof = (feof (i) != 0);
602  *red = rgbBuff[0]; ++red;
603  *green = rgbBuff[1]; ++green;
604  *blue = rgbBuff[2]; ++blue;
605  ++pixelsRead;
606  }
607  }
608 
609  fclose (i);
610 
611  return image;
612 } /* ReadImagePPM */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
KKB::KKStr osReadNextToken(FILE *in, const char *delimiters, bool &eof, bool &eol)
Read the next logical token from a file using characters in &#39;delimiters&#39; to separate tokens...
KKStr ReadImagePpmField(FILE *in, bool &eof)
Definition: ImageIO.cpp:451
__int32 kkint32
Definition: KKBaseTypes.h:88
A class that is used by to represent a single image in memory.
Definition: Raster.h:108
kkint32 ToInt32() const
Definition: KKStr.cpp:3587
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
uchar * RedArea() const
Definition: Raster.h:329
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
FILE * osFOPEN(const char *fileName, const char *mode)
Definition: OSservices.cpp:74
kkint32 Min(kkint32 x1, kkint32 x2)
Definition: Raster.cpp:229
KKStr KKB::ReadImagePpmField ( FILE *  in,
bool &  eof 
)

Definition at line 451 of file ImageIO.cpp.

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

Referenced by ReadImagePPM().

454 {
455  eof = false;
456  char token[2048];
457  kkint32 maxTokenLen = sizeof (token) - 1;
458 
459  kkint32 ch = 0;
460 
461  bool startOfTokenFound = false;
462  while (!startOfTokenFound)
463  {
464  // Skip leading white space
465  ch = fgetc (in); eof = (feof (in) != 0);
466  while ((!eof) && (strchr (" #\t\n\r", ch) != NULL) && (ch != '\n') && (ch != '#'))
467  {ch = fgetc (in); eof = (feof (in)!= 0);}
468 
469  if (eof)
470  return KKStr::EmptyStr ();
471 
472  else if (ch == '#')
473  {
474  // Skip the rest of the line.
475  while ((!eof) && (ch != '\n'))
476  {ch = fgetc (in); eof = (feof (in)!= 0);}
477  }
478 
479  else
480  {
481  startOfTokenFound = true;
482  }
483  }
484 
485  kkint32 tokenLen = 0;
486 
487  // Read till first delimiter or eof or eol
488  while ((!eof) && (strchr (" #\t\n\r", ch) == 0))
489  {
490  token[tokenLen] = ch;
491  tokenLen++;
492  if (tokenLen >= maxTokenLen)
493  break;
494  ch = fgetc (in); eof = (feof (in)!= 0);
495  }
496  token[tokenLen] = 0; // Terminating NULL character.
497  if ((!eof) && (ch == '#'))
498  {
499  // Skip the rest of the line.
500  while ((!eof) && (ch != '\n'))
501  {ch = fgetc (in); eof = (feof (in)!= 0);}
502  }
503 
504  if (eof & (tokenLen > 0))
505  {
506  eof = false;
507  ungetc ('\n', in);
508  }
509  return token;
510 } /* ReadImagePpmField */
__int32 kkint32
Definition: KKBaseTypes.h:88
RasterPtr KKB::ReadImageUsingGDI ( const KKStr imageFileName)

Definition at line 237 of file ImageIO.cpp.

References DefineImageIoAtExit(), gdiStarted, and KKB::KKStr::ToWchar_t().

Referenced by ReadImage().

238 {
239  if (!gdiStarted)
240  {
241  GdiplusStartupInput gdiplusStartupInput;
242  ULONG_PTR gdiplusToken;
243  // Initialize GDI+.
244  GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
245 
246  //GdiplusShutdown(gdiplusToken);
247 
248  gdiStarted = true;
250  }
251 
252  RasterPtr r = NULL;
253  wchar_t* imageFileNameWide = imageFileName.ToWchar_t ();
254 
255  Bitmap* bm = Bitmap::FromFile (imageFileNameWide, false);
256  if (bm == NULL)
257  {
258  cerr << endl << "KKB::ReadImageUsingGDI ***ERROR*** Reading file: " << imageFileName << endl;
259  }
260  else
261  {
262  kkuint32 height = bm->GetHeight ();
263  kkuint32 width = bm->GetWidth ();
264 
265  BitmapData* bitmapData = new BitmapData ();
266  Gdiplus::Rect rect (0, 0, width, height);
267 
268  bm->LockBits(&rect, Gdiplus::ImageLockModeRead, bm->GetPixelFormat (), bitmapData);
269 
270  Gdiplus::PixelFormat pixFormat = bitmapData->PixelFormat;
271  kkint32 stride = bitmapData->Stride;
272  void* scan0 = bitmapData->Scan0;
273 
274  if (pixFormat == PixelFormat24bppRGB)
275  {
276  r = new Raster (height, width, true);
277 
278  kkint32 nOffset = stride - width * 3;
279  kkint32 bytesPerRow = width * 3 + nOffset;
280 
281  uchar red = 255;
282  uchar green = 255;
283  uchar blue = 255;
284 
285  kkuint32 row, col;
286 
287  bool grayScaleImage = true;
288 
289  uchar* ptr = (uchar*)(void*)scan0;
290  for (row = 0; row < height; ++row)
291  {
292  for (col = 0; col < width; ++col)
293  {
294  red = *ptr; ++ptr;
295  green = *ptr; ++ptr;
296  blue = *ptr; ++ptr;
297  r->SetPixelValue (row, col, red, green, blue);
298 
299  if ((red != green) || (red != blue))
300  grayScaleImage= false;
301  }
302  ptr += nOffset;
303  }
304 
305  if (grayScaleImage)
306  {
307  RasterPtr grayScaleR = r->CreateGrayScale ();
308  delete r;
309  r = grayScaleR;
310  grayScaleR = NULL;
311  }
312  }
313 
314  else if (pixFormat == PixelFormat8bppIndexed)
315  {
316  kkint32 paletteSize = bm->GetPaletteSize ();
317 
318  ColorPalette* palette = (ColorPalette*)malloc (paletteSize);
319  bm->GetPalette (palette, paletteSize);
320 
321  INT paletteHasAlpha = palette->Flags & PaletteFlagsHasAlpha;
322  INT paletteHasGrayScale = palette->Flags & PaletteFlagsGrayScale;
323  INT paletteHasHalftone = palette->Flags & PaletteFlagsHalftone;
324 
325  r = new Raster (height, width, false);
326  kkint32 nOffset = stride - width;
327  kkint32 bytesPerRow = width + nOffset;
328 
329  uchar index = 255;
330 
331  kkuint32 row, col;
332 
333  uchar* ptr = (uchar*)(void*)scan0;
334 
335  for (row = 0; row < height; ++row)
336  {
337  for (col = 0; col < width; ++col)
338  {
339  index = *ptr; ++ptr;
340 
341  ARGB argb = palette->Entries[index];
342 
343  kkint32 grayScaleValue = argb % 256;
344 
345  r->SetPixelValue (row, col, (uchar)grayScaleValue);
346  }
347 
348  ptr += nOffset;
349  }
350 
351  free (palette);
352  palette = NULL;
353  }
354 
355  bm->UnlockBits (bitmapData);
356 
357  delete bitmapData; bitmapData = NULL;
358  delete bm; bm = NULL;
359  }
360 
361  delete imageFileNameWide;
362  imageFileNameWide = NULL;
363  return r;
364 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
wchar_t * ToWchar_t() const
Definition: KKStr.cpp:3703
A class that is used by to represent a single image in memory.
Definition: Raster.h:108
#define INT
Definition: UsfCasCor.h:196
void DefineImageIoAtExit()
Definition: ImageIO.cpp:70
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
ULONG_PTR gdiplusToken
Definition: ImageIO.cpp:235
GdiplusStartupInput gdiplusStartupInput
Definition: ImageIO.cpp:234
bool gdiStarted
Definition: ImageIO.cpp:233
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
void SetPixelValue(const Point &point, const PixelValue &pixVal)
Definition: Raster.cpp:1440
RasterPtr CreateGrayScale() const
Definition: Raster.cpp:6060
void KKB::SaveImage ( const Raster image,
const KKStr imageFileName 
)

Definition at line 617 of file ImageIO.cpp.

References KKB::BmpImage::BmpImage(), KKB::KKStr::Concat(), KKB::KKException::KKException(), KKB::KKStr::operator+(), operator+(), KKB::KKStr::operator==(), osGetFileExtension(), KKB::BmpImage::Save(), SaveImagePGM(), SaveImagePNG(), and KKB::KKStr::Upper().

Referenced by KKB::Chart::SaveAsImage(), KKB::Histogram::SaveGraphImage(), SaveImageInverted(), and KKB::Raster::SegmentImage().

620 {
621  KKStr extension = osGetFileExtension (imageFileName);
622  extension.Upper ();
623 
624  if (extension == "BMP")
625  {
626  try
627  {
628  BmpImage bmpImage (image);
629  bmpImage.Save (imageFileName);
630  }
631  catch (const KKStr& errMsg)
632  {
633  throw KKException (errMsg);
634  }
635  catch (const KKException& errMsg)
636  {
637  KKStr msg = "SaveImage Exception Saving image using 'BmpImage'";
638  cerr << std::endl << msg << std::endl << std::endl;
639  throw KKException (msg, errMsg);
640  }
641  catch (...)
642  {
643  KKStr errMsg = "SaveImage Exception occurred calling 'BmpImage::Save' for file[" + imageFileName + "]";
644  cerr << std::endl << errMsg << std::endl << std::endl;
645  throw KKException (errMsg);
646  }
647  }
648 
649  else if (extension == "PGM")
650  {
651  SaveImagePGM (image, imageFileName);
652  }
653 
654  else if (extension == "PNG")
655  {
656  SaveImagePNG (image, imageFileName);
657  }
658 
659  else
660  {
661  KKStr errMsg = "ImageIO::SaveImage Extension[" + extension + "] is not supported.";
662 
663  cerr << std::endl << std::endl << std::endl
664  << "SaveImage *** ERROR *** " << std::endl
665  << errMsg << std::endl
666  << std::endl;
667  throw KKException (errMsg);
668  }
669 
670  return;
671 } /* SaveImage */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
void SaveImagePGM(const Raster &image, const KKStr &imageFileName)
Definition: ImageIO.cpp:675
KKStr osGetFileExtension(KKStr fullFileName)
Used to encode and decode BMP Images.
Definition: BMPImage.h:49
void Upper()
Converts all characters in string to their Upper case equivalents via &#39;toupper&#39;.
Definition: KKStr.cpp:2461
void SaveImagePNG(const Raster &image, const KKStr &imageFileName)
Definition: ImageIO.cpp:712
void KKB::SaveImageGrayscaleInverted4Bit ( const Raster image,
const KKStr _fileName 
)

Saves image as BMP file using 4 bit compressed gray-scale where Background = 255 and foreground = 0.

If image is color will convert to gray-scale 1st. Palette will be set to 0 = 255, 1 = 238, 2 = 221, 3 = 204... 255 = 0.

Definition at line 874 of file ImageIO.cpp.

References KKB::BmpImage::BmpImage(), KKB::KKStr::Concat(), KKB::KKStr::EqualIgnoreCase(), KKB::KKException::KKException(), KKB::KKStr::operator+(), operator+(), osGetFileExtension(), and KKB::BmpImage::SaveGrayscaleInverted4Bit().

877 {
878  KKStr ext = osGetFileExtension (_fileName);
879  if (!ext.EqualIgnoreCase ("BMP"))
880  {
881  KKStr msg;
882  msg << "KKB::SaveImageGrayscaleInverted4Bit Only 'BMP' files are supported; FileName[" << _fileName << "].";
883  cerr << endl << "***ERROR*** " << msg << endl << endl;
884  throw KKException (msg);
885  }
886 
887  try
888  {
889  BmpImage bmpImage (image);
890  bmpImage.SaveGrayscaleInverted4Bit (_fileName);
891  }
892  catch (const KKException& errMsg)
893  {
894  KKStr msg = "SaveImageGrayscaleInverted4Bit Exception Saving image using 'BmpImage' for file[" + _fileName + "]";
895  cerr << std::endl << msg << std::endl << std::endl;
896  throw KKException (msg, errMsg);
897  }
898  catch (...)
899  {
900  KKStr errMsg = "SaveImageGrayscaleInverted4Bit Exception occurred calling 'BmpImage::Save' for file[" + _fileName + "]";
901  cerr << std::endl << errMsg << std::endl << std::endl;
902  throw KKException (errMsg);
903  }
904 } /* SaveImageGrayscaleInverted4Bit */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
KKStr osGetFileExtension(KKStr fullFileName)
Used to encode and decode BMP Images.
Definition: BMPImage.h:49
void KKB::SaveImageGrayscaleInverted8Bit ( const Raster image,
const KKStr _fileName 
)

Saves image as BMP using compressed gray-scale where Background = 255 and foreground = 0.

Saves image as BMP using compressed GrayScale where Background = 255 and foreground = 0.

If image is color will convert to gray-scale 1st. Palette will be set to 0 = 255, 1 = 254, 2 = 253, ... 255 = 0.

If image is color will convert to GrayScale 1st. Palette will be set to 0 = 255, 1 = 254, 2 = 253, ... 255 = 0.

Definition at line 914 of file ImageIO.cpp.

References KKB::BmpImage::BmpImage(), KKB::KKStr::Concat(), KKB::KKStr::EqualIgnoreCase(), KKB::KKException::KKException(), KKB::KKStr::operator+(), operator+(), osGetFileExtension(), and KKB::BmpImage::SaveGrayscaleInverted8Bit().

917 {
918  KKStr ext = osGetFileExtension (_fileName);
919  if (!ext.EqualIgnoreCase ("BMP"))
920  {
921  KKStr msg;
922  msg << "KKB::SaveImageGrayscaleInverted4Bit Only 'BMP' files are supported; FileName[" << _fileName << "].";
923  cerr << endl << "***ERROR*** " << msg << endl << endl;
924  throw KKException (msg);
925  }
926 
927  try
928  {
929  BmpImage bmpImage (image);
930  bmpImage.SaveGrayscaleInverted8Bit (_fileName);
931  }
932  catch (const KKException& errMsg)
933  {
934  KKStr msg = "SaveImageGrayscaleInverted8Bit Exception Saving image using 'BmpImage'";
935  cerr << std::endl << "***ERROR*** " << msg << std::endl << std::endl;
936  throw KKException (msg, errMsg);
937  }
938  catch (...)
939  {
940  KKStr errMsg = "SaveImageGrayscaleInverted8Bit Exception occurred calling 'BmpImage::Save' for file[" + _fileName + "]";
941  cerr << std::endl << errMsg << std::endl << std::endl;
942  throw KKException (errMsg);
943  }
944 } /* SaveImageGrayscaleInverted4Bit */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
KKStr osGetFileExtension(KKStr fullFileName)
Used to encode and decode BMP Images.
Definition: BMPImage.h:49
void KKB::SaveImageInverted ( Raster raster,
const KKStr imageFileName 
)

Definition at line 841 of file ImageIO.cpp.

References KKB::Raster::Blue(), KKB::Raster::Color(), KKB::Raster::Green(), KKB::Raster::Height(), KKB::Raster::Raster(), KKB::Raster::Red(), SaveImage(), and KKB::Raster::Width().

844 {
845  RasterPtr invertedImage = new Raster (raster);
846 
847  kkint32 r, c;
848 
849  uchar** g = invertedImage->Green ();
850  uchar** red = invertedImage->Red ();
851  uchar** blue = invertedImage->Blue ();
852 
853  for (r = 0; r < invertedImage->Height (); r++)
854  {
855  for (c = 0; c < invertedImage->Width (); c++)
856  {
857  g[r][c] = 255 - g[r][c];
858  if (invertedImage->Color ())
859  {
860  red [r][c] = 255 - red [r][c];
861  blue[r][c] = 255 - blue[r][c];
862  }
863  }
864  }
865 
866  SaveImage (*invertedImage, imageFileName);
867  delete invertedImage;
868  invertedImage = NULL;
869 } /* SaveImageInverted */
__int32 kkint32
Definition: KKBaseTypes.h:88
A class that is used by to represent a single image in memory.
Definition: Raster.h:108
bool Color() const
Definition: Raster.h:310
uchar ** Red() const
Definition: Raster.h:326
kkint32 Height() const
Definition: Raster.h:319
void SaveImage(const Raster &image, const KKStr &imageFileName)
Definition: ImageIO.cpp:617
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
kkint32 Width() const
Definition: Raster.h:324
uchar ** Blue() const
Definition: Raster.h:328
uchar ** Green() const
Definition: Raster.h:327
void KKB::SaveImagePGM ( const Raster image,
const KKStr imageFileName 
)

Definition at line 675 of file ImageIO.cpp.

References KKB::Raster::Color(), KKB::KKStr::Concat(), KKB::Raster::CreateGrayScale(), KKB::Raster::GreenArea(), KKB::Raster::Height(), KKB::KKStr::KKStr(), osFOPEN(), KKB::KKStr::Str(), and KKB::Raster::Width().

Referenced by SaveImage().

678 {
679  FILE* o = osFOPEN (imageFileName.Str (), "wb");
680 
681  {
682  KKStr headerStr (15);
683  headerStr << "P5" << endl
684  << image.Width () << endl
685  << image.Height () << endl
686  << (kkint16)255 << endl;
687 
688  const char* h = headerStr.Str ();
689  fwrite (h, 1, headerStr.Len (), o);
690  }
691 
692  kkint32 totalPixels = image.Height () * image.Width ();
693 
694  if (image.Color ())
695  {
696  RasterPtr grayScaleImage = image.CreateGrayScale ();
697  const uchar* g = grayScaleImage->GreenArea ();
698  fwrite (g, 1, totalPixels, o);
699  delete grayScaleImage;
700  }
701  else
702  {
703  const uchar* g = image.GreenArea ();
704  fwrite (g, 1, totalPixels, o);
705  }
706 
707  fclose (o);
708 } /* SaveImagePGM */
__int16 kkint16
16 bit signed integer.
Definition: KKBaseTypes.h:85
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
A class that is used by to represent a single image in memory.
Definition: Raster.h:108
bool Color() const
Definition: Raster.h:310
kkint32 Height() const
Definition: Raster.h:319
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
uchar * GreenArea() const
Definition: Raster.h:330
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
kkint32 Width() const
Definition: Raster.h:324
FILE * osFOPEN(const char *fileName, const char *mode)
Definition: OSservices.cpp:74
RasterPtr CreateGrayScale() const
Definition: Raster.cpp:6060
void KKB::SaveImagePNG ( const Raster image,
const KKStr imageFileName 
)

Definition at line 712 of file ImageIO.cpp.

References KKB::Raster::BlueArea(), KKB::Raster::Color(), KKB::KKStr::Concat(), KKB::Raster::GreenArea(), KKB::Raster::Height(), KKB::KKException::KKException(), KKB::KKStr::KKStr(), KKB::KKStr::operator+(), operator+(), osFOPEN(), KKB::Raster::RedArea(), KKB::KKStr::Str(), and KKB::Raster::Width().

Referenced by SaveImage().

715 {
716  FILE* o = osFOPEN (imageFileName.Str (), "wb");
717  if (!o)
718  {
719  KKStr errMsg = "SaveImagePNG Error opening File[" + imageFileName + "]";
720  cerr << std::endl << errMsg << std::endl << std::endl;
721  throw KKException (errMsg);
722  }
723 
724  {
725  KKStr headerStr (15);
726  headerStr << "P6" << endl
727  << image.Width () << endl
728  << image.Height () << endl
729  << (kkint16)255 << endl;
730 
731  const char* h = headerStr.Str ();
732  fwrite (h, 1, headerStr.Len (), o);
733  }
734 
735  kkint32 totalPixels = image.Height () * image.Width ();
736 
737  if (image.Color ())
738  {
739  const uchar* red = image.RedArea ();
740  const uchar* green = image.GreenArea ();
741  const uchar* blue = image.BlueArea ();
742 
743  for (kkint32 x = 0; x < totalPixels; x++)
744  {
745  fwrite (red, 1, 1, o); ++red;
746  fwrite (green, 1, 1, o); ++green;
747  fwrite (blue, 1, 1, o); ++blue;
748  }
749  }
750  else
751  {
752  uchar* green = image.GreenArea ();
753  uchar buff3[3];
754 
755  for (kkint32 x = 0; x < totalPixels; x++)
756  {
757  uchar intensity = 255 - (*green);
758  buff3[0] = intensity;
759  buff3[1] = intensity;
760  buff3[2] = intensity;
761  fwrite (buff3, 1, 3, o);
762  ++green;
763  }
764  }
765 
766  fclose (o);
767  o = NULL;
768 
769  return ;
770 } /* SaveImagePNG */
__int16 kkint16
16 bit signed integer.
Definition: KKBaseTypes.h:85
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
bool Color() const
Definition: Raster.h:310
kkint32 Height() const
Definition: Raster.h:319
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
uchar * RedArea() const
Definition: Raster.h:329
uchar * GreenArea() const
Definition: Raster.h:330
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
uchar * BlueArea() const
Definition: Raster.h:331
kkint32 Width() const
Definition: Raster.h:324
FILE * osFOPEN(const char *fileName, const char *mode)
Definition: OSservices.cpp:74
void KKB::SaveImagePPM ( const Raster image,
const KKStr imageFileName 
)

Definition at line 774 of file ImageIO.cpp.

References KKB::Raster::BlueArea(), KKB::Raster::Color(), KKB::KKStr::Concat(), KKB::Raster::GreenArea(), KKB::Raster::Height(), KKB::KKException::KKException(), KKB::KKStr::KKStr(), KKB::KKStr::operator+(), operator+(), osFOPEN(), KKB::Raster::RedArea(), KKB::KKStr::Str(), and KKB::Raster::Width().

777 {
778  FILE* o = osFOPEN (imageFileName.Str (), "wb");
779  if (!o)
780  {
781  KKStr errMsg = "SaveImagePNG Error opening File[" + imageFileName + "]";
782  cerr << std::endl << errMsg << std::endl << std::endl;
783  throw KKException (errMsg);
784  }
785 
786  {
787  KKStr headerStr (15);
788  headerStr << "P6" << endl
789  << image.Width () << endl
790  << image.Height () << endl
791  << (kkint16)255 << endl;
792 
793  const char* h = headerStr.Str ();
794  fwrite (h, 1, headerStr.Len (), o);
795  }
796 
797  kkint32 totalPixels = image.Height () * image.Width ();
798 
799  if (image.Color ())
800  {
801  const uchar* red = image.RedArea ();
802  const uchar* green = image.GreenArea ();
803  const uchar* blue = image.BlueArea ();
804 
805  for (kkint32 x = 0; x < totalPixels; x++)
806  {
807  fwrite (red, 1, 1, o); ++red;
808  fwrite (green, 1, 1, o); ++green;
809  fwrite (blue, 1, 1, o); ++blue;
810  }
811  }
812  else
813  {
814  uchar* green = image.GreenArea ();
815  uchar buff3[3];
816 
817  for (kkint32 x = 0; x < totalPixels; x++)
818  {
819  uchar intensity = *green;
820  buff3[0] = intensity;
821  buff3[1] = intensity;
822  buff3[2] = intensity;
823  fwrite (buff3, 1, 3, o);
824  ++green;
825  }
826  }
827 
828  fclose (o);
829  o = NULL;
830 
831  return ;
832 } /* SaveImagePPM */
__int16 kkint16
16 bit signed integer.
Definition: KKBaseTypes.h:85
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
bool Color() const
Definition: Raster.h:310
kkint32 Height() const
Definition: Raster.h:319
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
uchar * RedArea() const
Definition: Raster.h:329
uchar * GreenArea() const
Definition: Raster.h:330
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
uchar * BlueArea() const
Definition: Raster.h:331
kkint32 Width() const
Definition: Raster.h:324
FILE * osFOPEN(const char *fileName, const char *mode)
Definition: OSservices.cpp:74
kkint32 KKB::SPRINTF ( char *  buff,
kkint32  buffSize,
const char *  formatSpec,
kkint16  right 
)

Definition at line 162 of file KKStr.cpp.

Referenced by KKB::KKStr::operator+(), and StrFromInt16().

167 {
168 # ifdef USE_SECURE_FUNCS
169  return sprintf_s (buff, buffSize, formatSpec, right);
170 # else
171  return sprintf (buff, formatSpec, right);
172 # endif
173 }
kkint32 KKB::SPRINTF ( char *  buff,
kkint32  buffSize,
const char *  formatSpec,
kkuint16  right 
)

Definition at line 177 of file KKStr.cpp.

Referenced by KKB::KKStr::operator+(), and StrFromUint16().

182 {
183 # ifdef USE_SECURE_FUNCS
184  return sprintf_s (buff, buffSize, formatSpec, right);
185 # else
186  return sprintf (buff, formatSpec, right);
187 #endif
188 }
kkint32 KKB::SPRINTF ( char *  buff,
kkint32  buffSize,
const char *  formatSpec,
kkint32  right 
)

Definition at line 193 of file KKStr.cpp.

Referenced by KKB::KKStr::operator+(), KKB::KKStr::operator=(), and StrFromInt32().

198 {
199 # ifdef USE_SECURE_FUNCS
200  return sprintf_s (buff, buffSize, formatSpec, right);
201 # else
202  return sprintf (buff, formatSpec, right);
203 # endif
204 }
kkint32 KKB::SPRINTF ( char *  buff,
kkint32  buffSize,
const char *  formatSpec,
kkuint32  right 
)

Definition at line 208 of file KKStr.cpp.

Referenced by KKB::KKStr::operator+(), and StrFromUint32().

213 {
214 # ifdef USE_SECURE_FUNCS
215  return sprintf_s (buff, buffSize, formatSpec, right);
216 # else
217  return sprintf (buff, formatSpec, right);
218 #endif
219 }
kkint32 KKB::SPRINTF ( char *  buff,
kkint32  buffSize,
const char *  formatSpec,
kkint64  right 
)

Definition at line 223 of file KKStr.cpp.

Referenced by KKB::KKStr::operator+(), and StrFromInt64().

228 {
229 
230 # ifdef USE_SECURE_FUNCS
231  return sprintf_s (buff, buffSize, formatSpec, right);
232 # else
233  return sprintf (buff, formatSpec, right);
234 # endif
235 }
kkint32 KKB::SPRINTF ( char *  buff,
kkint32  buffSize,
const char *  formatSpec,
kkuint64  right 
)

Definition at line 239 of file KKStr.cpp.

Referenced by KKB::KKStr::operator+(), and StrFromUint64().

244 {
245 
246 # ifdef USE_SECURE_FUNCS
247  return sprintf_s (buff, buffSize, formatSpec, right);
248 # else
249  return sprintf (buff, formatSpec, right);
250 # endif
251 }
kkint32 KKB::SPRINTF ( char *  buff,
kkint32  buffSize,
const char *  formatSpec,
kkint32  precision,
double  d 
)

Definition at line 255 of file KKStr.cpp.

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

261 {
262 #ifdef USE_SECURE_FUNCS
263  return sprintf_s (buff, buffSize, formatSpec, precision, d);
264 #else
265  return sprintf (buff, formatSpec, precision, d);
266 #endif
267 }
kkint32 KKB::SPRINTF ( char *  buff,
kkint32  buffSize,
char const *  formatSpec,
double  d 
)

Definition at line 271 of file KKStr.cpp.

Referenced by KKB::KKStr::KKStr(), KKB::KKStr::operator+(), KKB::KKStr::operator<<(), StrFromDouble(), StrFromFloat(), and SVM289_MFS::Svm_Model::WriteXML().

276 {
277  #ifdef USE_SECURE_FUNCS
278  return sprintf_s (buff, buffSize, formatSpec, d);
279  #else
280  return sprintf (buff, formatSpec, d);
281  #endif
282 }
void KKB::SRand48 ( kkint64  _seed)

Seeds the Lrand48 functions with the parameters passed to it.

Definition at line 49 of file KKBaseTypes.cpp.

References _lrand48_sequence.

50 {
51  kkint64 seedMask = 65535;
52  _lrand48_sequence &= seedMask;
53  kkint64 upperBits = _seed;
54  upperBits <<= 16;
55  _lrand48_sequence |= upperBits;
56 }
__int64 kkint64
Definition: KKBaseTypes.h:90
kkint64 _lrand48_sequence
Definition: KKBaseTypes.cpp:32
char * KKB::STRCAT ( char *  dest,
kkint32  destSize,
const char *  src 
)

Definition at line 74 of file KKStr.cpp.

78 {
79 # ifdef USE_SECURE_FUNCS
80  strcat_s (dest, destSize, src);
81 # else
82  strcat (dest, src);
83 # endif
84 
85  return dest;
86 } /* STRCAT */
char * KKB::STRCOPY ( char *  dest,
kkint32  destSize,
const char *  src 
)

Definition at line 46 of file KKStr.cpp.

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

50 {
51 # ifdef USE_SECURE_FUNCS
52  strcpy_s (dest, destSize, src);
53 # else
54  strcpy (dest, src);
55 # endif
56  return dest;
57 } /* STRCOPY */
char * KKB::STRCOPY ( char *  dest,
kkuint16  destSize,
const char *  src 
)

Definition at line 31 of file KKStr.cpp.

Referenced by KKB::KKStr::EnterStr(), KKB::KKStr::KKStr(), and KKB::KKStr::operator=().

35 {
36 # ifdef USE_SECURE_FUNCS
37  strcpy_s (dest, destSize, src);
38 # else
39  strcpy (dest, src);
40 # endif
41  return dest;
42 } /* STRCOPY */
char * KKB::STRDUP ( const char *  src)

Definition at line 62 of file KKStr.cpp.

Referenced by KKB::Tokenizer::DefineOperatorChars(), KKB::KKStrParser::KKStrParser(), and KKB::KKStrParser::TrimWhiteSpace().

63 {
64 # ifdef USE_SECURE_FUNCS
65  return _strdup (src);
66 # else
67  return strdup (src);
68 # endif
69 } /* STRDUP */
KKStr KKB::StrFormatDouble ( double  val,
const char *  mask 
)

Definition at line 4819 of file KKStr.cpp.

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

Referenced by KKMLL::ConfusionMatrix2::AccuracyStr(), KKMLL::CrossValidationVoting::FoldAccuracysToStr(), KKLSC::ScannerFile::InitiateWritting(), KKMLL::ConfusionMatrix2::PrintAccuracyByProbByClassHTML(), and StrFormatInt().

4822 {
4823  // Get number of decimal Places
4824 
4825  char buff[512];
4826  char* bp = buff + 511;
4827  *bp = 0;
4828 
4829  bool negativePrinted = true;
4830 
4831  if (val < 0)
4832  {
4833  negativePrinted = false;
4834  val = fabs (val);
4835  }
4836 
4837  bool printDecimalPoint = false;
4838 
4839  kkint32 numOfDecimalPlaces = 0;
4840 
4841  kkint32 maskLen = (kkint32)strlen (mask);
4842 
4843  kkint32 decimalPosition = LocateLastOccurrence (mask, '.');
4844 
4845  const char* maskPtr = mask + maskLen - 1;
4846 
4847  long intPart = (long)floor (val);
4848 
4849  kkint32 nextDigit = 0;
4850 
4851  kkint32 x;
4852 
4853  if (decimalPosition >= 0)
4854  {
4855  numOfDecimalPlaces = maskLen - decimalPosition - 1;
4856  printDecimalPoint = true;
4857  maskPtr = mask + decimalPosition - 1;
4858  maskLen = decimalPosition;
4859  }
4860 
4861  if (printDecimalPoint)
4862  {
4863  double power = pow ((double)10, (double)numOfDecimalPlaces);
4864 
4865  double frac = val - floor (val);
4866 
4867  kkint32 fracInt = (kkint32)(frac * power + 0.5);
4868 
4869  for (x = 0; x < numOfDecimalPlaces; x++)
4870  {
4871  nextDigit = fracInt % 10;
4872  fracInt = fracInt / 10;
4873  bp--;
4874  *bp = (char)('0' + nextDigit);
4875  }
4876 
4877  if (fracInt != 0)
4878  {
4879  // This can occur,
4880  // ex: mask = "#0.000", val = 1.9997
4881  // fracInt will end up equaling 1.000. because of rounding.
4882  intPart = intPart + fracInt;
4883  }
4884 
4885  bp--;
4886  *bp = '.';
4887  }
4888 
4889  char formatChar = ' ';
4890  char lastFormatChar = ' ';
4891 
4892  while (maskLen > 0)
4893  {
4894  formatChar = (char)toupper (*maskPtr);
4895 
4896  switch (formatChar)
4897  {
4898  case '0':
4899  case '@':
4900  nextDigit = intPart % 10;
4901  intPart = intPart / 10;
4902  bp--;
4903  *bp = '0' + (uchar)nextDigit;
4904  break;
4905 
4906 
4907  case '#':
4908  case '9':
4909  if (intPart > 0)
4910  {
4911  nextDigit = intPart % 10;
4912  intPart = intPart / 10;
4913  bp--;
4914  *bp = '0' + (uchar)nextDigit;
4915  }
4916  else
4917  {
4918  bp--;
4919  *bp = ' ';
4920  }
4921  break;
4922 
4923 
4924  case 'Z':
4925  if (intPart > 0)
4926  {
4927  nextDigit = intPart % 10;
4928  intPart = intPart / 10;
4929  bp--;
4930  *bp = '0' + (uchar)nextDigit;
4931  }
4932  break;
4933 
4934 
4935  case '-':
4936  if (intPart > 0)
4937  {
4938  nextDigit = intPart % 10;
4939  intPart = intPart / 10;
4940  bp--;
4941  *bp = '0' + (uchar)nextDigit;
4942  }
4943  else
4944  {
4945  if (!negativePrinted)
4946  {
4947  negativePrinted = true;
4948  bp--;
4949  *bp = '-';
4950  }
4951  }
4952  break;
4953 
4954 
4955  case ',':
4956  if (intPart > 0)
4957  {
4958  bp--;
4959  *bp = ',';
4960  }
4961 
4962  else if (lastFormatChar != 'Z')
4963  {
4964  bp--;
4965  *bp = ' ';
4966  }
4967  break;
4968 
4969 
4970  default:
4971  bp--;
4972  *bp = formatChar;
4973  break;
4974  } /* end of Switch (*maskPtr) */
4975 
4976 
4977  lastFormatChar = formatChar;
4978 
4979  maskPtr--;
4980  maskLen--;
4981  }
4982 
4983  // If the mask was not large enough to include all digits then lets do it now.
4984  while (intPart > 0)
4985  {
4986  nextDigit = intPart % 10;
4987  intPart = intPart / 10;
4988  bp--;
4989  *bp = '0' + (uchar)nextDigit;
4990  }
4991 
4992  if (!negativePrinted)
4993  {
4994  bp--;
4995  *bp = '-';
4996  }
4997 
4998  return KKStr (bp);
4999 } /* StrFormatDouble */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 LocateLastOccurrence(const char *str, char ch)
Definition: KKStr.cpp:4791
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
KKStr KKB::StrFormatInt64 ( kkint64  val,
const char *  mask 
)

Definition at line 5013 of file KKStr.cpp.

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

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

5016 {
5017  // Get number of decimal Places
5018 
5019  char buff[128];
5020  char* bp = buff + 127;
5021  *bp = 0;
5022 
5023  bool negativePrinted = true;
5024 
5025  if (val < 0)
5026  {
5027  negativePrinted = false;
5028  val = 0 - val;
5029  }
5030 
5031  kkint32 maskLen = (kkint32)strlen (mask);
5032  const char* maskPtr = mask + maskLen - 1;
5033 
5034  kkint64 intPart = val;
5035 
5036  kkint32 nextDigit = 0;
5037 
5038  char formatChar = ' ';
5039  char lastFormatChar = ' ';
5040 
5041  while (maskLen > 0)
5042  {
5043  formatChar = (uchar)toupper (*maskPtr);
5044 
5045  switch (formatChar)
5046  {
5047  case '0':
5048  case '@':
5049  nextDigit = intPart % 10;
5050  intPart = intPart / 10;
5051  bp--;
5052  *bp = '0' + (uchar)nextDigit;
5053  break;
5054 
5055 
5056  case '#':
5057  case '9':
5058  if (intPart > 0)
5059  {
5060  nextDigit = intPart % 10;
5061  intPart = intPart / 10;
5062  bp--;
5063  *bp = '0' + (uchar)nextDigit;
5064  }
5065  else
5066  {
5067  bp--;
5068  *bp = ' ';
5069  }
5070  break;
5071 
5072 
5073  case 'Z':
5074  if (intPart > 0)
5075  {
5076  nextDigit = intPart % 10;
5077  intPart = intPart / 10;
5078  bp--;
5079  *bp = '0' + (uchar)nextDigit;
5080  }
5081  break;
5082 
5083 
5084  case '-':
5085  if (intPart > 0)
5086  {
5087  nextDigit = intPart % 10;
5088  intPart = intPart / 10;
5089  bp--;
5090  *bp = '0' + (uchar)nextDigit;
5091  }
5092  else
5093  {
5094  if (!negativePrinted)
5095  {
5096  negativePrinted = true;
5097  bp--;
5098  *bp = '-';
5099  }
5100  }
5101  break;
5102 
5103 
5104  case ',':
5105  if (intPart > 0)
5106  {
5107  bp--;
5108  *bp = ',';
5109  }
5110 
5111  else if (lastFormatChar != 'Z')
5112  {
5113  bp--;
5114  *bp = ' ';
5115  }
5116  break;
5117 
5118 
5119  default:
5120  bp--;
5121  *bp = formatChar;
5122  break;
5123  } /* end of Switch (*maskPtr) */
5124 
5125 
5126  lastFormatChar = formatChar;
5127 
5128  maskPtr--;
5129  maskLen--;
5130  }
5131 
5132  // If the mask was not large enough to include all digits then lets do it now.
5133  while (intPart > 0)
5134  {
5135  nextDigit = intPart % 10;
5136  intPart = intPart / 10;
5137  bp--;
5138  *bp = '0' + (uchar)nextDigit;
5139  }
5140 
5141  if (!negativePrinted)
5142  {
5143  bp--;
5144  *bp = '-';
5145  }
5146 
5147  return KKStr (bp);
5148 } /* StrFormatInt */
__int32 kkint32
Definition: KKBaseTypes.h:88
__int64 kkint64
Definition: KKBaseTypes.h:90
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
KKStr KKB::StrFromDouble ( double  d)

Definition at line 5229 of file KKStr.cpp.

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

Referenced by KKB::XmlElementKeyValuePairs::Add().

5230 {
5231  char buff[50];
5232  SPRINTF (buff, sizeof (buff), "%g", d);
5233  KKStr s (buff);
5234  return s;
5235 } /* StrFromFloat */
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr KKB::StrFromFloat ( float  f)

Definition at line 5219 of file KKStr.cpp.

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

Referenced by KKB::XmlElementKeyValuePairs::Add().

5220 {
5221  char buff[50];
5222  SPRINTF (buff, sizeof (buff), "%f", f);
5223  KKStr s (buff);
5224  return s;
5225 } /* StrFromFloat */
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr KKB::StrFromInt16 ( kkint16  i)

Definition at line 5152 of file KKStr.cpp.

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

Referenced by KKMLL::Model::CreateAModel().

5153 {
5154  char buff[50];
5155 
5156  SPRINTF (buff, sizeof (buff), "%d", i);
5157  KKStr s (buff);
5158  return s;
5159 } /* StrFromInt16 */
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr KKB::StrFromInt32 ( kkint32  i)

Definition at line 5175 of file KKStr.cpp.

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

Referenced by KKB::XmlElementKeyValuePairs::Add(), KKB::BmpImage::BlueRow(), KKB::BmpImage::ImageRow(), KKB::BmpImage::RedRow(), KKB::KKStr::RightPad(), tqli(), and Tred2().

5176 {
5177  char buff[50];
5178 
5179  SPRINTF (buff, sizeof (buff), "%ld", i);
5180  KKStr s (buff);
5181  return s;
5182 } /* StrFromInt32 */
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr KKB::StrFromInt64 ( kkint64  i)

Definition at line 5198 of file KKStr.cpp.

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

5199 {
5200  char buff[50];
5201 
5202  SPRINTF (buff, sizeof (buff), "%lld", i64);
5203  KKStr s (buff);
5204  return s;
5205 } /* StrFromInt64 */
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr KKB::StrFromUint16 ( kkuint16  ui)

Definition at line 5164 of file KKStr.cpp.

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

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

5165 {
5166  char buff[50];
5167 
5168  SPRINTF (buff, sizeof (buff), "%u", ui);
5169  KKStr s (buff);
5170  return s;
5171 } /* StrFromUint16 */
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr KKB::StrFromUint32 ( kkuint32  ui)

Definition at line 5187 of file KKStr.cpp.

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

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

5188 {
5189  char buff[50];
5190 
5191  SPRINTF (buff, sizeof (buff), "%lu", ui);
5192  KKStr s (buff);
5193  return s;
5194 } /* StrFromUint32 */
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
KKStr KKB::StrFromUint64 ( kkuint64  ui)

Definition at line 5209 of file KKStr.cpp.

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

5210 {
5211  char buff[50];
5212  SPRINTF (buff, sizeof (buff), "%llu", ul);
5213  KKStr s (buff);
5214  return s;
5215 } /* StrFromUint64 */
kkint32 SPRINTF(char *buff, kkint32 buffSize, const char *formatSpec, kkint16 right)
Definition: KKStr.cpp:162
kkint32 KKB::STRICMP ( const char *  left,
const char *  right 
)

Definition at line 92 of file KKStr.cpp.

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

95 {
96  if (left == NULL)
97  {
98  if (right == NULL)
99  return 0;
100  else
101  return -1;
102  }
103  else if (!right)
104  return 1;
105 
106  kkint32 zed = (toupper (*left)) - (toupper (*right));
107 
108  while ((zed == 0) && (*left != 0))
109  {
110  left++; right++;
111  zed = (toupper (*left)) - (toupper (*right));
112  }
113 
114  if (zed < 0)
115  return -1;
116  else if (zed == 0)
117  return 0;
118  else
119  return 1;
120 
121 } /* STRICMP */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 KKB::STRNICMP ( const char *  left,
const char *  right,
kkint32  len 
)

Definition at line 126 of file KKStr.cpp.

130 {
131  if (left == NULL)
132  {
133  if (right == NULL)
134  return 0;
135  else
136  return -1;
137  }
138  else if (!right)
139  return 1;
140 
141  if (len < 1)
142  return 0;
143 
144  kkint32 x = 0;
145  kkint32 zed = (toupper (*left)) - (toupper (*right));
146  while ((zed == 0) && (*left != 0) && (x < len))
147  {
148  ++left; ++right; ++x;
149  zed = (toupper (*left)) - (toupper (*right));
150  }
151 
152  if (zed < 0)
153  return -1;
154  else if (zed == 0)
155  return 0;
156  else
157  return 1;
158 } /* STRNICMP */
__int32 kkint32
Definition: KKBaseTypes.h:88
bool KKB::SupportedImageFileFormat ( const KKStr imageFileName)

Definition at line 948 of file ImageIO.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::operator==(), osGetFileExtension(), and KKB::KKStr::Upper().

Referenced by KKMLL::FeatureFileIO::FeatureDataReSink().

949 {
950  KKStr ext = osGetFileExtension (imageFileName);
951  ext.Upper ();
952 
953  return (
954  (ext == "BMP") ||
955  (ext == "PGM") ||
956  (ext == "PNG")
957  );
958 }
KKStr osGetFileExtension(KKStr fullFileName)
void Upper()
Converts all characters in string to their Upper case equivalents via &#39;toupper&#39;.
Definition: KKStr.cpp:2461
template<class T >
T KKB::Swap ( T &  x,
T &  y 
)

Definition at line 255 of file KKBaseTypes.h.

258  {
259  T z = x;
260  x = y;
261  y = z;
262  } /* Swap */
unsigned int KKB::ThreadStartCallBack ( void *  param)

Definition at line 280 of file KKThread.cpp.

References KKB::KKStr::Concat(), KKB::KKThread::Crashed(), KKB::KKThread::ExceptionText(), KKB::KKThread::Run(), KKB::KKThread::Starting, KKB::KKThread::Status(), KKB::KKThread::Stopped, and KKB::KKException::ToString().

281  {
282  KKThreadPtr tp = (KKThreadPtr)param;
283  tp->Status (KKThread::ThreadStatus::Starting);
284  try
285  {
286  tp->Run ();
287  }
288  catch (const KKException& e1)
289  {
290  tp->Crashed (true);
291  tp->ExceptionText (e1.ToString ());
292  }
293  catch (const std::exception e2)
294  {
295  tp->Crashed (true);
296  const char* e2What = e2.what ();
297  KKStr msg (30 + strlen (e2What));
298  msg << "std::exception: " << e2What;
299  tp->ExceptionText (msg);
300  }
301  catch (...)
302  {
303  tp->Crashed (true);
304  tp->ExceptionText ("exception(...) trapped.");
305  }
306 
307  tp->Status (KKThread::ThreadStatus::Stopped);
308  return 0;
309  }
ThreadStatus Status() const
Definition: KKThread.h:72
bool Crashed() const
Definition: KKThread.h:62
The base class to be used any thread.
Definition: KKThread.h:27
const KKStr & ExceptionText() const
Definition: KKThread.h:66
KKThread::KKThreadPtr KKThreadPtr
Definition: KKThread.h:209
virtual const KKStr & ToString() const
Definition: KKException.cpp:98
virtual void Run()
Definition: KKThread.cpp:447
void KKB::tqli ( kkint32  n,
double *  d,
double *  e,
double  z[2][2] 
)

Definition at line 195 of file EigenVector.cpp.

References KKB::KKException::KKException(), KKB::KKStr::operator+(), operator+(), pythag(), and StrFromInt32().

Referenced by KKB::Raster::CalcOrientationAndEigerRatio().

200 {
201  if ((n < 1) || (n > 2))
202  throw KKException ("KKB::tqli n:" + StrFromInt32(n) + " out of range of 1 thru 2");
203 
204  kkint32 m, l, iter, i, k;
205  double s, r, p,g, f, dd, c, b;
206 
207  for (i = 1; i < n; i++)
208  e[i - 1] = e[i];
209 
210  e[n - 1] = 0.0;
211 
212  for (l = 0; l < n; l++)
213  {
214  iter = 0;
215 
216  do
217  {
218  for (m = l; m < n - 1; m++)
219  {
220  // Looking for a single small sub-diagonal element
221  // to split the matrix
222  dd = fabs (d[m]) + fabs (d[m + 1]);
223  if (fabs (e[m]) + dd == dd)
224  break;
225  }
226 
227  if (m != l)
228  {
229  if (iter == 100)
230  {
231  cerr << std::endl << std::endl
232  << "EigenVector::tqli **** ERROR **** To many iterations in tqli" << std::endl
233  << std::endl;
234  //osWaitForEnter ();
235  //exit (-1);
236  return;
237  }
238  iter++;
239 
240  g = (d[l + 1] - d[l]) / (2.0 * e[1]);
241  r = pythag (g, 1.0);
242  g = d[m] - d[l] + e[l] / (g + SIGN (r, g));
243  s = c = 1.0;
244  p = 0.0;
245 
246  for (i = m - 1; i >= l; i--)
247  {
248  f = s * e[i];
249  b = c * e[i];
250  e[i + 1] = (r = pythag (f, g));
251  if (r == 0.0)
252  {
253  d[i + 1] -= p;
254  e[m] = 0.0;
255  break;
256  }
257 
258  s = f / r;
259  c = g / r;
260  g = d[i + 1] - p;
261  r = (d[i] - g) * s + 2.0 * c * b;
262  d[i + 1] = g + (p = s * r);
263  g = c * r - b;
264 
265  // Next loop can be omitted if eigen vectors not wanted
266 
267  for (k = 0; k < n; k++)
268  {
269  f = z[k][i + 1];
270  z[k][i + 1] = s * z[k][i] + c * f;
271  z[k][i] = c * z[k][i] - s * f;
272  } /* for (k) */
273 
274  } /* for (i) */
275 
276  if ((r == 0.0) && (i >= l))
277  continue;
278 
279  d[l] -= p;
280  e[l] = g;
281  e[m] = 0.0;
282  }
283  }
284  while (m != l);
285 
286  } /* for (l) */
287 
288  return;
289 } /* tqli */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
const T SIGN(const T &a, const T &b)
double pythag(const double a, const double b)
KKStr StrFromInt32(kkint32 i)
Definition: KKStr.cpp:5175
void KKB::Tred2 ( kkint32  n,
double  a[2][2],
double *  d,
double *  e 
)

Definition at line 31 of file EigenVector.cpp.

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

Referenced by KKB::Raster::CalcOrientationAndEigerRatio().

36 {
37  if ((n < 1) || (n > 2))
38  throw KKException("KKB::Tred2 n:" + StrFromInt32(n) + " out of range of 1 thru 2"); kkint32 i, j, k, l;
39 
40  double scale, hh, h, g, f;
41 
42  for (i = n - 1; i > 0; i--)
43  {
44  l = i - 1;
45  h = scale = 0.0;
46 
47  if (l > 0)
48  {
49  for (k = 0; k < l + 1; k++)
50  scale += fabs (a[i][k]);
51 
52  if (scale == 0.0)
53  {
54  e[i] = a[i][l];
55  }
56 
57  else
58  {
59  for (k = 0; k < l + 1; k++)
60  {
61  if (scale == 0.0)
62  a[i][k] = 0.0;
63  else
64  a[i][k] /= scale; // Use scaled a's for transformation
65  h+= a[i][k] * a[i][k]; // h = sigma
66  }
67 
68  f = a[i][l];
69  g = (f > 0 ? -sqrt(h) : sqrt(h));
70  e[i] = scale * g;
71  h -= f * g;
72  a[i][l] = f - g;
73  f = 0.0;
74 
75  for (j = 0; j < l + 1; j++)
76  {
77  a[j][i] = a[i][j] / h;
78  g = 0.0;
79  for (k = 0; k < j + 1; k++)
80  g += a[j][k] * a[i][k];
81 
82  for (k = j + 1; k < l + 1; k++)
83  g += a[k][j] * a[i][k];
84 
85  e[j] = g / h;
86 
87  f += e[j] * a[i][j];
88  } /* for (j = 0; */
89 
90  hh = f / (h + h);
91 
92  for (j = 0; j < l + 1; j++)
93  {
94  f = a[i][j];
95  e[j] = g = e[j] - hh * f;
96  for (k = 0; k < j + 1; k++)
97  a[j][k] -= (f * e[k] + g * a[i][k]);
98  }
99  }
100  } /* if (l > 0) */
101  else
102  {
103  e[i] = a[i][l];
104  }
105 
106  d[i] = h;
107  }
108 
109  // We can now calculate Eigen Vectors
110 
111  d[0] = 0.0;
112  e[0] = 0.0;
113 
114  for (i = 0; i < n; i++)
115  {
116  l = i;
117 
118  if (d[i] != 0.0)
119  {
120  for (j = 0; j < l; j++)
121  {
122  g = 0.0;
123  for (k = 0; k < l; k++)
124  g += a[i][k] * a[k][j];
125 
126  for (k = 0; k < l; k++)
127  a[k][j] -= g * a[k][i];
128  }
129  }
130 
131  d[i] = a[i][i];
132 
133  // Reset row and column of 'a' to identity matrix;
134  a[i][i] = 1.0;
135  for (j = 0; j < l; j++)
136  a[j][i] = a[i][j] = 0.0;
137  } /* for (i) */
138 
139 } /* Tred2 */
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr StrFromInt32(kkint32 i)
Definition: KKStr.cpp:5175
XmlFactoryPtr KKB::XmlElementKKStrFactoryInstance ( )

Definition at line 1415 of file XmlStream.cpp.

1416 {
1418 }
static XmlFactoryKKStr * FactoryInstance()
Definition: XmlStream.cpp:1413
XmlFactoryPtr KKB::XmlElementUnKnownFactoryInstance ( )

Definition at line 1090 of file XmlStream.cpp.

Referenced by KKB::XmlStream::GetNextToken().

1091 {
1093 }
static XmlFactoryUnKnown * FactoryInstance()
Definition: XmlStream.cpp:1088

Variable Documentation

double KKB::DoubleMax = DBL_MAX

Definition at line 22 of file KKBaseTypes.cpp.

double KKB::DoubleMin = DBL_MIN

Definition at line 23 of file KKBaseTypes.cpp.

bool KKB::imageIoAtExitDefined = false

Definition at line 65 of file ImageIO.cpp.

Referenced by DefineImageIoAtExit().