Annotation of parser3/src/classes/regex.C, revision 1.1
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:
! 8: static const char * const IDENT_REGEX_C="$Date: 2009-04-16 01:10:21 $";
! 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 {
! 20: public: // VStateless_class
! 21: Value* create_new_value(Pool&, HashStringValue&) { return new VRegex(); }
! 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) {
! 35: Value& value=params.as_no_junction(0, "regexp must not be code");
! 36:
! 37: VRegex& vregex=GET_SELF(r, VRegex);
! 38:
! 39: vregex.set(r.charsets.source(),
! 40: &value.as_string(),
! 41: params.count()>1?¶ms.as_no_junction(1, "options must not be code").as_string():0);
! 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: }
E-mail: