|
|
| version 1.32, 2003/11/20 16:34:23 | version 1.35, 2005/08/08 09:24:27 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b hashfile parser class. | Parser: @b hashfile parser class. |
| Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2004 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| */ | */ |
| Line 19 static const char * const IDENT="$Id$"; | Line 19 static const char * const IDENT="$Id$"; |
| class MHashfile : public Methoded { | class MHashfile : public Methoded { |
| public: // VStateless_class | public: // VStateless_class |
| Value *create_new_value(Pool& apool) { return new VHashfile(apool); } | Value *create_new_value(Pool& apool, HashStringValue&) { return new VHashfile(apool); } |
| public: | public: |
| MHashfile(); | MHashfile(); |
| Line 31 public: // Methoded | Line 31 public: // Methoded |
| DECLARE_CLASS_VAR(hashfile, new MHashfile, 0); | DECLARE_CLASS_VAR(hashfile, new MHashfile, 0); |
| // defines for statics | |
| #define OPEN_DATA_NAME "HASHFILE-OPEN-DATA" | |
| // methods | // methods |
| typedef Hash<const String::Body, bool> HashStringBool; | |
| static void _open(Request& r, MethodParams& params) { | static void _open(Request& r, MethodParams& params) { |
| HashStringBool* file_list=static_cast<HashStringBool*>(r.classes_conf.get(OPEN_DATA_NAME)); | |
| if(!file_list) { | |
| file_list=new HashStringBool(); | |
| r.classes_conf.put(OPEN_DATA_NAME, file_list); | |
| } | |
| const String& file_spec=r.absolute(params.as_string(0, "filename must be string")); | |
| if(file_list->get(file_spec)) | |
| throw Exception("parser.runtime", | |
| 0, | |
| "this hashfile is already opened, use existing variable"); | |
| file_list->put(file_spec, true); | |
| VHashfile& self=GET_SELF(r, VHashfile); | VHashfile& self=GET_SELF(r, VHashfile); |
| self.open(file_spec); | |
| self.open(r.absolute(params.as_string(0, "filename must be string"))); | |
| } | } |
| static void _hash(Request& r, MethodParams&) { | static void _hash(Request& r, MethodParams&) { |
| Line 84 static void one_foreach_cycle(const Stri | Line 102 static void one_foreach_cycle(const Stri |
| Foreach_info& info=*static_cast<Foreach_info*>(ainfo); | Foreach_info& info=*static_cast<Foreach_info*>(ainfo); |
| info.vkey->set_string(*new String(key, String::L_TAINTED)); | info.vkey->set_string(*new String(key, String::L_TAINTED)); |
| info.vvalue->set_string(value); | info.vvalue->set_string(value); |
| info.var_context->put_element(*info.key_var_name, info.vkey, false); | info.var_context->put_element(*info.var_context, *info.key_var_name, info.vkey, false); |
| info.var_context->put_element(*info.value_var_name, info.vvalue, false); | info.var_context->put_element(*info.var_context, *info.value_var_name, info.vvalue, false); |
| StringOrValue sv_processed=info.r->process(*info.body_code); | StringOrValue sv_processed=info.r->process(*info.body_code); |
| const String* s_processed=sv_processed.get_string(); | const String* s_processed=sv_processed.get_string(); |