mirror of
https://github.com/polybar/polybar.git
synced 2026-02-20 15:05:55 +00:00
feat(string_util): Custom stringstream
This commit is contained in:
@ -161,7 +161,7 @@ namespace string_util {
|
||||
*/
|
||||
vector<string>& split_into(const string& s, char delim, vector<string>& container) {
|
||||
string str;
|
||||
stringstream buffer(s);
|
||||
std::stringstream buffer(s);
|
||||
while (getline(buffer, str, delim)) {
|
||||
container.emplace_back(str);
|
||||
}
|
||||
@ -191,7 +191,7 @@ namespace string_util {
|
||||
* Create a floating point string
|
||||
*/
|
||||
string floating_point(double value, size_t precision, bool fixed, const string& locale) {
|
||||
stringstream ss;
|
||||
std::stringstream ss;
|
||||
ss.imbue(!locale.empty() ? std::locale(locale.c_str()) : std::locale::classic());
|
||||
ss << std::fixed << std::setprecision(precision) << value;
|
||||
return fixed ? ss.str() : replace(ss.str(), ".00", "");
|
||||
@ -225,18 +225,6 @@ namespace string_util {
|
||||
return floating_point(value, precision, fixed, locale) + " GB";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the resulting string from a ostream/
|
||||
*
|
||||
* Example usage:
|
||||
* @code cpp
|
||||
* string_util::from_stream(stringstream() << ...);
|
||||
* @endcode
|
||||
*/
|
||||
string from_stream(const std::basic_ostream<char>& os) {
|
||||
return dynamic_cast<const stringstream&>(os).str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute string hash
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user