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;
199 template<
typename DurationT>
205 getTimeUnit<time::nanoseconds>(
bool isLong)
207 return isLong ?
"nanoseconds" :
"ns";
212 getTimeUnit<time::microseconds>(
bool isLong)
214 return isLong ?
"microseconds" :
"us";
219 getTimeUnit<time::milliseconds>(
bool isLong)
221 return isLong ?
"milliseconds" :
"ms";
226 getTimeUnit<time::seconds>(
bool isLong)
228 return isLong ?
"seconds" :
"s";
233 getTimeUnit<time::minutes>(
bool isLong)
235 return isLong ?
"minutes" :
"m";
240 getTimeUnit<time::hours>(
bool isLong)
242 return isLong ?
"hours" :
"h";
247 getTimeUnit<time::days>(
bool isLong)
249 return isLong ?
"days" :
"d";
254 template<
typename OutputPrecision>
258 return std::to_string(time::duration_cast<OutputPrecision>(d).count()) +
259 (isLong ?
" " :
"") + detail::getTimeUnit<OutputPrecision>(isLong);
Print attributes of an item.
ItemAttributes(bool wantMultiLine=false, int maxAttributeWidth=0)
Constructor.
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.
Separator(std::string_view first, std::string_view subsequent)
friend std::ostream & operator<<(std::ostream &os, Separator &sep)
std::string getTimeUnit(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'.