3 #include <boost/lexical_cast.hpp>
4 #include <boost/tokenizer.hpp>
17 boost::char_separator<char> sep(
"-.");
18 boost::tokenizer<boost::char_separator<char> > tok(filename, sep);
21 std::vector<std::string> tokens;
30 segment = boost::lexical_cast<
int>((*(tokens.rbegin())));
32 catch (boost::bad_lexical_cast
const&)
34 std::cout <<
"Cannot extract segment number from filename "
35 << filename << std::endl;
36 std::cout <<
"Segment string after parsing: input string "
38 <<
" is not valid segment number" << std::endl;
39 std::cout <<
"filename " << filename <<
" not standard -runnumber-segment.ext"
41 std::cout <<
"using " << segment <<
" as segment number" << std::endl;
47 runnumber = boost::lexical_cast<
int>((*(tokens.rbegin())));
49 catch (boost::bad_lexical_cast
const&)
51 std::cout <<
"Cannot extract run number from filename "
52 << filename << std::endl;
53 std::cout <<
"Segment string after parsing: input string "
55 <<
" is not valid run number" << std::endl;
56 std::cout <<
"filename " << filename <<
" not standard -runnumber-segment.ext"
58 std::cout <<
"returning " << runnumber <<
" as run number" << std::endl;
60 return std::make_pair(runnumber, segment);