ChimeraTK-DeviceAccess-DoocsBackend  01.09.02
StringUtility.cc
Go to the documentation of this file.
1 #include "StringUtility.h"
2 
3 #include <boost/algorithm/string.hpp>
4 
5 /********************************************************************************************************************/
6 
7 namespace detail {
8 
9  std::pair<bool, std::string> endsWith(std::string const& s, const std::vector<std::string>& patterns) {
10  for(auto& p : patterns) {
11  if(boost::algorithm::ends_with(s, p)) {
12  return std::pair<bool, std::string>{true, p};
13  }
14  }
15  return std::pair<bool, std::string>{false, ""};
16  }
17 
18  /********************************************************************************************************************/
19 
20  long slashes(const std::string& s) {
21  long nSlashes;
22  if(!boost::starts_with(s, "doocs://")) {
23  nSlashes = std::count(s.begin(), s.end(), '/');
24  }
25  else {
26  nSlashes = std::count(s.begin(), s.end(), '/') - 3;
27  }
28  return nSlashes;
29  }
30 
31 } // namespace detail
detail
Definition: StringUtility.h:7
detail::slashes
long slashes(const std::string &s)
Definition: StringUtility.cc:20
detail::endsWith
std::pair< bool, std::string > endsWith(std::string const &s, const std::vector< std::string > &patterns)
Definition: StringUtility.cc:9
StringUtility.h