Main page.

group_C page.

group_S page.

Text formatting of permzbis.
Version of Saturday 14 September 2024.


Five functions are of interest here:

#1
/* S1 */  std::istream & operator>> 
              (std::istream & text_in, permzbi & p);
These are for input. #1 invokes #2, which few users will need to invoke directly.
#2
/* C3 */  static permzbi permzbi::get_text 
              (std::istream & text_in);
#3
/* C3 */  friend permzbi permzbi::operator""_pz 
              (char const* const s, size_t const);
This is for creating a permzbi in program code.
#4
/* S1 */  std::ostream & operator<< 
              (std::ostream & text_out, permzbi const & p);
These are for output. #4 invokes #5 with default parameters. The user can invoke #5 directly, with non-default parameters, to place text_divider characters periodically between some of the numbers in order to emphasize a grouping. However, the text_divider has no official significance.
#5
/* C2 */  void permzbi::put_text 
              (std::ostream & text_out, 
               int const spacing_a = 0,
               int const spacing_b = 0,
               int const spacing_c = 0) const;

text format for input to
#1 operator>> or #2 get_text
text format for input to
#3 operator""_pz
The only characters permitted are these: The only characters permitted are these:
  • 0 1 2 3 4 5 6 7 8 9
  • : ,
  • whitespace
The permzbi consists of '{' followed by zero or more numbers followed by '}':
  • each number may contain multiple digits, but two consecutive numbers must be separated by at least one character of whitespace
  • there may be whitespace immediately before or after the '{'
  • there may be whitespace immediately before the '}'
  • anywhere after the '{':
    • the text_divider ':' is equivalent to whitespace
    • the comma ',' is equivalent to whitespace
  • anywhere before the '{':
    • the text_divider and the comma are illegal
Any characters after the '}' are not consumed, but remain in the std::istream for the next input operation.
The permzbi consists of zero or more numbers:
  • each number may contain multiple digits, but two consecutive numbers must be separated by at least one character of whitespace
  • the text_divider ':' is equivalent to whitespace
  • the comma ',' is equivalent to whitespace

example of input to
#1 operator>> or #2 get_text
example of string to
#3 operator""_pz
example of output from
#4 operator<< or #5 put_text
{} empty string {}
{ } whitespace only {}
{ 0 } 0 {0}
{3 0 1 2} 3 0 1 2 {3 0 1 2}
{, 3 0 1 2} , 3 0 1 2 {3 0 1 2}
{3 0 1 2, } 3 0 1 2, {3 0 1 2}
{ 3,,0 1 2 } 3,,0 1 2 {3 0 1 2}
{ 5 0:,3 6:,:1 4:7 2 } 5 0:,3 6:,:1 4:7 2 {5 0 3 6 1 4 7 2}
{10 2 9 4 3 11 8 0 1 12 7 5 13 6 } 10 2 9 4 3 11 8 0 1 12 7 5 13 6 {10 2 9 4 3 11 8 : 0 1 12 7 5 13 6}
{ 2 0 1 : 5 3 4 } 2 : 0 5 3 : 4 : {2 0 : 1 5 : 3 4}

The last row of the table reflects the fact that any text_dividers appearing in input are immediately forgotten. The placement of any text_dividers in output is not determined until put_text is invoked. text_divider information is not stored with a permzbi, because a function might take as input two permzbis with incompatible text_divider indications, and there would be no way for the function to tell which (or neither, or something else entirely) should be used.

The comma is tolerated to benefit users who, when typing input, are accustomed to separating numbers with commas.

The following two expressions have practically the same effect:

The operand to operator""_pz must be a string literal and nothing else. Because there can be no whitespace between the closing quote and the underscore, even the name of a string literal that was created with the preprocessor #define statement will give a syntax error.