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 #if defined(_LUCENE_PRAGMA_ONCE) 00011 # pragma once 00012 #endif 00013 00014 CL_NS_DEF(util) 00015 00016 00017 00019 class Misc{ 00020 public: 00021 static uint64_t currentTimeMillis(); 00022 static const TCHAR* replace_all( const TCHAR* val, const TCHAR* srch, const TCHAR* repl ); 00023 static bool dir_Exists(const char* path); 00024 static int64_t file_Size(const char* path); 00025 00026 static size_t ahashCode(const char* str); 00027 static size_t ahashCode(const char* str, size_t len); 00028 00029 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 ); 00030 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 ); 00031 00032 static bool priv_isDotDir( const TCHAR* name ); 00033 //Creates a filename by concatenating Segment with ext and x 00034 static char* segmentname(const char* segment, const char* ext, const int32_t x=-1 ); 00035 //Creates a filename in buffer by concatenating Segment with ext and x 00036 static void segmentname(char* buffer,int32_t bufferLen, const char* Segment, const char* ext, const int32_t x=-1); 00037 00048 static int32_t stringDifference(const TCHAR* s1, const int32_t s1Len, const TCHAR* s2, const int32_t s2Len); 00049 00050 #ifdef _UCS2 00051 static size_t whashCode(const wchar_t* str); 00052 static size_t whashCode(const wchar_t* str, size_t len); 00053 #define thashCode whashCode 00054 00055 static char* _wideToChar(const wchar_t* s CL_FILELINEPARAM); 00056 static wchar_t* _charToWide(const char* s CL_FILELINEPARAM); 00057 00058 static void _cpycharToWide(const char* s, wchar_t* d, size_t len); 00059 static void _cpywideToChar(const wchar_t* s, char* d, size_t len); 00060 #else 00061 #define thashCode ahashCode 00062 #endif 00063 }; 00064 00065 CL_NS_END 00066 #endif