|
|
| version 1.124, 2015/10/15 18:12:29 | version 1.127, 2016/07/04 17:26:23 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b hash parser class. | Parser: @b hash parser class. |
| Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2015 Art. Lebedev Studio (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 31 public: | Line 31 public: |
| // global variable | // global variable |
| DECLARE_CLASS_VAR(hash, new MHash, 0); | DECLARE_CLASS_VAR(hash, new MHash); |
| // methods | // methods |
| Line 198 static void _create_or_add(Request& r, M | Line 198 static void _create_or_add(Request& r, M |
| HashStringValue* self_hash=&(self.hash()); | HashStringValue* self_hash=&(self.hash()); |
| if(VHash* src=static_cast<VHash*>(vsrc.as(VHASH_TYPE))) { | if(VHash* src=static_cast<VHash*>(vsrc.as(VHASH_TYPE))) { |
| src_hash=&(src->hash_ro()); | src_hash=&(src->hash()); |
| if(src_hash==self_hash) // same: doing nothing | if(src_hash==self_hash) // same: doing nothing |
| return; | return; |
| Line 384 static void _keys(Request& r, MethodPara | Line 384 static void _keys(Request& r, MethodPara |
| *columns+=keys_column_name; | *columns+=keys_column_name; |
| Table* table=new Table(columns); | Table* table=new Table(columns); |
| GET_SELF(r, VHash).hash_ro().for_each<Table*>(keys_collector, table); | GET_SELF(r, VHash).hash().for_each<Table*>(keys_collector, table); |
| r.write_no_lang(*new VTable(table)); | r.write_no_lang(*new VTable(table)); |
| } | } |
| static void _count(Request& r, MethodParams&) { | static void _count(Request& r, MethodParams&) { |
| r.write_no_lang(*new VInt(GET_SELF(r, VHash).hash_ro().count())); | r.write_no_lang(*new VInt(GET_SELF(r, VHash).hash().count())); |
| } | } |
| static void _delete(Request& r, MethodParams& params) { | static void _delete(Request& r, MethodParams& params) { |
| Line 401 static void _delete(Request& r, MethodPa | Line 401 static void _delete(Request& r, MethodPa |
| } | } |
| static void _contains(Request& r, MethodParams& params) { | static void _contains(Request& r, MethodParams& params) { |
| bool result=GET_SELF(r, VHash).hash_ro().contains(params.as_string(0, "key must be string")); | bool result=GET_SELF(r, VHash).hash().contains(params.as_string(0, "key must be string")); |
| r.write_no_lang(VBool::get(result)); | r.write_no_lang(VBool::get(result)); |
| } | } |
| Line 465 static void _foreach(Request& r, MethodP | Line 465 static void _foreach(Request& r, MethodP |
| }; | }; |
| VHash& self=GET_SELF(r, VHash); | VHash& self=GET_SELF(r, VHash); |
| HashStringValue& hash=self.hash_ro(); | HashStringValue& hash=self.hash(); |
| VHash_lock lock(self); | |
| hash.first_that<Foreach_info*>(one_foreach_cycle, &info); | hash.first_that<Foreach_info*>(one_foreach_cycle, &info); |
| } | } |
| Line 521 static void _sort(Request& r, MethodPara | Line 520 static void _sort(Request& r, MethodPara |
| VMethodFrame* context=r.get_method_frame()->caller(); | VMethodFrame* context=r.get_method_frame()->caller(); |
| VHash& self=GET_SELF(r, VHash); | VHash& self=GET_SELF(r, VHash); |
| HashStringValue& hash=self.hash_ro(); | HashStringValue& hash=self.hash(); |
| int count=hash.count(); | int count=hash.count(); |
| VHash_lock lock(self); | |
| Hash_seq_item* seq=new(PointerFreeGC) Hash_seq_item[count]; | Hash_seq_item* seq=new(PointerFreeGC) Hash_seq_item[count]; |
| int pos=0; | int pos=0; |
| Line 569 static void _sort(Request& r, MethodPara | Line 567 static void _sort(Request& r, MethodPara |
| } | } |
| static void _at(Request& r, MethodParams& params) { | static void _at(Request& r, MethodParams& params) { |
| HashStringValue& hash=GET_SELF(r, VHash).hash_ro(); | HashStringValue& hash=GET_SELF(r, VHash).hash(); |
| size_t count=hash.count(); | size_t count=hash.count(); |
| int pos=0; | int pos=0; |