clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -O3 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name EnvironmentVariables.cc -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/data/b2soft/buildbot/development/build -fcoverage-compilation-dir=/data/b2soft/buildbot/development/build -resource-dir /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/lib/clang/21 -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/c++ -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/c++/x86_64-redhat-linux -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/c++/backward -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/include -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/python3.12 -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/include/CLHEP -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/Geant4 -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/include/root -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/include/belle_legacy -I include/ -D _PACKAGE_="framework" -D G4UI_USE_TCSH -D RaveDllExport= -D HAS_SQLITE -D HAS_CALLGRIND -D KeccakP200_excluded -D KeccakP400_excluded -D KeccakP800_excluded -I include -I /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/libxml2 -internal-isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/bin/../lib64/gcc/x86_64-redhat-linux/15.2.0/../../../../include/c++ -internal-isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/bin/../lib64/gcc/x86_64-redhat-linux/15.2.0/../../../../include/c++/x86_64-redhat-linux -internal-isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/bin/../lib64/gcc/x86_64-redhat-linux/15.2.0/../../../../include/c++/backward -internal-isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/bin/../lib64/gcc/x86_64-redhat-linux/15.2.0/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-missing-braces -Wno-unused-command-line-argument -std=c++20 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /scan_build/2026-05-31-004316-385593-1 -x c++ framework/utilities/src/EnvironmentVariables.cc
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | #ifndef BOOST_STRING_FINDER_HPP |
| 12 | #define BOOST_STRING_FINDER_HPP |
| 13 | |
| 14 | #include <boost/algorithm/string/config.hpp> |
| 15 | |
| 16 | #include <boost/range/iterator_range_core.hpp> |
| 17 | #include <boost/range/begin.hpp> |
| 18 | #include <boost/range/end.hpp> |
| 19 | #include <boost/range/iterator.hpp> |
| 20 | #include <boost/range/const_iterator.hpp> |
| 21 | |
| 22 | #include <boost/algorithm/string/constants.hpp> |
| 23 | #include <boost/algorithm/string/detail/finder.hpp> |
| 24 | #include <boost/algorithm/string/compare.hpp> |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | namespace boost { |
| 35 | namespace algorithm { |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | template<typename RangeT> |
| 49 | inline detail::first_finderF< |
| 50 | BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type, |
| 51 | is_equal> |
| 52 | first_finder( const RangeT& Search ) |
| 53 | { |
| 54 | return |
| 55 | detail::first_finderF< |
| 56 | BOOST_STRING_TYPENAME |
| 57 | range_const_iterator<RangeT>::type, |
| 58 | is_equal>( ::boost::as_literal(Search), is_equal() ) ; |
| 59 | } |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | template<typename RangeT,typename PredicateT> |
| 66 | inline detail::first_finderF< |
| 67 | BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type, |
| 68 | PredicateT> |
| 69 | first_finder( |
| 70 | const RangeT& Search, PredicateT Comp ) |
| 71 | { |
| 72 | return |
| 73 | detail::first_finderF< |
| 74 | BOOST_STRING_TYPENAME |
| 75 | range_const_iterator<RangeT>::type, |
| 76 | PredicateT>( ::boost::as_literal(Search), Comp ); |
| 77 | } |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | template<typename RangeT> |
| 89 | inline detail::last_finderF< |
| 90 | BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type, |
| 91 | is_equal> |
| 92 | last_finder( const RangeT& Search ) |
| 93 | { |
| 94 | return |
| 95 | detail::last_finderF< |
| 96 | BOOST_STRING_TYPENAME |
| 97 | range_const_iterator<RangeT>::type, |
| 98 | is_equal>( ::boost::as_literal(Search), is_equal() ); |
| 99 | } |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | template<typename RangeT, typename PredicateT> |
| 105 | inline detail::last_finderF< |
| 106 | BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type, |
| 107 | PredicateT> |
| 108 | last_finder( const RangeT& Search, PredicateT Comp ) |
| 109 | { |
| 110 | return |
| 111 | detail::last_finderF< |
| 112 | BOOST_STRING_TYPENAME |
| 113 | range_const_iterator<RangeT>::type, |
| 114 | PredicateT>( ::boost::as_literal(Search), Comp ) ; |
| 115 | } |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | template<typename RangeT> |
| 128 | inline detail::nth_finderF< |
| 129 | BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type, |
| 130 | is_equal> |
| 131 | nth_finder( |
| 132 | const RangeT& Search, |
| 133 | int Nth) |
| 134 | { |
| 135 | return |
| 136 | detail::nth_finderF< |
| 137 | BOOST_STRING_TYPENAME |
| 138 | range_const_iterator<RangeT>::type, |
| 139 | is_equal>( ::boost::as_literal(Search), Nth, is_equal() ) ; |
| 140 | } |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | template<typename RangeT, typename PredicateT> |
| 146 | inline detail::nth_finderF< |
| 147 | BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type, |
| 148 | PredicateT> |
| 149 | nth_finder( |
| 150 | const RangeT& Search, |
| 151 | int Nth, |
| 152 | PredicateT Comp ) |
| 153 | { |
| 154 | return |
| 155 | detail::nth_finderF< |
| 156 | BOOST_STRING_TYPENAME |
| 157 | range_const_iterator<RangeT>::type, |
| 158 | PredicateT>( ::boost::as_literal(Search), Nth, Comp ); |
| 159 | } |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | inline detail::head_finderF |
| 173 | head_finder( int N ) |
| 174 | { |
| 175 | return detail::head_finderF(N); |
| 176 | } |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | inline detail::tail_finderF |
| 190 | tail_finder( int N ) |
| 191 | { |
| 192 | return detail::tail_finderF(N); |
| 193 | } |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | template< typename PredicateT > |
| 214 | inline detail::token_finderF<PredicateT> |
| 215 | token_finder( |
| 216 | PredicateT Pred, |
| 217 | token_compress_mode_type eCompress=token_compress_off ) |
| 218 | { |
| 219 | return detail::token_finderF<PredicateT>( Pred, eCompress ); |
| 5 | | Calling constructor for 'token_finderF<boost::algorithm::detail::is_any_ofF<char>>' | |
|
| 10 | | Returning from constructor for 'token_finderF<boost::algorithm::detail::is_any_ofF<char>>' | |
|
| 220 | } |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | template< typename ForwardIteratorT > |
| 233 | inline detail::range_finderF<ForwardIteratorT> |
| 234 | range_finder( |
| 235 | ForwardIteratorT Begin, |
| 236 | ForwardIteratorT End ) |
| 237 | { |
| 238 | return detail::range_finderF<ForwardIteratorT>( Begin, End ); |
| 239 | } |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | template< typename ForwardIteratorT > |
| 246 | inline detail::range_finderF<ForwardIteratorT> |
| 247 | range_finder( iterator_range<ForwardIteratorT> Range ) |
| 248 | { |
| 249 | return detail::range_finderF<ForwardIteratorT>( Range ); |
| 250 | } |
| 251 | |
| 252 | } |
| 253 | |
| 254 | |
| 255 | using algorithm::first_finder; |
| 256 | using algorithm::last_finder; |
| 257 | using algorithm::nth_finder; |
| 258 | using algorithm::head_finder; |
| 259 | using algorithm::tail_finder; |
| 260 | using algorithm::token_finder; |
| 261 | using algorithm::range_finder; |
| 262 | |
| 263 | } |
| 264 | |
| 265 | |
| 266 | #endif // BOOST_STRING_FINDER_HPP |
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | #ifndef BOOST_STRING_FINDER_DETAIL_HPP |
| 12 | #define BOOST_STRING_FINDER_DETAIL_HPP |
| 13 | |
| 14 | #include <boost/algorithm/string/config.hpp> |
| 15 | #include <boost/algorithm/string/constants.hpp> |
| 16 | #include <iterator> |
| 17 | |
| 18 | #include <boost/range/iterator_range_core.hpp> |
| 19 | #include <boost/range/begin.hpp> |
| 20 | #include <boost/range/end.hpp> |
| 21 | #include <boost/range/empty.hpp> |
| 22 | #include <boost/range/as_literal.hpp> |
| 23 | |
| 24 | namespace boost { |
| 25 | namespace algorithm { |
| 26 | namespace detail { |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | template<typename SearchIteratorT,typename PredicateT> |
| 37 | struct first_finderF |
| 38 | { |
| 39 | typedef SearchIteratorT search_iterator_type; |
| 40 | |
| 41 | |
| 42 | template< typename SearchT > |
| 43 | first_finderF( const SearchT& Search, PredicateT Comp ) : |
| 44 | m_Search(::boost::begin(Search), ::boost::end(Search)), m_Comp(Comp) {} |
| 45 | first_finderF( |
| 46 | search_iterator_type SearchBegin, |
| 47 | search_iterator_type SearchEnd, |
| 48 | PredicateT Comp ) : |
| 49 | m_Search(SearchBegin, SearchEnd), m_Comp(Comp) {} |
| 50 | |
| 51 | |
| 52 | template< typename ForwardIteratorT > |
| 53 | iterator_range<ForwardIteratorT> |
| 54 | operator()( |
| 55 | ForwardIteratorT Begin, |
| 56 | ForwardIteratorT End ) const |
| 57 | { |
| 58 | typedef iterator_range<ForwardIteratorT> result_type; |
| 59 | typedef ForwardIteratorT input_iterator_type; |
| 60 | |
| 61 | |
| 62 | for(input_iterator_type OuterIt=Begin; |
| 63 | OuterIt!=End; |
| 64 | ++OuterIt) |
| 65 | { |
| 66 | |
| 67 | if( boost::empty(m_Search) ) |
| 68 | return result_type( End, End ); |
| 69 | |
| 70 | input_iterator_type InnerIt=OuterIt; |
| 71 | search_iterator_type SubstrIt=m_Search.begin(); |
| 72 | for(; |
| 73 | InnerIt!=End && SubstrIt!=m_Search.end(); |
| 74 | ++InnerIt,++SubstrIt) |
| 75 | { |
| 76 | if( !( m_Comp(*InnerIt,*SubstrIt) ) ) |
| 77 | break; |
| 78 | } |
| 79 | |
| 80 | |
| 81 | if ( SubstrIt==m_Search.end() ) |
| 82 | return result_type( OuterIt, InnerIt ); |
| 83 | } |
| 84 | |
| 85 | return result_type( End, End ); |
| 86 | } |
| 87 | |
| 88 | private: |
| 89 | iterator_range<search_iterator_type> m_Search; |
| 90 | PredicateT m_Comp; |
| 91 | }; |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | template<typename SearchIteratorT, typename PredicateT> |
| 101 | struct last_finderF |
| 102 | { |
| 103 | typedef SearchIteratorT search_iterator_type; |
| 104 | typedef first_finderF< |
| 105 | search_iterator_type, |
| 106 | PredicateT> first_finder_type; |
| 107 | |
| 108 | |
| 109 | template< typename SearchT > |
| 110 | last_finderF( const SearchT& Search, PredicateT Comp ) : |
| 111 | m_Search(::boost::begin(Search), ::boost::end(Search)), m_Comp(Comp) {} |
| 112 | last_finderF( |
| 113 | search_iterator_type SearchBegin, |
| 114 | search_iterator_type SearchEnd, |
| 115 | PredicateT Comp ) : |
| 116 | m_Search(SearchBegin, SearchEnd), m_Comp(Comp) {} |
| 117 | |
| 118 | |
| 119 | template< typename ForwardIteratorT > |
| 120 | iterator_range<ForwardIteratorT> |
| 121 | operator()( |
| 122 | ForwardIteratorT Begin, |
| 123 | ForwardIteratorT End ) const |
| 124 | { |
| 125 | typedef iterator_range<ForwardIteratorT> result_type; |
| 126 | |
| 127 | if( boost::empty(m_Search) ) |
| 128 | return result_type( End, End ); |
| 129 | |
| 130 | typedef BOOST_STRING_TYPENAME |
| 131 | std::iterator_traits<ForwardIteratorT>::iterator_category category; |
| 132 | |
| 133 | return findit( Begin, End, category() ); |
| 134 | } |
| 135 | |
| 136 | private: |
| 137 | |
| 138 | template< typename ForwardIteratorT > |
| 139 | iterator_range<ForwardIteratorT> |
| 140 | findit( |
| 141 | ForwardIteratorT Begin, |
| 142 | ForwardIteratorT End, |
| 143 | std::forward_iterator_tag ) const |
| 144 | { |
| 145 | typedef iterator_range<ForwardIteratorT> result_type; |
| 146 | |
| 147 | first_finder_type first_finder( |
| 148 | m_Search.begin(), m_Search.end(), m_Comp ); |
| 149 | |
| 150 | result_type M=first_finder( Begin, End ); |
| 151 | result_type Last=M; |
| 152 | |
| 153 | while( M ) |
| 154 | { |
| 155 | Last=M; |
| 156 | M=first_finder( ::boost::end(M), End ); |
| 157 | } |
| 158 | |
| 159 | return Last; |
| 160 | } |
| 161 | |
| 162 | |
| 163 | template< typename ForwardIteratorT > |
| 164 | iterator_range<ForwardIteratorT> |
| 165 | findit( |
| 166 | ForwardIteratorT Begin, |
| 167 | ForwardIteratorT End, |
| 168 | std::bidirectional_iterator_tag ) const |
| 169 | { |
| 170 | typedef iterator_range<ForwardIteratorT> result_type; |
| 171 | typedef ForwardIteratorT input_iterator_type; |
| 172 | |
| 173 | |
| 174 | for(input_iterator_type OuterIt=End; |
| 175 | OuterIt!=Begin; ) |
| 176 | { |
| 177 | input_iterator_type OuterIt2=--OuterIt; |
| 178 | |
| 179 | input_iterator_type InnerIt=OuterIt2; |
| 180 | search_iterator_type SubstrIt=m_Search.begin(); |
| 181 | for(; |
| 182 | InnerIt!=End && SubstrIt!=m_Search.end(); |
| 183 | ++InnerIt,++SubstrIt) |
| 184 | { |
| 185 | if( !( m_Comp(*InnerIt,*SubstrIt) ) ) |
| 186 | break; |
| 187 | } |
| 188 | |
| 189 | |
| 190 | if( SubstrIt==m_Search.end() ) |
| 191 | return result_type( OuterIt2, InnerIt ); |
| 192 | } |
| 193 | |
| 194 | return result_type( End, End ); |
| 195 | } |
| 196 | |
| 197 | private: |
| 198 | iterator_range<search_iterator_type> m_Search; |
| 199 | PredicateT m_Comp; |
| 200 | }; |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | template<typename SearchIteratorT, typename PredicateT> |
| 210 | struct nth_finderF |
| 211 | { |
| 212 | typedef SearchIteratorT search_iterator_type; |
| 213 | typedef first_finderF< |
| 214 | search_iterator_type, |
| 215 | PredicateT> first_finder_type; |
| 216 | typedef last_finderF< |
| 217 | search_iterator_type, |
| 218 | PredicateT> last_finder_type; |
| 219 | |
| 220 | |
| 221 | template< typename SearchT > |
| 222 | nth_finderF( |
| 223 | const SearchT& Search, |
| 224 | int Nth, |
| 225 | PredicateT Comp) : |
| 226 | m_Search(::boost::begin(Search), ::boost::end(Search)), |
| 227 | m_Nth(Nth), |
| 228 | m_Comp(Comp) {} |
| 229 | nth_finderF( |
| 230 | search_iterator_type SearchBegin, |
| 231 | search_iterator_type SearchEnd, |
| 232 | int Nth, |
| 233 | PredicateT Comp) : |
| 234 | m_Search(SearchBegin, SearchEnd), |
| 235 | m_Nth(Nth), |
| 236 | m_Comp(Comp) {} |
| 237 | |
| 238 | |
| 239 | template< typename ForwardIteratorT > |
| 240 | iterator_range<ForwardIteratorT> |
| 241 | operator()( |
| 242 | ForwardIteratorT Begin, |
| 243 | ForwardIteratorT End ) const |
| 244 | { |
| 245 | if(m_Nth>=0) |
| 246 | { |
| 247 | return find_forward(Begin, End, m_Nth); |
| 248 | } |
| 249 | else |
| 250 | { |
| 251 | return find_backward(Begin, End, -m_Nth); |
| 252 | } |
| 253 | |
| 254 | } |
| 255 | |
| 256 | private: |
| 257 | |
| 258 | template< typename ForwardIteratorT > |
| 259 | iterator_range<ForwardIteratorT> |
| 260 | find_forward( |
| 261 | ForwardIteratorT Begin, |
| 262 | ForwardIteratorT End, |
| 263 | unsigned int N) const |
| 264 | { |
| 265 | typedef iterator_range<ForwardIteratorT> result_type; |
| 266 | |
| 267 | |
| 268 | if( boost::empty(m_Search) ) |
| 269 | return result_type( End, End ); |
| 270 | |
| 271 | |
| 272 | first_finder_type first_finder( |
| 273 | m_Search.begin(), m_Search.end(), m_Comp ); |
| 274 | |
| 275 | result_type M( Begin, Begin ); |
| 276 | |
| 277 | for( unsigned int n=0; n<=N; ++n ) |
| 278 | { |
| 279 | |
| 280 | M=first_finder( ::boost::end(M), End ); |
| 281 | |
| 282 | if ( !M ) |
| 283 | { |
| 284 | |
| 285 | return M; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | return M; |
| 290 | } |
| 291 | |
| 292 | template< typename ForwardIteratorT > |
| 293 | iterator_range<ForwardIteratorT> |
| 294 | find_backward( |
| 295 | ForwardIteratorT Begin, |
| 296 | ForwardIteratorT End, |
| 297 | unsigned int N) const |
| 298 | { |
| 299 | typedef iterator_range<ForwardIteratorT> result_type; |
| 300 | |
| 301 | |
| 302 | if( boost::empty(m_Search) ) |
| 303 | return result_type( End, End ); |
| 304 | |
| 305 | |
| 306 | last_finder_type last_finder( |
| 307 | m_Search.begin(), m_Search.end(), m_Comp ); |
| 308 | |
| 309 | result_type M( End, End ); |
| 310 | |
| 311 | for( unsigned int n=1; n<=N; ++n ) |
| 312 | { |
| 313 | |
| 314 | M=last_finder( Begin, ::boost::begin(M) ); |
| 315 | |
| 316 | if ( !M ) |
| 317 | { |
| 318 | |
| 319 | return M; |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | return M; |
| 324 | } |
| 325 | |
| 326 | |
| 327 | private: |
| 328 | iterator_range<search_iterator_type> m_Search; |
| 329 | int m_Nth; |
| 330 | PredicateT m_Comp; |
| 331 | }; |
| 332 | |
| 333 | |
| 334 | |
| 335 | template<typename ForwardIteratorT> |
| 336 | iterator_range<ForwardIteratorT> |
| 337 | find_head_impl( |
| 338 | ForwardIteratorT Begin, |
| 339 | ForwardIteratorT End, |
| 340 | unsigned int N, |
| 341 | std::forward_iterator_tag ) |
| 342 | { |
| 343 | typedef ForwardIteratorT input_iterator_type; |
| 344 | typedef iterator_range<ForwardIteratorT> result_type; |
| 345 | |
| 346 | input_iterator_type It=Begin; |
| 347 | for( unsigned int Index=0; Index<N && It!=End; ++Index,++It ) |
| 348 | ; |
| 349 | |
| 350 | return result_type( Begin, It ); |
| 351 | } |
| 352 | |
| 353 | template< typename ForwardIteratorT > |
| 354 | iterator_range<ForwardIteratorT> |
| 355 | find_head_impl( |
| 356 | ForwardIteratorT Begin, |
| 357 | ForwardIteratorT End, |
| 358 | unsigned int N, |
| 359 | std::random_access_iterator_tag ) |
| 360 | { |
| 361 | typedef iterator_range<ForwardIteratorT> result_type; |
| 362 | |
| 363 | if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) ) |
| 364 | return result_type( Begin, End ); |
| 365 | |
| 366 | return result_type(Begin,Begin+N); |
| 367 | } |
| 368 | |
| 369 | |
| 370 | template<typename ForwardIteratorT> |
| 371 | iterator_range<ForwardIteratorT> |
| 372 | find_head_impl( |
| 373 | ForwardIteratorT Begin, |
| 374 | ForwardIteratorT End, |
| 375 | unsigned int N ) |
| 376 | { |
| 377 | typedef BOOST_STRING_TYPENAME |
| 378 | std::iterator_traits<ForwardIteratorT>::iterator_category category; |
| 379 | |
| 380 | return ::boost::algorithm::detail::find_head_impl( Begin, End, N, category() ); |
| 381 | } |
| 382 | |
| 383 | template< typename ForwardIteratorT > |
| 384 | iterator_range<ForwardIteratorT> |
| 385 | find_tail_impl( |
| 386 | ForwardIteratorT Begin, |
| 387 | ForwardIteratorT End, |
| 388 | unsigned int N, |
| 389 | std::forward_iterator_tag ) |
| 390 | { |
| 391 | typedef ForwardIteratorT input_iterator_type; |
| 392 | typedef iterator_range<ForwardIteratorT> result_type; |
| 393 | |
| 394 | unsigned int Index=0; |
| 395 | input_iterator_type It=Begin; |
| 396 | input_iterator_type It2=Begin; |
| 397 | |
| 398 | |
| 399 | for( Index=0; Index<N && It2!=End; ++Index,++It2 ) |
| 400 | ; |
| 401 | |
| 402 | |
| 403 | for(; It2!=End; ++It,++It2 ) |
| 404 | ; |
| 405 | |
| 406 | return result_type( It, It2 ); |
| 407 | } |
| 408 | |
| 409 | template< typename ForwardIteratorT > |
| 410 | iterator_range<ForwardIteratorT> |
| 411 | find_tail_impl( |
| 412 | ForwardIteratorT Begin, |
| 413 | ForwardIteratorT End, |
| 414 | unsigned int N, |
| 415 | std::bidirectional_iterator_tag ) |
| 416 | { |
| 417 | typedef ForwardIteratorT input_iterator_type; |
| 418 | typedef iterator_range<ForwardIteratorT> result_type; |
| 419 | |
| 420 | input_iterator_type It=End; |
| 421 | for( unsigned int Index=0; Index<N && It!=Begin; ++Index,--It ) |
| 422 | ; |
| 423 | |
| 424 | return result_type( It, End ); |
| 425 | } |
| 426 | |
| 427 | template< typename ForwardIteratorT > |
| 428 | iterator_range<ForwardIteratorT> |
| 429 | find_tail_impl( |
| 430 | ForwardIteratorT Begin, |
| 431 | ForwardIteratorT End, |
| 432 | unsigned int N, |
| 433 | std::random_access_iterator_tag ) |
| 434 | { |
| 435 | typedef iterator_range<ForwardIteratorT> result_type; |
| 436 | |
| 437 | if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) ) |
| 438 | return result_type( Begin, End ); |
| 439 | |
| 440 | return result_type( End-N, End ); |
| 441 | } |
| 442 | |
| 443 | |
| 444 | template< typename ForwardIteratorT > |
| 445 | iterator_range<ForwardIteratorT> |
| 446 | find_tail_impl( |
| 447 | ForwardIteratorT Begin, |
| 448 | ForwardIteratorT End, |
| 449 | unsigned int N ) |
| 450 | { |
| 451 | typedef BOOST_STRING_TYPENAME |
| 452 | std::iterator_traits<ForwardIteratorT>::iterator_category category; |
| 453 | |
| 454 | return ::boost::algorithm::detail::find_tail_impl( Begin, End, N, category() ); |
| 455 | } |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | struct head_finderF |
| 469 | { |
| 470 | |
| 471 | head_finderF( int N ) : m_N(N) {} |
| 472 | |
| 473 | |
| 474 | template< typename ForwardIteratorT > |
| 475 | iterator_range<ForwardIteratorT> |
| 476 | operator()( |
| 477 | ForwardIteratorT Begin, |
| 478 | ForwardIteratorT End ) const |
| 479 | { |
| 480 | if(m_N>=0) |
| 481 | { |
| 482 | return ::boost::algorithm::detail::find_head_impl( Begin, End, m_N ); |
| 483 | } |
| 484 | else |
| 485 | { |
| 486 | iterator_range<ForwardIteratorT> Res= |
| 487 | ::boost::algorithm::detail::find_tail_impl( Begin, End, -m_N ); |
| 488 | |
| 489 | return ::boost::make_iterator_range(Begin, Res.begin()); |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | private: |
| 494 | int m_N; |
| 495 | }; |
| 496 | |
| 497 | |
| 498 | |
| 499 | |
| 500 | |
| 501 | |
| 502 | |
| 503 | |
| 504 | |
| 505 | |
| 506 | struct tail_finderF |
| 507 | { |
| 508 | |
| 509 | tail_finderF( int N ) : m_N(N) {} |
| 510 | |
| 511 | |
| 512 | template< typename ForwardIteratorT > |
| 513 | iterator_range<ForwardIteratorT> |
| 514 | operator()( |
| 515 | ForwardIteratorT Begin, |
| 516 | ForwardIteratorT End ) const |
| 517 | { |
| 518 | if(m_N>=0) |
| 519 | { |
| 520 | return ::boost::algorithm::detail::find_tail_impl( Begin, End, m_N ); |
| 521 | } |
| 522 | else |
| 523 | { |
| 524 | iterator_range<ForwardIteratorT> Res= |
| 525 | ::boost::algorithm::detail::find_head_impl( Begin, End, -m_N ); |
| 526 | |
| 527 | return ::boost::make_iterator_range(Res.end(), End); |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | private: |
| 532 | int m_N; |
| 533 | }; |
| 534 | |
| 535 | |
| 536 | |
| 537 | |
| 538 | |
| 539 | |
| 540 | |
| 541 | |
| 542 | |
| 543 | |
| 544 | |
| 545 | |
| 546 | |
| 547 | template< typename PredicateT > |
| 548 | struct token_finderF |
| 549 | { |
| 550 | |
| 551 | token_finderF( |
| 552 | PredicateT Pred, |
| 553 | token_compress_mode_type eCompress=token_compress_off ) : |
| 554 | m_Pred(Pred), m_eCompress(eCompress) {} |
| 6 | | Calling copy constructor for 'is_any_ofF<char>' | |
|
| 9 | | Returning from copy constructor for 'is_any_ofF<char>' | |
|
| 555 | |
| 556 | |
| 557 | template< typename ForwardIteratorT > |
| 558 | iterator_range<ForwardIteratorT> |
| 559 | operator()( |
| 560 | ForwardIteratorT Begin, |
| 561 | ForwardIteratorT End ) const |
| 562 | { |
| 563 | typedef iterator_range<ForwardIteratorT> result_type; |
| 564 | |
| 565 | ForwardIteratorT It=std::find_if( Begin, End, m_Pred ); |
| 566 | |
| 567 | if( It==End ) |
| 568 | { |
| 569 | return result_type( End, End ); |
| 570 | } |
| 571 | else |
| 572 | { |
| 573 | ForwardIteratorT It2=It; |
| 574 | |
| 575 | if( m_eCompress==token_compress_on ) |
| 576 | { |
| 577 | |
| 578 | while( It2!=End && m_Pred(*It2) ) ++It2; |
| 579 | } |
| 580 | else |
| 581 | { |
| 582 | |
| 583 | ++It2; |
| 584 | } |
| 585 | |
| 586 | return result_type( It, It2 ); |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | private: |
| 591 | PredicateT m_Pred; |
| 592 | token_compress_mode_type m_eCompress; |
| 593 | }; |
| 594 | |
| 595 | |
| 596 | |
| 597 | |
| 598 | |
| 599 | |
| 600 | |
| 601 | |
| 602 | template<typename ForwardIterator1T> |
| 603 | struct range_finderF |
| 604 | { |
| 605 | typedef ForwardIterator1T input_iterator_type; |
| 606 | typedef iterator_range<input_iterator_type> result_type; |
| 607 | |
| 608 | |
| 609 | range_finderF( |
| 610 | input_iterator_type Begin, |
| 611 | input_iterator_type End ) : m_Range(Begin, End) {} |
| 612 | |
| 613 | range_finderF(const iterator_range<input_iterator_type>& Range) : |
| 614 | m_Range(Range) {} |
| 615 | |
| 616 | |
| 617 | template< typename ForwardIterator2T > |
| 618 | iterator_range<ForwardIterator2T> |
| 619 | operator()( |
| 620 | ForwardIterator2T, |
| 621 | ForwardIterator2T ) const |
| 622 | { |
| 623 | #if BOOST_WORKAROUND( __MWERKS__, <= 0x3003 ) |
| 624 | return iterator_range<const ForwardIterator2T>(this->m_Range); |
| 625 | #else |
| 626 | return m_Range; |
| 627 | #endif |
| 628 | } |
| 629 | |
| 630 | private: |
| 631 | iterator_range<input_iterator_type> m_Range; |
| 632 | }; |
| 633 | |
| 634 | |
| 635 | } |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | #endif // BOOST_STRING_FINDER_DETAIL_HPP |
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | #ifndef BOOST_STRING_CLASSIFICATION_DETAIL_HPP |
| 12 | #define BOOST_STRING_CLASSIFICATION_DETAIL_HPP |
| 13 | |
| 14 | #include <boost/algorithm/string/config.hpp> |
| 15 | #include <algorithm> |
| 16 | #include <cstring> |
| 17 | #include <functional> |
| 18 | #include <locale> |
| 19 | |
| 20 | #include <boost/range/begin.hpp> |
| 21 | #include <boost/range/distance.hpp> |
| 22 | #include <boost/range/end.hpp> |
| 23 | |
| 24 | #include <boost/algorithm/string/predicate_facade.hpp> |
| 25 | #include <boost/type_traits/remove_const.hpp> |
| 26 | |
| 27 | namespace boost { |
| 28 | namespace algorithm { |
| 29 | namespace detail { |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | struct is_classifiedF : |
| 35 | public predicate_facade<is_classifiedF> |
| 36 | { |
| 37 | |
| 38 | typedef bool result_type; |
| 39 | |
| 40 | |
| 41 | is_classifiedF(std::ctype_base::mask Type, std::locale const & Loc = std::locale()) : |
| 42 | m_Type(Type), m_Locale(Loc) {} |
| 43 | |
| 44 | template<typename CharT> |
| 45 | bool operator()( CharT Ch ) const |
| 46 | { |
| 47 | return std::use_facet< std::ctype<CharT> >(m_Locale).is( m_Type, Ch ); |
| 48 | } |
| 49 | |
| 50 | #if defined(BOOST_BORLANDC) && (BOOST_BORLANDC >= 0x560) && (BOOST_BORLANDC <= 0x582) && !defined(_USE_OLD_RW_STL) |
| 51 | template<> |
| 52 | bool operator()( char const Ch ) const |
| 53 | { |
| 54 | return std::use_facet< std::ctype<char> >(m_Locale).is( m_Type, Ch ); |
| 55 | } |
| 56 | #endif |
| 57 | |
| 58 | private: |
| 59 | std::ctype_base::mask m_Type; |
| 60 | std::locale m_Locale; |
| 61 | }; |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | template<typename CharT> |
| 69 | struct is_any_ofF : |
| 70 | public predicate_facade<is_any_ofF<CharT> > |
| 71 | { |
| 72 | private: |
| 73 | |
| 74 | typedef typename ::boost::remove_const<CharT>::type set_value_type; |
| 75 | |
| 76 | public: |
| 77 | |
| 78 | typedef bool result_type; |
| 79 | |
| 80 | |
| 81 | template<typename RangeT> |
| 82 | is_any_ofF( const RangeT& Range ) : m_Size(0) |
| 83 | { |
| 84 | |
| 85 | m_Storage.m_dynSet=0; |
| 86 | |
| 87 | std::size_t Size=::boost::distance(Range); |
| 88 | m_Size=Size; |
| 89 | set_value_type* Storage=0; |
| 90 | |
| 91 | if(use_fixed_storage(m_Size)) |
| 92 | { |
| 93 | |
| 94 | Storage=&m_Storage.m_fixSet[0]; |
| 95 | } |
| 96 | else |
| 97 | { |
| 98 | |
| 99 | m_Storage.m_dynSet=new set_value_type[m_Size]; |
| 100 | Storage=m_Storage.m_dynSet; |
| 101 | } |
| 102 | |
| 103 | |
| 104 | ::std::copy(::boost::begin(Range), ::boost::end(Range), Storage); |
| 105 | ::std::sort(Storage, Storage+m_Size); |
| 106 | } |
| 107 | |
| 108 | |
| 109 | is_any_ofF(const is_any_ofF& Other) : m_Size(Other.m_Size) |
| 110 | { |
| 111 | |
| 112 | m_Storage.m_dynSet=0; |
| 113 | const set_value_type* SrcStorage=0; |
| 114 | set_value_type* DestStorage=0; |
| 115 | |
| 116 | if(use_fixed_storage(m_Size)) |
| |
| 117 | { |
| 118 | |
| 119 | DestStorage=&m_Storage.m_fixSet[0]; |
| 120 | SrcStorage=&Other.m_Storage.m_fixSet[0]; |
| 121 | } |
| 122 | else |
| 123 | { |
| 124 | |
| 125 | m_Storage.m_dynSet=new set_value_type[m_Size]; |
| |
| 126 | DestStorage=m_Storage.m_dynSet; |
| 127 | SrcStorage=Other.m_Storage.m_dynSet; |
| 128 | } |
| 129 | |
| 130 | |
| 131 | ::std::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size); |
| 132 | } |
| 133 | |
| 134 | |
| 135 | ~is_any_ofF() |
| 136 | { |
| 137 | if(!use_fixed_storage(m_Size) && m_Storage.m_dynSet!=0) |
| |
| 138 | { |
| 139 | delete [] m_Storage.m_dynSet; |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | |
| 144 | is_any_ofF& operator=(const is_any_ofF& Other) |
| 145 | { |
| 146 | |
| 147 | if(this==&Other) return *this; |
| 148 | |
| 149 | |
| 150 | const set_value_type* SrcStorage; |
| 151 | set_value_type* DestStorage; |
| 152 | |
| 153 | if(use_fixed_storage(Other.m_Size)) |
| 154 | { |
| 155 | |
| 156 | DestStorage=&m_Storage.m_fixSet[0]; |
| 157 | SrcStorage=&Other.m_Storage.m_fixSet[0]; |
| 158 | |
| 159 | |
| 160 | if(!use_fixed_storage(m_Size) && m_Storage.m_dynSet!=0) |
| 161 | { |
| 162 | delete [] m_Storage.m_dynSet; |
| 163 | } |
| 164 | |
| 165 | |
| 166 | m_Size=Other.m_Size; |
| 167 | } |
| 168 | else |
| 169 | { |
| 170 | |
| 171 | SrcStorage=Other.m_Storage.m_dynSet; |
| 172 | |
| 173 | |
| 174 | if(use_fixed_storage(m_Size)) |
| 175 | { |
| 176 | |
| 177 | set_value_type* pTemp=new set_value_type[Other.m_Size]; |
| 178 | DestStorage=pTemp; |
| 179 | m_Storage.m_dynSet=pTemp; |
| 180 | m_Size=Other.m_Size; |
| 181 | } |
| 182 | else |
| 183 | { |
| 184 | |
| 185 | if(m_Storage.m_dynSet!=0 && m_Size>=Other.m_Size && m_Size<Other.m_Size*2) |
| 186 | { |
| 187 | |
| 188 | DestStorage=m_Storage.m_dynSet; |
| 189 | m_Size=Other.m_Size; |
| 190 | } |
| 191 | else |
| 192 | { |
| 193 | |
| 194 | set_value_type* pTemp=new set_value_type[Other.m_Size]; |
| 195 | DestStorage=pTemp; |
| 196 | |
| 197 | |
| 198 | if(m_Storage.m_dynSet!=0) |
| 199 | { |
| 200 | delete [] m_Storage.m_dynSet; |
| 201 | } |
| 202 | |
| 203 | m_Storage.m_dynSet=pTemp; |
| 204 | |
| 205 | m_Size=Other.m_Size; |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | |
| 211 | ::std::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size); |
| 212 | |
| 213 | return *this; |
| 214 | } |
| 215 | |
| 216 | |
| 217 | template<typename Char2T> |
| 218 | bool operator()( Char2T Ch ) const |
| 219 | { |
| 220 | const set_value_type* Storage= |
| 221 | (use_fixed_storage(m_Size)) |
| 222 | ? &m_Storage.m_fixSet[0] |
| 223 | : m_Storage.m_dynSet; |
| 224 | |
| 225 | return ::std::binary_search(Storage, Storage+m_Size, Ch); |
| 226 | } |
| 227 | private: |
| 228 | |
| 229 | static bool use_fixed_storage(std::size_t size) |
| 230 | { |
| 231 | return size<=sizeof(set_value_type*)*2; |
| 232 | } |
| 233 | |
| 234 | |
| 235 | private: |
| 236 | |
| 237 | |
| 238 | union |
| 239 | { |
| 240 | set_value_type* m_dynSet; |
| 241 | set_value_type m_fixSet[sizeof(set_value_type*)*2]; |
| 242 | } |
| 243 | m_Storage; |
| 244 | |
| 245 | |
| 246 | ::std::size_t m_Size; |
| 247 | }; |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | template<typename CharT> |
| 255 | struct is_from_rangeF : |
| 256 | public predicate_facade< is_from_rangeF<CharT> > |
| 257 | { |
| 258 | |
| 259 | typedef bool result_type; |
| 260 | |
| 261 | |
| 262 | is_from_rangeF( CharT From, CharT To ) : m_From(From), m_To(To) {} |
| 263 | |
| 264 | |
| 265 | template<typename Char2T> |
| 266 | bool operator()( Char2T Ch ) const |
| 267 | { |
| 268 | return ( m_From <= Ch ) && ( Ch <= m_To ); |
| 269 | } |
| 270 | |
| 271 | private: |
| 272 | CharT m_From; |
| 273 | CharT m_To; |
| 274 | }; |
| 275 | |
| 276 | |
| 277 | template<typename Pred1T, typename Pred2T> |
| 278 | struct pred_andF : |
| 279 | public predicate_facade< pred_andF<Pred1T,Pred2T> > |
| 280 | { |
| 281 | public: |
| 282 | |
| 283 | |
| 284 | typedef bool result_type; |
| 285 | |
| 286 | |
| 287 | pred_andF( Pred1T Pred1, Pred2T Pred2 ) : |
| 288 | m_Pred1(Pred1), m_Pred2(Pred2) {} |
| 289 | |
| 290 | |
| 291 | template<typename CharT> |
| 292 | bool operator()( CharT Ch ) const |
| 293 | { |
| 294 | return m_Pred1(Ch) && m_Pred2(Ch); |
| 295 | } |
| 296 | |
| 297 | private: |
| 298 | Pred1T m_Pred1; |
| 299 | Pred2T m_Pred2; |
| 300 | }; |
| 301 | |
| 302 | |
| 303 | template<typename Pred1T, typename Pred2T> |
| 304 | struct pred_orF : |
| 305 | public predicate_facade< pred_orF<Pred1T,Pred2T> > |
| 306 | { |
| 307 | public: |
| 308 | |
| 309 | typedef bool result_type; |
| 310 | |
| 311 | |
| 312 | pred_orF( Pred1T Pred1, Pred2T Pred2 ) : |
| 313 | m_Pred1(Pred1), m_Pred2(Pred2) {} |
| 314 | |
| 315 | |
| 316 | template<typename CharT> |
| 317 | bool operator()( CharT Ch ) const |
| 318 | { |
| 319 | return m_Pred1(Ch) || m_Pred2(Ch); |
| 320 | } |
| 321 | |
| 322 | private: |
| 323 | Pred1T m_Pred1; |
| 324 | Pred2T m_Pred2; |
| 325 | }; |
| 326 | |
| 327 | |
| 328 | template< typename PredT > |
| 329 | struct pred_notF : |
| 330 | public predicate_facade< pred_notF<PredT> > |
| 331 | { |
| 332 | public: |
| 333 | |
| 334 | typedef bool result_type; |
| 335 | |
| 336 | |
| 337 | pred_notF( PredT Pred ) : m_Pred(Pred) {} |
| 338 | |
| 339 | |
| 340 | template<typename CharT> |
| 341 | bool operator()( CharT Ch ) const |
| 342 | { |
| 343 | return !m_Pred(Ch); |
| 344 | } |
| 345 | |
| 346 | private: |
| 347 | PredT m_Pred; |
| 348 | }; |
| 349 | |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | |
| 355 | #endif // BOOST_STRING_CLASSIFICATION_DETAIL_HPP |