00001
00002
00004 #ifndef __CUtils__
00005 #define __CUtils__
00006
00007 #include <iostream>
00008 #include <iomanip>
00009 #include <math.h>
00010 #include <stdlib.h>
00011 #include <string.h>
00012 #include <vector>
00013 #include <stdio.h>
00014 #include <sstream>
00015
00016 #include <fstream>
00017 #include <regex.h>
00018
00019 #ifndef __CINT__
00020 #include <dirent.h>
00021 #include <glob.h>
00022 #include <fnmatch.h>
00023 #endif
00024
00025 #define LN2 0.6931471805599453094172321214581766
00027 using namespace std;
00028
00034 inline bool IsPowerOfTwo (unsigned int x){ return ((x != 0) && !(x & (x - 1))); };
00035
00036
00041 inline int NextPowerOfTwo (double x){
00042 return (int)pow(2.0,ceil(log(x)/log(2.0)));
00043 };
00044
00045
00050 double medianbiasfactor(const int nn);
00051
00059 vector<string> SplitString(const string stringtodivide, const char separator);
00060
00069 string ReplaceAll(string str, const string& from, const string& to);
00070
00076 bool IsDirectory(const char* dirname);
00077
00083 inline bool IsDirectory(const string dirname){ return IsDirectory(dirname.c_str()); };
00084
00091 bool ListDirectories(const string maindir, vector <string> &subdir);
00092
00098 bool IsTextFile(const char* filename);
00099
00105 inline bool IsTextFile(const string filename){ return IsTextFile(filename.c_str()); };
00106
00112 bool IsBinaryFile(const char* filename);
00113
00119 inline bool IsBinaryFile(const string filename){ return IsBinaryFile(filename.c_str()); };
00120
00126 vector<string> Glob(const char* pattern);
00127
00128 #endif
00129
00130