CLucene - a full-featured, c++ search engine
API Documentation
00001 /*------------------------------------------------------------------------------ 00002 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team 00003 * 00004 * Distributable under the terms of either the Apache License (Version 2.0) or 00005 * the GNU Lesser General Public License, as specified in the COPYING file. 00006 ------------------------------------------------------------------------------*/ 00007 #ifndef _lucene_util_Misc_H 00008 #define _lucene_util_Misc_H 00009 00010 CL_NS_DEF(util) 00013 class Misc{ 00014 public: 00015 static uint64_t currentTimeMillis(); 00016 static const TCHAR* replace_all( const TCHAR* val, const TCHAR* srch, const TCHAR* repl ); 00017 static bool dir_Exists(const char* path); 00018 static int64_t file_Size(const char* path); 00019 00020 static size_t ahashCode(const char* str); 00021 static size_t ahashCode(const char* str, size_t len); 00022 00023 static TCHAR* join ( const TCHAR* a, const TCHAR* b, const TCHAR* c=NULL, const TCHAR* d=NULL,const TCHAR* e=NULL,const TCHAR* f=NULL ); 00024 static char* ajoin ( const char* a, const char* b, const char* c=NULL, const char* d=NULL,const char* e=NULL,const char* f=NULL ); 00025 00026 static bool priv_isDotDir( const TCHAR* name ); 00027 //Creates a filename by concatenating Segment with ext and x 00028 static char* segmentname(const char* segment, const char* ext, const int32_t x=-1 ); 00029 //Creates a filename in buffer by concatenating Segment with ext and x 00030 static void segmentname(char* buffer,int32_t bufferLen, const char* Segment, const char* ext, const int32_t x=-1); 00031 00042 static int32_t stringDifference(const TCHAR* s1, const int32_t s1Len, const TCHAR* s2, const int32_t s2Len); 00043 00044 // In-place trimming for strings and words ("te st" will be returned by stringTrim, while wordTrim will return "te") 00045 // This is by design only meant for use with on-memory strings, and calling it like stringTrim(_T("test")) will 00046 // be errorneous 00047 static TCHAR* stringTrim(TCHAR* s); 00048 static TCHAR* wordTrim(TCHAR* s); 00049 00050 static char* longToBase( int64_t value, int32_t base ); 00051 static int64_t base36ToLong( const char* value ); 00052 00053 #ifdef _UCS2 00054 static size_t whashCode(const wchar_t* str); 00055 static size_t whashCode(const wchar_t* str, size_t len); 00056 #define thashCode whashCode 00057 00058 static char* _wideToChar(const wchar_t* s); 00059 static wchar_t* _charToWide(const char* s); 00060 00061 static void _cpycharToWide(const char* s, wchar_t* d, size_t len); 00062 static void _cpywideToChar(const wchar_t* s, char* d, size_t len); 00063 #else 00064 #define thashCode ahashCode 00065 #endif 00066 }; 00067 00068 CL_NS_END 00069 #endif