Annotation of parser3/src/classes/regex.C, revision 1.4

1.1       misha       1: /** @file
                      2:        Parser: @b int parser class.
                      3: 
                      4:        Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com)
                      5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
                      6: */
                      7: 
1.4     ! misha       8: static const char * const IDENT_REGEX_C="$Date: 2009-06-14 00:33:36 $";
1.1       misha       9: 
                     10: #include "classes.h"
                     11: #include "pa_vmethod_frame.h"
                     12: 
                     13: #include "pa_request.h"
                     14: #include "pa_vint.h"
                     15: #include "pa_vregex.h"
                     16: 
                     17: // class
                     18: 
                     19: class MRegex: public Methoded {
1.2       misha      20: public: // VStateless_class
1.3       misha      21:        Value* create_new_value(Pool&, HashStringValue*) { return new VRegex(); }
1.1       misha      22: public:
                     23:        MRegex();
                     24: public: // Methoded
                     25:        bool used_directly() { return true; }
                     26: };
                     27: 
                     28: // global variable
                     29: 
                     30: DECLARE_CLASS_VAR(regex, new MRegex, 0);
                     31: 
                     32: // methods
                     33: 
                     34: static void _create(Request& r, MethodParams& params) {
1.4     ! misha      35:        const String& pattern=params.as_string(0, "regexp must not be code");
1.1       misha      36: 
                     37:        VRegex& vregex=GET_SELF(r, VRegex);
                     38: 
                     39:        vregex.set(r.charsets.source(),
1.4     ! misha      40:                &pattern,
        !            41:                params.count()>1?&params.as_string(1, OPTIONS_MUST_NOT_BE_CODE):0);
1.1       misha      42: 
                     43:        vregex.compile();
                     44: 
                     45:        vregex.study();
                     46: }
                     47: 
                     48: 
                     49: static void _size(Request& r, MethodParams&) {
                     50:        VRegex& vregex=GET_SELF(r, VRegex);
                     51:        r.write_no_lang(*new VInt(vregex.get_info_size()));
                     52: }
                     53: 
                     54: static void _study_size(Request& r, MethodParams&) {
                     55:        VRegex& vregex=GET_SELF(r, VRegex);
                     56:        r.write_no_lang(*new VInt(vregex.get_study_size()));
                     57: }
                     58: 
                     59: // constructor
                     60: 
                     61: MRegex::MRegex(): Methoded("regex") {
                     62:        // ^regex::create[string[;options]]
                     63:        add_native_method("create", Method::CT_DYNAMIC, _create, 1, 2);
                     64: 
                     65:        // ^regex.info_size[]
                     66:        add_native_method("size", Method::CT_DYNAMIC, _size, 0, 0);
                     67: 
                     68:        // ^regex.study_size[]
                     69:        add_native_method("study_size", Method::CT_DYNAMIC, _study_size, 0, 0);
                     70: 
                     71: }
1.2       misha      72: 

E-mail: