Compute left and right padding for content within a field width.
Synopsis
Declared in <bslfmt_padutil.h>
static
void
computePadding(
std::ptrdiff_t* leftPadding,
std::ptrdiff_t* rightPadding,
NumericValue const& widthValue,
std::ptrdiff_t contentWidth,
Alignment alignment,
Alignment defaultAlign = Enums::e_ALIGN_LEFT);
Description
Compute the left and right padding values needed to format content with the specified contentWidth within a field of the width specified by widthValue using the specified alignment. If Enums::e_ALIGN_DEFAULT is passed to alignment, use the specified defaultAlign instead. Load the computed padding values into the specified leftPadding and rightPadding. If the category of widthValue is not e_VALUE or if the value indicated by widthValue is less than contentWidth, the padding is zero. The behavior is undefined if contentWidth specifies a negative width, or if defaultAlign specifies e_ALIGN_DEFAULT.
Parameters
Name |
Description |
leftPadding |
receives the number of filler repetitions on the left |
rightPadding |
receives the number of filler repetitions on the right |
widthValue |
field width specification |
contentWidth |
width of the content being formatted |
alignment |
desired alignment of the content within the field |
defaultAlign |
alignment used when |
Created with MrDocs