Moved trim_zeroes to libslic3r utils.

This commit is contained in:
Joseph Lenox 2018-07-15 10:10:42 -05:00
parent ee71f8b8f8
commit 49f123ca20
4 changed files with 10 additions and 9 deletions

View File

@ -148,14 +148,7 @@ std::vector<wxString> open_model(wxWindow* parent, wxWindow* top) {
return tmp;
}
/// Remove extra zeroes generated from std::to_string on doubles
std::string trim_zeroes(std::string in) {
std::string result {""};
std::regex strip_zeroes("(0*)$");
std::regex_replace (std::back_inserter(result), in.begin(), in.end(), strip_zeroes, "");
if (result.back() == '.') result.append("0");
return result;
}
wxString trim_zeroes(wxString in) { return wxString(trim_zeroes(in.ToStdString())); }

View File

@ -155,7 +155,6 @@ inline Slic3r::Point new_scale(const wxPoint& p) { return Slic3r::Point::new_sca
/// Singleton for UI settings.
extern std::unique_ptr<Settings> ui_settings;
std::string trim_zeroes(std::string in);
wxString trim_zeroes(wxString in);

View File

@ -50,3 +50,11 @@ split_at_regex(const std::string& input, const std::string& regex) {
last;
return {first, last};
}
/// Remove extra zeroes generated from std::to_string on doubles
std::string trim_zeroes(std::string in) {
std::string result {""};
std::regex strip_zeroes("(0*)$");
std::regex_replace (std::back_inserter(result), in.begin(), in.end(), strip_zeroes, "");
if (result.back() == '.') result.append("0");
return result;
}

View File

@ -9,5 +9,6 @@
/// Separate a string based on some regular expression string.
std::vector<std::string>
split_at_regex(const std::string& input, const std::string& regex);
std::string trim_zeroes(std::string in);
#endif // UTILS_HPP