| 16 | } |
| 17 | |
| 18 | void 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 | |
| 43 | void PrintStream::RenderAlignedValue(const string &str, idx_t width, TextAlignment alignment) { |
| 44 | RenderAlignedValue(str.c_str(), str.size(), width, alignment); |
no test coverage detected