For user defined quotation methods This class is used for customising formatting.
The library supports several standard quotations
like C strings or Lisp, Shell, etc. You may
want to define your own syntax by implementing
a few functions here and using
Vector_set_quotation_method() to define your style.
If this is != NULL, the empty string is exceptionally represent this way.
Similar to null_name, but this handles the empty string. E.g. in Unxi Shell
syntax quotation, which is currently implemented to not print string
delimiters, the empty string would in normal printing result in just that:
the empty string. But that's wrong, so this member has the value "''" for
Shell quotation.
If this is NULL, the string is normally printed using the other fields
and functions of this struct.
A function that decides whether a string needs quotations.
You can either implement your own checks, or simply return
a value of 2 to let the library check each character for
quotation.
Results:
0
no, no quotation
1
yes, quotation
2
decide by checking results of the quoted_length function.
If for some oType it returns != 1, it needs quotation.
3
yes, quote, but leave out prefix and suffix.
4
Always quote, but decide whether the prefix and suffix
are used by checking the results of the quoted_length
function. If it is != 1 for some character, use them,
otherwise leave them away.
If the function pointer is NULL, this means to never quote.
For checking individually whether to quote or not for each character:
NULL means: literal length 1 (no quotation)
The integer given to this function is the output of this function for the
previous characters. The function can then decide whether and how to quote
depending on the previous value. Initially, -1 is given.
If this function returns a negative value, its absolute value is taked as
the quoted string's length. This is useful for indicating that a string
needs quotation even if the current character's quoted length is 1.
The actual implementation of a quotation of one character.
NULL means: no quotation
This function must write exactly length non-null characters. No null
character may follow (use memcpy instead of strcpy!)
The length argument is the output of the quoted_length function.
Check that the quotation has worked and eventually fix it so
that it is properly quoted. The string passed is not
null-terminated, but instead the length is given.
This function pointer may be NULL: in that case it is not invoked.
Note
This function must not change the length of the string!
E.g. this function is used for the Windows shell quotation method to
swap the last two characters if they are \". This is necessary because
the quotation method is really weird (the backslash has two meanings):
Before
Quoted
B\C D
"B\C D"
B\"C D
"B\\"C D"
B\"C D\
"B\\"C D"\
not "B\\"C D\"
The last one cannot be "B\\"C D\" since a backslash before a double quote
is interpreted as a quoted double quote. This is prevented by the
check_quote function.