mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Plumbing: Move basic format() calls to templates
- format() is already using variadic templates, make use of a plain one to remove more code bloat.
This commit is contained in:
parent
57133140fb
commit
2e3b8c8c2a
2 changed files with 8 additions and 45 deletions
40
src/text.cpp
40
src/text.cpp
|
@ -686,46 +686,6 @@ const std::string format (const char* value)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
const std::string format (char value)
|
|
||||||
{
|
|
||||||
std::stringstream s;
|
|
||||||
s << value;
|
|
||||||
return s.str ();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
const std::string format (int value)
|
|
||||||
{
|
|
||||||
std::stringstream s;
|
|
||||||
s << value;
|
|
||||||
return s.str ();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
const std::string format (unsigned int value)
|
|
||||||
{
|
|
||||||
std::stringstream s;
|
|
||||||
s << value;
|
|
||||||
return s.str ();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
const std::string format (unsigned long value)
|
|
||||||
{
|
|
||||||
std::stringstream s;
|
|
||||||
s << value;
|
|
||||||
return s.str ();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
const std::string format (long value)
|
|
||||||
{
|
|
||||||
std::stringstream s;
|
|
||||||
s << value;
|
|
||||||
return s.str ();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
const std::string formatHex (int value)
|
const std::string formatHex (int value)
|
||||||
{
|
{
|
||||||
|
|
13
src/text.h
13
src/text.h
|
@ -61,17 +61,20 @@ int strippedLength (const std::string&);
|
||||||
const std::string obfuscateText (const std::string&);
|
const std::string obfuscateText (const std::string&);
|
||||||
const std::string format (std::string&);
|
const std::string format (std::string&);
|
||||||
const std::string format (const char*);
|
const std::string format (const char*);
|
||||||
const std::string format (char);
|
|
||||||
const std::string format (int);
|
|
||||||
const std::string format (unsigned int);
|
|
||||||
const std::string format (long);
|
|
||||||
const std::string format (unsigned long);
|
|
||||||
const std::string formatHex (int);
|
const std::string formatHex (int);
|
||||||
const std::string format (float, int, int);
|
const std::string format (float, int, int);
|
||||||
const std::string format (double, int, int);
|
const std::string format (double, int, int);
|
||||||
const std::string format (double);
|
const std::string format (double);
|
||||||
void replace_positional (std::string&, const std::string&, const std::string&);
|
void replace_positional (std::string&, const std::string&, const std::string&);
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
const std::string format (T value)
|
||||||
|
{
|
||||||
|
std::stringstream s;
|
||||||
|
s << value;
|
||||||
|
return s.str ();
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
const std::string format (int fmt_num, const std::string& fmt, T arg)
|
const std::string format (int fmt_num, const std::string& fmt, T arg)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue