Annotation of parser3/src/classes/root.C, revision 1.15

1.1       paf         1: /*
1.10      paf         2:        Parser
                      3:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.12      paf         4:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.10      paf         5: 
1.15    ! paf         6:        $Id: root.C,v 1.14 2001/03/11 09:24:41 paf Exp $
1.1       paf         7: */
                      8: 
                      9: #include "pa_request.h"
1.8       paf        10: #include "_root.h"
1.1       paf        11: 
1.6       paf        12: static void _if(Request& r, Array *params) {
1.2       paf        13:        bool condition=
                     14:                r.autocalc(
1.6       paf        15:                        *static_cast<Value *>(params->get(0)), 
1.11      paf        16:                        0/*no name*/,
1.14      paf        17:                        false/*don't intercept string*/).get_bool();
1.6       paf        18:        if(condition) {
                     19:                Value& value=r.autocalc(*static_cast<Value *>(params->get(1)));
1.9       paf        20:                r.wcontext->write(value, String::Untaint_lang::PASS_APPENDED);
1.6       paf        21:        } else if(params->size()==3) {
                     22:                Value& value=r.autocalc(*static_cast<Value *>(params->get(2)));
1.9       paf        23:                r.wcontext->write(value, String::Untaint_lang::PASS_APPENDED);
1.6       paf        24:        }
1.1       paf        25: }
                     26: 
1.15    ! paf        27: static void _untaint(Request& r, Array *params) {
        !            28:        const String& lang_name=r.autocalc(*static_cast<Value *>(params->get(0))).as_string();
        !            29:        String::Untaint_lang lang=static_cast<String::Untaint_lang>(
        !            30:                untaint_lang_name_to_value->get_int(lang_name));
        !            31:        if(!lang)
        !            32:                R_THROW(0, 0,
        !            33:                        &lang_name,
        !            34:                        "invalid language");
        !            35: 
        !            36:        Temp_lang temp_lang(r, lang);
        !            37:        Value& value=r.autocalc(*static_cast<Value *>(params->get(1)));
        !            38:        r.wcontext->write(value, String::Untaint_lang::PASS_APPENDED);
        !            39: }
        !            40:        
        !            41: 
1.7       paf        42: void initialize_root_class(Pool& pool, VClass& vclass) {
1.15    ! paf        43:        // ^if(condition){code-when-true}
        !            44:        // ^if(condition){code-when-true}{code-when-false}
        !            45:        vclass.add_native_method("if", _if, 2, 3);
        !            46: 
        !            47:        // ^untaint[as-is|sql|js|html|html-typo]{code}
        !            48:        vclass.add_native_method("untaint", _untaint, 2, 2);
1.1       paf        49: }

E-mail: