26#ifndef NFD_TOOLS_NFDC_FORMAT_HELPERS_HPP
27#define NFD_TOOLS_NFDC_FORMAT_HELPERS_HPP
103 Separator(std::string_view first, std::string_view subsequent);
115 const std::string m_first;
116 const std::string m_subsequent;
149 ItemAttributes(
bool wantMultiLine =
false,
int maxAttributeWidth = 0);
167 const bool m_wantMultiLine;
168 const int m_maxAttributeWidth;
199template<
typename DurationT>
207 return isLong ?
"nanoseconds" :
"ns";
214 return isLong ?
"microseconds" :
"us";
221 return isLong ?
"milliseconds" :
"ms";
228 return isLong ?
"seconds" :
"s";
235 return isLong ?
"minutes" :
"m";
242 return isLong ?
"hours" :
"h";
249 return isLong ?
"days" :
"d";
254template<
typename OutputPrecision>
258 return std::to_string(time::duration_cast<OutputPrecision>(d).count()) +
259 (isLong ?
" " :
"") + detail::getTimeUnit<OutputPrecision>(isLong);
Print attributes of an item.
Attribute operator()(const std::string &attribute)
friend std::ostream & operator<<(std::ostream &os, const ItemAttributes::Attribute &attr)
Print different string on first and subsequent usage.
friend std::ostream & operator<<(std::ostream &os, Separator &sep)
std::string getTimeUnit(bool isLong)
std::string getTimeUnit< time::microseconds >(bool isLong)
std::string getTimeUnit< time::days >(bool isLong)
std::string getTimeUnit< time::seconds >(bool isLong)
std::string getTimeUnit< time::milliseconds >(bool isLong)
std::string getTimeUnit< time::nanoseconds >(bool isLong)
std::string getTimeUnit< time::hours >(bool isLong)
std::string getTimeUnit< time::minutes >(bool isLong)
std::string formatTimestamp(time::system_clock::time_point t)
std::ostream & operator<<(std::ostream &os, const Spaces &spaces)
std::string formatDuration(time::nanoseconds d, bool isLong=false)
Print boolean as 'on' or 'off'.
Print a number of whitespaces.
int nSpaces
number of spaces; print nothing if negative
Print boolean as 'yes' or 'no'.