00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ROOT_TMemStatHelpers
00012 #define ROOT_TMemStatHelpers
00013
00014
00015 #include "TString.h"
00016 #include "TObjString.h"
00017 #include "TCollection.h"
00018
00019 #include <string>
00020 #include <functional>
00021 #include <algorithm>
00022 #include <cctype>
00023
00024
00025 class TObject;
00026
00027 namespace memstat {
00028 std::string dig2bytes(Long64_t bytes);
00029
00030
00031 struct SFind_t : std::binary_function<TObject*, TString, bool> {
00032 bool operator()(TObject *_Obj, const TString &_ToFind) const {
00033 TObjString *str(dynamic_cast<TObjString*>(_Obj));
00034 if(!str)
00035 return false;
00036 return !str->String().CompareTo(_ToFind);
00037 }
00038 };
00039
00040
00041 template<class T>
00042 Int_t find_string(const T &_Container, const TString &_ToFind)
00043 {
00044
00045
00046
00047 typedef TIterCategory<T> iterator_t;
00048
00049 iterator_t iter(&_Container);
00050 iterator_t found(
00051 std::find_if(iter.Begin(), iterator_t::End(), bind2nd(SFind_t(), _ToFind))
00052 );
00053 return ((!(*found)) ? -1 : std::distance(iter.Begin(), found));
00054 }
00055
00056
00057
00058 struct ToLower_t {
00059 char operator()(char c) const {
00060 return std::tolower(c);
00061 }
00062 };
00063
00064 }
00065 #endif