Annotation of parser3/src/classes/hash.C, revision 1.1
1.1 ! paf 1: /** @file
! 2: Parser: @b hash parser class.
! 3:
! 4: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
! 5:
! 6: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
! 7:
! 8: $Id: hash.C,v 1.11 2001/05/04 10:42:36 paf Exp $
! 9: */
! 10:
! 11: #include "classes.h"
! 12: #include "pa_request.h"
! 13: #include "pa_vhash.h"
! 14: #include "pa_vunknown.h"
! 15:
! 16: // class
! 17:
! 18: class MHash : public Methoded {
! 19: public:
! 20: MHash(Pool& pool);
! 21: public: // Methoded
! 22: bool used_directly() { return false; }
! 23: };
! 24:
! 25: // methods
! 26:
! 27: static void _default(Request& r, const String&, MethodParams *params) {
! 28: Pool& pool=r.pool();
! 29:
! 30: VHash& vhash=*static_cast<VHash *>(r.self);
! 31: if(params->size())
! 32: vhash.set_default(params->get(0)); // info: may be code..
! 33: else {
! 34: Value *default_value=vhash.get_default();
! 35: r.write_assign_lang(default_value?*default_value:*new(pool) VUnknown(pool));
! 36: }
! 37: }
! 38:
! 39: // constructor
! 40:
! 41: MHash::MHash(Pool& apool) : Methoded(apool) {
! 42: // ^hash.default[]
! 43: // ^hash.default[hash]
! 44: add_native_method("default", Method::CT_DYNAMIC, _default, 0, 1);
! 45: }
! 46:
! 47: // global variable
! 48:
! 49: Methoded *hash_base_class;
! 50:
! 51: // creator
! 52:
! 53: Methoded *MHash_create(Pool& pool) {
! 54: return hash_base_class=new(pool) MHash(pool);
! 55: }
E-mail: