Project

General

Profile

cetlib-master.patch

Patrick Gartung, 01/25/2016 05:06 PM

View differences:

cetlib/CMakeLists.txt
45 45
  search_path.cc
46 46
  simple_stats.cc
47 47
  split_path.cc
48
  split_by_regex.cc
48 49
  LIBRARIES
49 50
  ${Boost_FILESYSTEM_LIBRARY}
50 51
  ${Boost_REGEX_LIBRARY}
cetlib/split_by_regex.cc
1
#include <algorithm>
2
#include <regex>
3

  
4
namespace cet {
5

  
6
  std::vector<std::string> split_by_regex (std::string const& str,
7
                                           std::string const& delimSet )
8
  {
9
    std::vector<std::string> tokens;
10
    std::copy( std::sregex_token_iterator(str.begin(),
11
                                          str.end(),
12
                                          std::regex( delimSet ),
13
                                          -1),
14
               std::sregex_token_iterator(),
15
               std::back_inserter( tokens ) );
16
    return tokens;
17
  }
18

  
19
}
20

  
cetlib/split_by_regex.h
26 26
//
27 27
// ======================================================================
28 28

  
29
#include <algorithm>
30
#include <regex>
29
#include <vector>
30
#include <string>
31 31

  
32 32
namespace cet {
33 33

  
34
  inline
35 34
  std::vector<std::string> split_by_regex (std::string const& str,
36
                                           std::string const& delimSet )
37
  {
38
    std::vector<std::string> tokens;
39
    std::copy( std::sregex_token_iterator(str.begin(),
40
                                          str.end(),
41
                                          std::regex( delimSet ),
42
                                          -1),
43
               std::sregex_token_iterator(),
44
               std::back_inserter( tokens ) );
45
    return tokens;
46
  }
35
                                           std::string const& delimSet );
47 36

  
48 37
}
49 38