MCPcopy Create free account
hub / github.com/duckdb/duckdb / RenderAlignedValue

Method RenderAlignedValue

tools/shell/shell_renderer.cpp:18–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18void PrintStream::RenderAlignedValue(const char *str, idx_t str_len, idx_t width, TextAlignment alignment) {
19 idx_t w = width;
20 idx_t n = state.RenderLength(str, str_len);
21 idx_t space_count = w < n ? 0 : w - n;
22 idx_t lspace;
23 idx_t rspace;
24 if (alignment == TextAlignment::LEFT) {
25 lspace = 0;
26 rspace = space_count;
27 } else if (alignment == TextAlignment::RIGHT) {
28 lspace = space_count;
29 rspace = 0;
30 } else {
31 lspace = space_count / 2;
32 rspace = (space_count + 1) / 2;
33 }
34 if (lspace > 0) {
35 Print(string(lspace, ' '));
36 }
37 Print(duckdb::string_t(str, str_len));
38 if (rspace > 0) {
39 Print(string(rspace, ' '));
40 }
41}
42
43void PrintStream::RenderAlignedValue(const string &str, idx_t width, TextAlignment alignment) {
44 RenderAlignedValue(str.c_str(), str.size(), width, alignment);

Callers 6

RenderRowMethod · 0.80
RenderHeaderMethod · 0.80
RenderHeaderMethod · 0.80
RenderHeaderMethod · 0.80
RenderHeaderMethod · 0.80
RenderHeaderMethod · 0.80

Calls 6

RenderLengthMethod · 0.80
c_strMethod · 0.80
string_tClass · 0.50
sizeMethod · 0.45
GetDataMethod · 0.45
GetSizeMethod · 0.45

Tested by

no test coverage detected