00001 00002 //#include <sys/types.h> 00003 00004 #include "std/support.H" 00005 #include "stream.H" 00006 #include "net.H" 00007 #include "net_types.H" 00008 #include "data_item.H" 00009 00010 00011 STDdstream & 00012 operator >> (STDdstream &ds, HASH &h) 00013 { 00014 h.clear(); 00015 int num; 00016 ds >> num; 00017 str_ptr key; 00018 for (int i = 0; i < num; i++) { 00019 ds >> key; 00020 DATA_ITEM *di = DATA_ITEM::Decode(ds); 00021 00022 h.add(**key, (void *) di); 00023 } 00024 return ds; 00025 } 00026 00027 STDdstream & 00028 operator << (STDdstream &ds, CHASH &h) 00029 { 00030 ARRAY<long> keys; 00031 ARRAY<void *> items; 00032 h.get_items(keys, items); 00033 ds << items.num(); 00034 for (int i = 0; i < items.num(); i++) { 00035 ds << str_ptr((char *) keys[i]) << *((DATA_ITEM *) items[i]); 00036 } 00037 return ds; 00038 }