Top   Types   Functions   Classes   Options   Index   Sources 
Vector_format_info_t >>

struct Vector_quotation_method_t / Vector_quotation_method_t

Concrete Class


Description

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.

Members

void(*check_quote)(oType * destination, int length)
Tchar const *empty_name
int(*needs_quotation)(Tchar const *)
Tchar const *null_name
Tchar const *prefix
void(*quote)(oType * destination, Tchar tobequoted, int length)
int(*quoted_length)(int previous_quotation_length, Tchar tobequoted)
Tchar const *suffix


Detailed Descriptions


Tchar const * prefix

C++: Tchar const * _Vector_quotation_method_t::prefix

The prefix to print in front of a quoted string. NULL means empty. E.g. for C, this is "\"".

Declaration  ]


Tchar const * suffix

C++: Tchar const * _Vector_quotation_method_t::suffix

The suffix to print in front of a quoted string. NULL means empty.

E.g. for C, this is "\"".

Declaration  ]


Tchar const * null_name

C++: Tchar const * _Vector_quotation_method_t::null_name

The string to use for quoted output if the string to print is NULL. (No prefix or suffix will be used in this case)

E.g. for C, this is "NULL" and for Lisp, this is "nil".

If this is NULL, an out of range error is generated when the NULL string is encountered to be quoted.

Declaration  ]


Tchar const * empty_name

C++: Tchar const * _Vector_quotation_method_t::empty_name

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.

Declaration  ]


int (* needs_quotation) (Tchar const *)

C++: int (* _Vector_quotation_method_t::needs_quotation) (Tchar const *)

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.

Declaration  ]


int (* quoted_length) (int previous_quotation_length, Tchar tobequoted)

C++: int (* _Vector_quotation_method_t::quoted_length) (int previous_quotation_length, Tchar tobequoted)

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.

Declaration  ]


void (* quote) (oType * destination, Tchar tobequoted, int length)

C++: void (* _Vector_quotation_method_t::quote) (oType * destination, Tchar tobequoted, int length)

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.

Declaration  ]


void (* check_quote) (oType * destination, int length)

C++: void (* _Vector_quotation_method_t::check_quote) (oType * destination, int length)

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):

BeforeQuoted
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.

Declaration  ]

Index

Stoppt die Vorratsdatenspeicherung
November 26th, 2007
Comments? Suggestions? Corrections? You can drop me a line.
zpentrabvagiktu@theiling.de
Schwerpunktpraxis