MCPcopy Create free account
hub / github.com/ablab/spades / WidthHandler

Class WidthHandler

ext/src/cppformat/format.cc:240–264  ·  view source on GitHub ↗

Checks if an argument is a valid printf width specifier and sets left alignment if it is negative.

Source from the content-addressed store, hash-verified

238// Checks if an argument is a valid printf width specifier and sets
239// left alignment if it is negative.
240class WidthHandler : public fmt::internal::ArgVisitor<WidthHandler, unsigned> {
241 private:
242 fmt::FormatSpec &spec_;
243
244 public:
245 explicit WidthHandler(fmt::FormatSpec &spec) : spec_(spec) {}
246
247 unsigned visit_unhandled_arg() {
248 FMT_THROW(fmt::FormatError("width is not integer"));
249 return 0;
250 }
251
252 template <typename T>
253 unsigned visit_any_int(T value) {
254 typedef typename fmt::internal::IntTraits<T>::MainType UnsignedType;
255 UnsignedType width = value;
256 if (fmt::internal::is_negative(value)) {
257 spec_.align_ = fmt::ALIGN_LEFT;
258 width = 0 - width;
259 }
260 if (width > INT_MAX)
261 FMT_THROW(fmt::FormatError("number is too big"));
262 return static_cast<unsigned>(width);
263 }
264};
265
266class PrecisionHandler :
267 public fmt::internal::ArgVisitor<PrecisionHandler, int> {

Callers 1

parse_headerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected