Commit f2aeeaac authored by Alexander Lapshin's avatar Alexander Lapshin

+ new text methods

parent 3a194635
......@@ -57,7 +57,8 @@ static std::string ToStr(const double value, const int precision = 0)
if (precision) {
ss << std::setprecision(precision);
}else {
}
else {
ss << std::setprecision(std::numeric_limits<double>::digits10 + 2);
}
......@@ -447,3 +448,31 @@ bool in_array(const std::vector<T>& src, T subject)
{
return std::find(std::begin(src), std::end(src), subject) != std::end(src);
}
inline bool substring_between(
const std::string& s,
const std::string& start_delim,
const std::string& stop_delim,
std::string& result)
{
const auto first_delim_pos = s.find(start_delim);
if (first_delim_pos == std::string::npos) {
return false;
}
const auto end_pos_of_first_delim = first_delim_pos + start_delim.length();
if (end_pos_of_first_delim == std::string::npos) {
return false;
}
unsigned last_delim_pos = s.find_first_of(stop_delim, end_pos_of_first_delim);
if (last_delim_pos == std::string::npos) {
return false;
}
result = s.substr(end_pos_of_first_delim, last_delim_pos - end_pos_of_first_delim);
return true;
}
......@@ -493,3 +493,12 @@ inline std::string get_current_time(const std::string& format)
return ss.str();
}
inline TimeJD get_current_time()
{
TimeGD now;
const auto s_now = get_current_time("%d/%m/%Y %H:%M:%S");
StrToDate(s_now, now);
return now;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment