001
002
003 #ifndef GAUDIALG_HBOOKNAME_H
004 #define GAUDIALG_HBOOKNAME_H 1
005
006 #include <string>
007 #include <algorithm>
008
009
010
011
012
013
014
015
016
017
018 namespace
019 {
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036 inline std::string dirHbookName
037 ( const std::string& addr ,
038 const int maxLen = 16 )
039 {
040
041 if( addr.empty() ) { return std::string(); }
042
043 std::string old( addr );
044
045 if( 0 < maxLen && maxLen < (int) old.size() )
046 {
047 std::string::iterator p1,p2;
048 p1 = old.begin();
049 const char sep('/');
050 while( old.end() != p1 )
051 {
052 p1 =
053 std::find_if( p1 ,
054 old.end() ,
055 std::bind2nd(std::not_equal_to<char>(),sep));
056 p2 = std::find( p1 , old.end() , sep ) ;
057 if( ( p2 - p1 ) <= (int) maxLen ) { p1 = p2 ; continue ; }
058 old.insert( p1 + maxLen , sep ) ;
059 p1 = old.begin() ;
060 }
061 }
062
063 return old;
064 }
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085 inline std::string histoHbookName
086 ( const std::string& addr ,
087 const int maxLen = 8 )
088 {
089
090 if( addr.empty() ) { return std::string(); }
091
092 std::string old( addr );
093 {
094 std::string::size_type pos
095 = old.find_last_of( '/' );
096 if ( std::string::npos == pos ) { old += "/1" ; }
097 else if ( old.size() - 1 == pos ) { old += '1' ; }
098 else
099 {
100 const int id =
101 atoi( std::string( old , pos + 1 , std::string::npos ).c_str() );
102 if( 0 == id ) { old+="/1"; }
103 }
104 }
105
106 if( 0 < maxLen && maxLen < (int) old.size() )
107 {
108 std::string::iterator p1,p2;
109 p1 = old.begin();
110 const char sep('/');
111 while( old.end() != p1 )
112 {
113 p1 =
114 std::find_if( p1 ,
115 old.end() ,
116 std::bind2nd(std::not_equal_to<char>(),sep));
117 p2 = std::find( p1 , old.end() , sep ) ;
118 if( ( p2 - p1 ) <= (int) maxLen ) { p1 = p2 ; continue ; }
119 old.insert( p1 + maxLen , sep ) ;
120 p1 = old.begin() ;
121 }
122 }
123
124 return old;
125 }
126
127 }
128
129
130
131
132 #endif
133
134
| Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems |
|
This page was automatically generated by the
LXR engine.
|
|