Annotation of parser3/src/classes/hashfile.C, revision 1.2

1.1       parser      1: /** @file
                      2:        Parser: @b hashfile parser class.
                      3: 
                      4:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
                      5:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
                      6: 
1.2     ! parser      7:        $Id: hashfile.C,v 1.1 2001/10/22 12:30:24 parser Exp $
1.1       parser      8: */
                      9: 
                     10: #include "pa_config_includes.h"
                     11: #ifdef HAVE_LIBDB
                     12: 
                     13: #include "classes.h"
                     14: #include "pa_request.h"
                     15: #include "pa_vhashfile.h"
                     16: #include "pa_vhash.h"
                     17: 
                     18: // defines
                     19: 
                     20: #define HASH_CLASS_NAME "hashfile"
                     21: 
                     22: // class
                     23: 
                     24: class MHashfile : public Methoded {
                     25: public: // VStateless_class
                     26:        Value *create_new_value(Pool& pool) { return new(pool) VHashfile(pool); }
                     27: 
                     28: public:
                     29:        MHashfile(Pool& pool);
                     30: public: // Methoded
                     31:        bool used_directly() { return true; }
                     32: };
                     33: 
                     34: // methods
                     35: 
                     36: static void _assign(Request& r, const String& method_name, MethodParams *params) {
                     37:        Pool& pool=r.pool();
                     38:        VHashfile& self=*static_cast<VHashfile *>(r.self);
                     39:        
                     40:        const String &sfile_spec=params->as_string(0, "filename must be string");
                     41: 
1.2     ! parser     42:        self.assign(r.absolute(sfile_spec), method_name);
1.1       parser     43: }
                     44: //static_cast<VHashfile *>(r.self)     const String& file_spec=->file_spec();
                     45: 
                     46: // constructor
                     47: 
                     48: MHashfile::MHashfile(Pool& apool) : Methoded(apool) {
                     49:        set_name(*NEW String(pool(), HASH_CLASS_NAME));
                     50: 
                     51:        // ^hashfile::assign[filename]
                     52:        add_native_method("assign", Method::CT_DYNAMIC, _assign, 1, 1);
                     53: /*
                     54:        // ^hashfile.delete[key]
                     55:        add_native_method("delete", Method::CT_DYNAMIC, _delete, 1, 1);
                     56:        // ^hashfile.clear[]
                     57:        add_native_method("clear", Method::CT_DYNAMIC, _clear, 0, 0);
                     58:        // ^cache[key](seconds){code}
                     59:        add_native_method("cache", Method::CT_DYNAMIC, _cache, 3, 3);
                     60:        // ^cancel[]
                     61:        add_native_method("cancel", Method::CT_DYNAMIC, _cancel, 0, 0);
                     62:        // ^lock{code}
                     63:        add_native_method("lock", Method::CT_DYNAMIC, _lock, 1, 1);
                     64:        // ^pack[]
                     65:        add_native_method("pack", Method::CT_DYNAMIC, _pack, 0, 0);
                     66:        */
                     67: }
                     68: 
                     69: // global variable
                     70: 
                     71: Methoded *hashfile_base_class;
                     72: 
                     73: // creator
                     74: 
                     75: Methoded *MHashfile_create(Pool& pool) {
                     76:        return hashfile_base_class=new(pool) MHashfile(pool);
                     77: }
                     78: 
                     79: #endif

E-mail: