--- parser3/src/include/pa_request.h 2001/04/28 10:58:30 1.85 +++ parser3/src/include/pa_request.h 2001/07/07 16:38:01 1.91 @@ -5,12 +5,13 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_request.h,v 1.85 2001/04/28 10:58:30 paf Exp $ + $Id: pa_request.h,v 1.91 2001/07/07 16:38:01 parser Exp $ */ #ifndef PA_REQUEST_H #define PA_REQUEST_H +#include "pa_config_includes.h" #include "pa_pool.h" #include "pa_hash.h" #include "pa_wcontext.h" @@ -20,6 +21,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" @@ -86,7 +88,7 @@ public: bool header_only); /// executes ops - void execute(const Array& ops); + void execute(const Array& ops); // execute.C /// compiles the file, maybe forcing it's class @a name and @a base_class. VStateless_class *use_file( @@ -147,15 +149,17 @@ public: /// operators are methods of this class Methoded& OP; - /// $env:fields here + /// $env:fields VEnv env; - /// $form:elements here + /// $form:elements VForm form; - /// $request:elements here + /// $math:constants + VMath math; + /// $request:elements VRequest request; - /// $response: + /// $response:elements VResponse response; - /// $cookie: + /// $cookie:elements VCookie cookie; /// contexts @@ -163,29 +167,34 @@ public: /// contexts WContext *wcontext; - /// main class conglomerat + /// 'MAIN' class conglomerat VStateless_class *main_class; /// connection SQL_Connection *connection; - /// table of protocol's libraries. read from $SQL:drivers - Table *protocol2library; - /// mail options - Hash *mail; /// PCRE character tables unsigned char *pcre_tables; + /// classes configured data + Hash classes_conf; + + private: // core data - // classes + /// classes Hash fclasses; - // already used files to avoid cyclic uses + /// already used files to avoid cyclic uses Hash used_files; - // execution stack + /// execution stack Stack stack; + /** endless execute(execute(... preventing counter + @see ANTI_ENDLESS_EXECUTE_RECOURSION + */ + uint anti_endless_execute_recoursion; + private: // compile.C VStateless_class& real_compile(COMPILE_PARAMS); @@ -243,4 +252,64 @@ 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, Request& r) { + return get_processed(index, r).as_double(); + } + /// handy expression auto-processing to int + int as_int(int index, Request& r) { + return get_processed(index, r).as_int(); + } + /// 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, Request& r) { + return r.process(get(index), + 0/*no name*/, + false/*don't intercept string*/); + } + +private: + + const String& fmethod_name; + +}; + #endif