btllib
Loading...
Searching...
No Matches
util.hpp
1
4#ifndef BTLLIB_UTIL_HPP
5#define BTLLIB_UTIL_HPP
6
7#include "btllib/cstring.hpp"
8
9#include <condition_variable>
10#include <mutex>
11#include <string>
12#include <vector>
13
14namespace btllib {
15
25std::vector<std::string>
26split(const std::string& s, const std::string& delim);
27
36std::string
37join(const std::vector<std::string>& s, const std::string& delim);
38
45void
46ltrim(std::string& s);
47void
48ltrim(btllib::CString& s);
49
56void
57rtrim(std::string& s);
58void
59rtrim(btllib::CString& s);
60
67void
68trim(std::string& s);
69void
70trim(btllib::CString& s);
71
79bool
80startswith(std::string s, std::string prefix);
81
89bool
90endswith(std::string s, std::string suffix);
91
100std::string
101get_basename(const std::string& path);
102
111std::string
112get_dirname(const std::string& path);
113
124double
125sum_phred(const std::string& qual, size_t start_pos = 0, size_t len = 0);
126
138double
139calc_phred_avg(const std::string& qual, size_t start_pos = 0, size_t len = 0);
140
141// This exists in C++20, but we don't support that yet
143class Barrier
144{
145
146public:
147 Barrier(const unsigned count)
148 : counter_default(count)
149 {
150 }
151
152 void wait();
153
154private:
155 std::mutex m;
156 std::condition_variable cv;
157 unsigned counter{ 0 };
158 unsigned counter_default;
159 unsigned waiting{ 0 };
160};
162
163} // namespace btllib
164
165#endif
Definition aahash.hpp:12
bool endswith(std::string s, std::string suffix)
std::string join(const std::vector< std::string > &s, const std::string &delim)
void trim(std::string &s)
double calc_phred_avg(const std::string &qual, size_t start_pos=0, size_t len=0)
std::string get_dirname(const std::string &path)
std::string get_basename(const std::string &path)
std::vector< std::string > split(const std::string &s, const std::string &delim)
void rtrim(std::string &s)
bool startswith(std::string s, std::string prefix)
void ltrim(std::string &s)
double sum_phred(const std::string &qual, size_t start_pos=0, size_t len=0)