Functions | |
std::string | dirHbookName (const std::string &addr, const int maxLen=8) |
Simple function to convert any valid Gaudi address(name in Transient Store) to address, which is simultaneously valid for Hbook directory. |
std::string Local::dirHbookName | ( | const std::string & | addr, | |
const int | maxLen = 8 | |||
) | [inline] |
Simple function to convert any valid Gaudi address(name in Transient Store) to address, which is simultaneously valid for Hbook directory.
examples: "verylongname" --> "verylong/name"
The function is imported from Calo/CaloUtils package
addr | old address | |
maxLen | maximum allowed length of directory name (8 for Hbook) |
Definition at line 27 of file DirHbookName.h.
00029 { 00030 // ignore empty locations 00031 if( addr.empty() ) { return std::string(); } 00032 // 00033 std::string old( addr ); 00034 // remove long names 00035 if( 0 < maxLen && maxLen < (int) old.size() ) 00036 { 00037 std::string::iterator p1,p2; 00038 p1 = old.begin(); 00039 const char sep('/'); 00040 while( old.end() != p1 ) 00041 { 00042 p1 = 00043 std::find_if( p1 , 00044 old.end() , 00045 std::bind2nd(std::not_equal_to<char>(),sep)); 00046 p2 = std::find( p1 , old.end() , sep ) ; 00047 if( ( p2 - p1 ) <= (int) maxLen ) { p1 = p2 ; continue ; } 00048 old.insert( p1 + maxLen , sep ) ; 00049 p1 = old.begin() ; 00050 } 00051 } 00053 return old; 00054 };