calc: Migration to libshared

This commit is contained in:
Paul Beckingham
2016-12-06 07:23:25 -05:00
parent 8a43f4902d
commit 060787a5db
4 changed files with 5 additions and 67 deletions

View File

@@ -377,59 +377,3 @@ void replace_positional (
}
////////////////////////////////////////////////////////////////////////////////
std::string leftJustify (const int input, const int width)
{
std::stringstream s;
s << input;
std::string output = s.str ();
return output + std::string (width - output.length (), ' ');
}
////////////////////////////////////////////////////////////////////////////////
std::string leftJustify (const std::string& input, const int width)
{
auto len = static_cast <int> (utf8_text_width (input));
if (len == width)
return input;
if (len > width)
return input.substr (0, width);
return input + std::string (width - utf8_text_width (input), ' ');
}
////////////////////////////////////////////////////////////////////////////////
std::string rightJustifyZero (const int input, const int width)
{
std::stringstream s;
s << std::setw (width) << std::setfill ('0') << input;
return s.str ();
}
////////////////////////////////////////////////////////////////////////////////
std::string rightJustify (const int input, const int width)
{
std::stringstream s;
s << std::setw (width) << std::setfill (' ') << input;
return s.str ();
}
////////////////////////////////////////////////////////////////////////////////
std::string rightJustify (const std::string& input, const int width)
{
auto len = static_cast <int> (utf8_text_width (input));
if (len == width)
return input;
if (len > width)
return input.substr (0, width);
return ((width > len)
? std::string (width - len, ' ')
: "")
+ input;
}
////////////////////////////////////////////////////////////////////////////////