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

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

E-mail: