6#include <boost/format.hpp>
10extern template class boost::basic_format<char>;
15std::string getStackTrace();
27 Magenta(
const T & s) : value(s) {}
32std::ostream & operator<<(std::ostream & out,
const Magenta<T> & y)
34 return out << ANSI_MAGENTA << y.value << ANSI_NORMAL;
45 Uncolored(
const T & s) : value(s) {}
50std::ostream & operator<<(std::ostream & out,
const Uncolored<T> & y)
52 return out << ANSI_NORMAL << y.value;
55namespace fmt_internal {
63 boost::io::all_error_bits ^ boost::io::too_many_args_bit ^ boost::io::too_few_args_bit
76 template<
typename...
Args>
77 HintFmt(boost::format && fmt,
const Args &... args) : fmt(std::move(fmt))
84 HintFmt & operator%(
const T & value)
97 boost::format into_format()
99 return std::move(fmt);
127inline std::string
fmt(
const std::string & s)
132inline std::string fmt(
const char * s)
137template<
typename... Args>
138inline std::string
fmt(
const std::string & fs,
const Args &... args)
141 fmt_internal::setExceptions(f);
144}
catch (boost::io::format_error & fe) {
147 std::cerr <<
"nix::fmt threw format error. Original format string: '";
148 std::cerr << fs <<
"'; number of arguments: " <<
sizeof...(args) <<
"\n";
168 HintFmt(
const std::string & literal);
173 template<
typename...
Args>
176 try : fmt(fmt_internal::
HintFmt(boost::format(format), args...).into_format())
178 if (this->fmt.remaining_args() != 0) {
180 std::cerr <<
"HintFmt received incorrect number of format args. Original format string: '";
181 std::cerr << format <<
"'; number of arguments: " << sizeof...(args) <<
"\n";
185 }
catch (boost::io::format_error & ex) {
187 std::cerr <<
"HintFmt received incorrect format string. Original format string: '";
188 std::cerr << format <<
"'; number of arguments: " <<
sizeof...(args) <<
"\n";
192 HintFmt(
const HintFmt & hf) : fmt(hf.fmt) {}
194 HintFmt & operator=(HintFmt
const & rhs) =
default;
196 std::string str()
const
203extern template HintFmt::HintFmt(
const std::string &,
const Uncolored<std::string> &s);
204extern template HintFmt::HintFmt(
const std::string &,
const std::string &s);
205extern template HintFmt::HintFmt(
const std::string &,
const uint64_t &,
const char *
const &);
207std::ostream & operator<<(std::ostream & os,
const HintFmt & hf);
Some ANSI escape sequences.
HintFmt(const std::string &format, const Args &... args)
Definition fmt.hh:174
HintFmt(const std::string &literal)
Definition fmt.cc:18
void setExceptions(boost::format &fmt)
Definition fmt.hh:60
std::string fmt(const std::string &s)
Definition fmt.hh:127