PageRenderTime 26ms CodeModel.GetById 19ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/cln-1.3.2/src/real/format-output/cl_fmt_paddedstring.cc

#
C++ | 30 lines | 18 code | 8 blank | 4 comment | 2 complexity | ce1ca21eadf7ce7a19d7f87a8d3af9b1 MD5 | raw file
Possible License(s): GPL-2.0
 1// format_padded_string().
 2
 3// General includes.
 4#include "base/cl_sysdep.h"
 5
 6// Specification.
 7#include "real/format-output/cl_format.h"
 8
 9
10// Implementation.
11
12#include <cstring>
13
14namespace cln {
15
16void format_padded_string (std::ostream& stream, sintL mincol, sintL colinc, sintL minpad, char padchar, bool padleftflag, const char * str)
17{
18	var sintL need = ::strlen(str) + minpad; // so viele Zeichen mindestens
19	var uintL auxpad = (need < mincol
20			    ? ceiling((uintL)(mincol - need), colinc) * colinc
21			    : 0
22			   );
23	if (!padleftflag)
24		fprint(stream,str);
25	format_padding(stream,minpad+auxpad,padchar);
26	if (padleftflag)
27		fprint(stream,str);
28}
29
30}  // namespace cln