ChimeraTK-DeviceAccess-DoocsBackend 01.11.02
Loading...
Searching...
No Matches
StringUtility.cc
Go to the documentation of this file.
1#include "StringUtility.h"
2
3#include <boost/algorithm/string.hpp>
4
5/********************************************************************************************************************/
6
7namespace 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
std::pair< bool, std::string > endsWith(std::string const &s, const std::vector< std::string > &patterns)
long slashes(const std::string &s)