MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / write_padded

Method write_padded

extlibs/fmt/include/fmt/format.h:1677–1698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1675 // <left-padding><value><right-padding>
1676 // where <value> is written by f(it).
1677 template <typename F> void write_padded(const format_specs& specs, F&& f) {
1678 // User-perceived width (in code points).
1679 unsigned width = to_unsigned(specs.width);
1680 size_t size = f.size(); // The number of code units.
1681 size_t num_code_points = width != 0 ? f.width() : size;
1682 if (width <= num_code_points) return f(reserve(size));
1683 size_t padding = width - num_code_points;
1684 size_t fill_size = specs.fill.size();
1685 auto&& it = reserve(size + padding * fill_size);
1686 if (specs.align == align::right) {
1687 it = fill(it, padding, specs.fill);
1688 f(it);
1689 } else if (specs.align == align::center) {
1690 std::size_t left_padding = padding / 2;
1691 it = fill(it, left_padding, specs.fill);
1692 f(it);
1693 it = fill(it, padding - left_padding, specs.fill);
1694 } else {
1695 f(it);
1696 it = fill(it, padding, specs.fill);
1697 }
1698 }
1699
1700 void write(int value) { write_decimal(value); }
1701 void write(long value) { write_decimal(value); }

Callers 1

write_charMethod · 0.80

Calls 4

fillFunction · 0.85
reserveFunction · 0.70
sizeMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected