btllib: include/btllib/util.hpp Source File

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
48 ltrim(btllib::CString& s);
49
56void
57rtrim(std::string& s);
58void
59 rtrim(btllib::CString& s);
60
67void
68trim(std::string& s);
69void
70 trim(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
btllib
Definition aahash.hpp:12
btllib::endswith
bool endswith(std::string s, std::string suffix)
btllib::join
std::string join(const std::vector< std::string > &s, const std::string &delim)
btllib::trim
void trim(std::string &s)
btllib::calc_phred_avg
double calc_phred_avg(const std::string &qual, size_t start_pos=0, size_t len=0)
btllib::get_dirname
std::string get_dirname(const std::string &path)
btllib::get_basename
std::string get_basename(const std::string &path)
btllib::split
std::vector< std::string > split(const std::string &s, const std::string &delim)
btllib::rtrim
void rtrim(std::string &s)
btllib::startswith
bool startswith(std::string s, std::string prefix)
btllib::ltrim
void ltrim(std::string &s)
btllib::sum_phred
double sum_phred(const std::string &qual, size_t start_pos=0, size_t len=0)