--- parser3/src/classes/hash.C 2001/10/23 14:43:44 1.24 +++ parser3/src/classes/hash.C 2001/11/01 10:59:25 1.25 @@ -4,7 +4,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: hash.C,v 1.24 2001/10/23 14:43:44 parser Exp $ + $Id: hash.C,v 1.25 2001/11/01 10:59:25 paf Exp $ */ #include "classes.h" @@ -107,7 +107,7 @@ static void _create_or_add(Request& r, c static void remove_key_from(const Hash::Key& key, Hash::Val *value, void *info) { Hash& dest=*static_cast(info); - dest.put(key, 0); + dest.remove(key); } static void _sub(Request& r, const String& method_name, MethodParams *params) { @@ -263,6 +263,12 @@ static void _count(Request& r, const Str r.write_no_lang(result); } +static void _delete(Request& r, const String& method_name, MethodParams *params) { + Pool& pool=r.pool(); + + static_cast(r.self)->hash().remove(params->as_string(0, "key must be string")); +} + // constructor MHash::MHash(Pool& apool) : Methoded(apool) { @@ -281,6 +287,9 @@ MHash::MHash(Pool& apool) : Methoded(apo // ^a.intersects[b] = bool add_native_method("intersects", Method::CT_DYNAMIC, _intersects, 1, 1); + // ^a.delete[key] + add_native_method("delete", Method::CT_DYNAMIC, _delete, 1, 1); + // ^hash:sql[query][(count[;offset])] add_native_method("sql", Method::CT_DYNAMIC, _sql, 1, 3);