PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms 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. // General includes.
  3. #include "base/cl_sysdep.h"
  4. // Specification.
  5. #include "real/format-output/cl_format.h"
  6. // Implementation.
  7. #include <cstring>
  8. namespace cln {
  9. void format_padded_string (std::ostream& stream, sintL mincol, sintL colinc, sintL minpad, char padchar, bool padleftflag, const char * str)
  10. {
  11. var sintL need = ::strlen(str) + minpad; // so viele Zeichen mindestens
  12. var uintL auxpad = (need < mincol
  13. ? ceiling((uintL)(mincol - need), colinc) * colinc
  14. : 0
  15. );
  16. if (!padleftflag)
  17. fprint(stream,str);
  18. format_padding(stream,minpad+auxpad,padchar);
  19. if (padleftflag)
  20. fprint(stream,str);
  21. }
  22. } // namespace cln