1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 21:01:16 +02:00

Formatting

This commit is contained in:
Eelco Dolstra 2020-10-07 16:33:19 +02:00
parent 5257a2559e
commit 27ca87c46a
3 changed files with 32 additions and 28 deletions

View file

@ -76,11 +76,11 @@ template <class T>
struct yellowtxt
{
yellowtxt(const T &s) : value(s) {}
const T &value;
const T & value;
};
template <class T>
std::ostream& operator<<(std::ostream &out, const yellowtxt<T> &y)
std::ostream & operator<<(std::ostream & out, const yellowtxt<T> & y)
{
return out << ANSI_YELLOW << y.value << ANSI_NORMAL;
}
@ -88,12 +88,12 @@ std::ostream& operator<<(std::ostream &out, const yellowtxt<T> &y)
template <class T>
struct normaltxt
{
normaltxt(const T &s) : value(s) {}
const T &value;
normaltxt(const T & s) : value(s) {}
const T & value;
};
template <class T>
std::ostream& operator<<(std::ostream &out, const normaltxt<T> &y)
std::ostream & operator<<(std::ostream & out, const normaltxt<T> & y)
{
return out << ANSI_NORMAL << y.value;
}
@ -101,26 +101,30 @@ std::ostream& operator<<(std::ostream &out, const normaltxt<T> &y)
class hintformat
{
public:
hintformat(const string &format) :fmt(format)
hintformat(const string & format) : fmt(format)
{
fmt.exceptions(boost::io::all_error_bits ^
fmt.exceptions(boost::io::all_error_bits ^
boost::io::too_many_args_bit ^
boost::io::too_few_args_bit);
}
hintformat(const hintformat &hf)
: fmt(hf.fmt)
{}
hintformat(const hintformat & hf)
: fmt(hf.fmt)
{ }
hintformat(format && fmt)
: fmt(std::move(fmt))
{ }
template<class T>
hintformat& operator%(const T &value)
hintformat & operator%(const T & value)
{
fmt % yellowtxt(value);
return *this;
}
template<class T>
hintformat& operator%(const normaltxt<T> &value)
hintformat & operator%(const normaltxt<T> & value)
{
fmt % value.value;
return *this;
@ -135,7 +139,7 @@ private:
format fmt;
};
std::ostream& operator<<(std::ostream &os, const hintformat &hf);
std::ostream & operator<<(std::ostream & os, const hintformat & hf);
template<typename... Args>
inline hintformat hintfmt(const std::string & fs, const Args & ... args)