2016-05-31 03:58:58 +00:00
|
|
|
#pragma once
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
#include <sstream>
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
#include "common.hpp"
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
namespace string_util {
|
2016-10-29 04:48:51 +00:00
|
|
|
/**
|
|
|
|
* Hash type
|
|
|
|
*/
|
|
|
|
using hash_type = unsigned long;
|
|
|
|
|
2016-11-02 19:22:45 +00:00
|
|
|
bool contains(const string& haystack, const string& needle);
|
|
|
|
string upper(const string& s);
|
|
|
|
string lower(const string& s);
|
|
|
|
bool compare(const string& s1, const string& s2);
|
2016-12-04 03:11:47 +00:00
|
|
|
string replace(const string& haystack, const string& needle, const string& reply, size_t start = 0,
|
2016-12-04 03:03:17 +00:00
|
|
|
size_t end = string::npos);
|
2016-12-04 03:11:47 +00:00
|
|
|
string replace_all(const string& haystack, const string& needle, const string& reply, size_t start = 0,
|
2016-12-04 03:03:17 +00:00
|
|
|
size_t end = string::npos);
|
2016-11-02 19:22:45 +00:00
|
|
|
string squeeze(const string& haystack, char needle);
|
|
|
|
string strip(const string& haystack, char needle);
|
|
|
|
string strip_trailing_newline(const string& haystack);
|
|
|
|
string ltrim(const string& haystack, char needle);
|
|
|
|
string rtrim(const string& haystack, char needle);
|
|
|
|
string trim(const string& haystack, char needle);
|
2016-11-27 00:32:21 +00:00
|
|
|
string join(const vector<string>& strs, const string& delim);
|
2016-11-25 12:55:15 +00:00
|
|
|
vector<string>& split_into(const string& s, char delim, vector<string>& container);
|
2016-11-02 19:22:45 +00:00
|
|
|
vector<string> split(const string& s, char delim);
|
2016-11-25 12:55:15 +00:00
|
|
|
size_t find_nth(const string& haystack, size_t pos, const string& needle, size_t nth);
|
|
|
|
string floatval(float value, int decimals = 2, bool fixed = false, const string& locale = "");
|
|
|
|
string filesize(unsigned long long bytes, int decimals = 2, bool fixed = false, const string& locale = "");
|
2016-11-02 19:22:45 +00:00
|
|
|
string from_stream(const std::basic_ostream<char>& os);
|
2016-11-25 12:55:15 +00:00
|
|
|
hash_type hash(const string& src);
|
2016-05-19 14:41:06 +00:00
|
|
|
}
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|