Annotation of parser3/src/doc/string.dox, revision 1.7

1.1       paf         1: /**    @page String String
                      2: 
1.7     ! moko        3: In memory strings [String] are stored as letters [actually, cord objects from libgd cord library, see cord.h file] 
        !             4: plus list of fragments [String::Languages] which contain language of fragment+it's length.
1.6       paf         5: 
                      6: Fragments that are received from stdout of scripts are considered clean(String::Language ::L_CLEAN),
1.7     ! moko        7: but those from visitor - from stderr of scripts, from environment, from forms,
        !             8: from dist [table:load] or from sql server [table:sql] are considered tainted(String::Language::L_TAINTED),
1.6       paf         9: when string involved in different operations, it can be split, but all resulting parts 
                     10: still remember languages of their fragments.
                     11: String can be written to Request::wcontext, then part of fragments can change their language. 
                     12: Language is set to those fragments, which were not in particular language, but just tainted[L_TAINTED], 
                     13: they become "dirty, but we need what to do to make them clean, that is we know their language".
                     14: Say,
1.1       paf        15: @verbatim
1.3       paf        16: ^void:sql{insert into news (title) values ('$form:title')]
1.1       paf        17: @endverbatim
1.6       paf        18: when parameter of sql is processed, with help of Temp_lang 
1.7     ! moko       19: we set "current language" [Request::flang], and when string got written [Request::write_assign_lang] 
        !            20: L_TAINTED string from $form:title part of parameter of sql-method, the one in apostrophes, got assigned an L_SQL language.
1.6       paf        21: 
1.7     ! moko       22: String can be converted to normal string using String::cstr().
1.6       paf        23: If it is called with this parameter String::cstr(String::L_UNSPECIFIED) then
                     24: when it will be converted, fragment languages would be taken into consideration, and 
                     25: corresponding cleansing performed.
                     26: Particular language can also be specified String::cstr(String::Language) [by default =L_AS_IS], 
                     27: then all string fragments would forcibly considered to be in that language, 
                     28: regardles of the language inside fragment.
                     29: 
                     30: This is used, for instance, in work with file names
                     31: [ATTENTION: never ever use this construction if you care about your secret files,
                     32: it is used only as an example]:
1.1       paf        33: @verbatim
1.3       paf        34: $file[^table::load[$form:file_name]]
1.1       paf        35: @endverbatim
1.6       paf        36: here with normal $form:file_name processing would be L_HTML|L_OPTIMIZE_BIT, while we need L_FILE_SPEC,
                     37: and it would be stupid everywhere to do like we do in table:sql, insisting on {} parameters.
                     38: 
                     39: Usual language of output is String::Language::L_HTML|String::Language::L_OPTIMIZE_BIT, 
                     40: exception is CGI script, which got started outside of web-server,
                     41: in that case language String::Language::L_AS_IS is used.
1.1       paf        42: 
1.6       paf        43: In fragments where language is marked as OPTIMIZED (String::Language::L_OPTIMIZE_BIT), 
                     44: when they are converted into string String::cstr white spaces would be optimized:
                     45: out of several consequent characters would be left only first, others would be wiped off the result.
1.1       paf        46: 
1.6       paf        47: When code works with char* it is assumed it is can never be 0.
                     48: k
1.5       paf        49: */

E-mail: