| The Gaudi Framework v32r1 (f65d50dc)

HbookName.h
Go to the documentation of this file.
1 #ifndef GAUDIALG_HBOOKNAME_H
2 #define GAUDIALG_HBOOKNAME_H 1
3 // Include files
4 #include <algorithm>
5 #include <string>
6
16 namespace {
31 inline std::string dirHbookName( const std::string& addr, const int maxLen = 16 ) {
32 // ignore empty locations
33 if ( addr.empty() ) { return std::string(); }
34 //
35 std::string old( addr );
36 // remove long names
37 if ( 0 < maxLen && maxLen < (int)old.size() ) {
38 auto p1 = old.begin();
39 const char sep( '/' );
40 while ( old.end() != p1 ) {
41 p1 = std::find_if( p1, old.end(), [&]( const char& c ) { return c != sep; } );
42 auto p2 = std::find( p1, old.end(), sep );
43 if ( ( p2 - p1 ) <= (int)maxLen ) {
44 p1 = p2;
45 continue;
46 }
47 old.insert( p1 + maxLen, sep );
48 p1 = old.begin();
49 }
50 }
52 return old;
53 }
54
55 } // end of anonymous namespace
56
57 // ============================================================================
58 // The END
59 // ============================================================================
60 #endif // GAUDIALG_HBOOKNAME_H
std::string::empty
T empty(T... args)
gaudirun.c
c
Definition: gaudirun.py:487
std::string
STL class.
std::find_if
T find_if(T... args)