--- parser3/src/include/pa_request.h 2001/05/17 15:20:15 1.89 +++ parser3/src/include/pa_request.h 2001/10/15 11:48:04 1.103 @@ -2,10 +2,9 @@ Parser: request class decl. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_request.h,v 1.89 2001/05/17 15:20:15 parser Exp $ + $Id: pa_request.h,v 1.103 2001/10/15 11:48:04 parser Exp $ */ #ifndef PA_REQUEST_H @@ -21,6 +20,7 @@ #include "pa_vobject.h" #include "pa_venv.h" #include "pa_vform.h" +#include "pa_vmath.h" #include "pa_vrequest.h" #include "pa_vresponse.h" #include "pa_vcookie.h" @@ -80,10 +80,10 @@ public: BEWARE: may throw exception to you: catch it! */ void core( - const char *root_auto_path, ///< path to system auto.p file - bool root_auto_fail, ///< fail if system auto.p file not found - const char *site_auto_path, ///< path to site auto.p file - bool site_auto_fail, ///< fail if site auto.p file not found + const char *root_config_filespec, ///< system config filespec + bool root_config_fail_on_read_problem, ///< fail if system config file not found + const char *site_config_filespec, ///< site config filespec + bool site_config_fail_on_read_problem, ///< fail if site config file not found bool header_only); /// executes ops @@ -91,7 +91,8 @@ public: /// compiles the file, maybe forcing it's class @a name and @a base_class. VStateless_class *use_file( - const String& file_spec, bool fail_on_read_problem=true, + const String& file_name, + bool ignore_class_path=false, bool fail_on_read_problem=true, const String *name=0, VStateless_class *base_class=0); // core.C /// compiles a @a source buffer @@ -139,6 +140,9 @@ public: /// returns the mime type of 'user_file_name_cstr' const String& mime_type_of(const char *user_file_name_cstr); + /// PCRE character tables + const unsigned char *pcre_tables(); + public: /// info from web server @@ -152,6 +156,8 @@ public: VEnv env; /// $form:elements VForm form; + /// $math:constants + VMath math; /// $request:elements VRequest request; /// $response:elements @@ -169,13 +175,10 @@ public: /// connection SQL_Connection *connection; - /// PCRE character tables - unsigned char *pcre_tables; /// classes configured data Hash classes_conf; - private: // core data /// classes @@ -192,16 +195,21 @@ private: // core data */ uint anti_endless_execute_recoursion; + /// charset->pcre_tables + Hash CTYPE; + private: // compile.C VStateless_class& real_compile(COMPILE_PARAMS); private: // execute.C - const String *execute_method(Value& aself, const Method& method, - bool return_cstr=true); - const String *execute_method(Value& aself, const String& method_name, - bool return_cstr=true); + const String *execute_method(Value& aself, + const Method& method, bool return_cstr=true); + const String *execute_virtual_method(Value& aself, + const String& method_name, bool return_cstr=true); + const String *execute_nonvirtual_method(VStateless_class& aclass, + const String& method_name, bool return_cstr=true); Value *get_element(); @@ -249,4 +257,68 @@ public: } }; +/** + @b method parameters passed in this array. + contains handy typecast ad junction/not junction ensurers + +*/ +class MethodParams : public Array { +public: + MethodParams(Pool& pool, const String& amethod_name) : Array(pool), + fmethod_name(amethod_name) { + } + + /// handy typecast. I long for templates + Value& get(int index) { + return *static_cast(Array::get(index)); + } + /// handy is-value-a-junction ensurer + Value& as_junction(int index, const char *msg) { + return get_as(index, true, msg); + } + /// handy value-is-not-a-junction ensurer + Value& as_no_junction(int index, const char *msg) { + return get_as(index, false, msg); + } + /// handy expression auto-processing to double + double as_double(int index, const char *msg, Request& r) { + return get_processed(index, msg, r).as_double(); + } + /// handy expression auto-processing to int + int as_int(int index, const char *msg, Request& r) { + return get_processed(index, msg, r).as_int(); + } + /// handy expression auto-processing to bool + bool as_bool(int index, const char *msg, Request& r) { + return get_processed(index, msg, r).as_bool(); + } + /// handy string ensurer + const String& as_string(int index, const char *msg) { + return as_no_junction(index, msg).as_string(); + } + +private: + + /// handy value-is/not-a-junction ensurer + Value& get_as(int index, bool as_junction, const char *msg) { + Value& result=get(index); + if((result.get_junction()!=0) ^ as_junction) + THROW(0, 0, + &fmethod_name, + "%s (parameter #%d)", msg, 1+index); + return result; + } + + Value& get_processed(int index, const char *msg, Request& r) { + return r.process(as_junction(index, msg), + 0/*no name*/, + false/*don't intercept string*/); + } + +private: + + const String& fmethod_name; + +}; + #endif