00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00020 #ifndef FALCON_CORE_DICT_H
00021 #define FALCON_CORE_DICT_H
00022
00023 #include <falcon/types.h>
00024 #include <falcon/garbageable.h>
00025 #include <falcon/itemdict.h>
00026 #include <falcon/deepitem.h>
00027
00028 namespace Falcon {
00029
00030 class Item;
00031
00032 class FALCON_DYN_CLASS CoreDict: public DeepItem, public Garbageable
00033 {
00034 bool m_blessed;
00035 ItemDict* m_dict;
00036
00037 public:
00038 CoreDict( ItemDict* dict ):
00039 m_blessed( false ),
00040 m_dict( dict )
00041 {
00042 m_dict->owner( this );
00043 }
00044
00045 CoreDict( const CoreDict& other ):
00046 m_blessed( other.m_blessed ),
00047 m_dict( (ItemDict*) other.m_dict->clone() )
00048 {
00049 m_dict->owner( this );
00050 }
00051
00052 virtual ~CoreDict()
00053 {
00054 delete m_dict;
00055 }
00056
00057 const ItemDict& items() const { return *m_dict; }
00058 ItemDict& items() { return *m_dict; }
00059
00060 uint32 length() const { return m_dict->length(); }
00061
00062 Item *find( const Item &key ) const { return m_dict->find( key ); }
00063 bool findIterator( const Item &key, Iterator &iter ) { return m_dict->findIterator( key, iter ); }
00064
00065 bool remove( const Item &key ) { return m_dict->remove( key ); }
00066 void put( const Item &key, const Item &value ) { return m_dict->put( key, value ); }
00067 void smartInsert( const Iterator &iter, const Item &key, const Item &value ) {
00068 return m_dict->smartInsert( iter, key, value );
00069 }
00070
00071 CoreDict *clone() const { return new CoreDict( *this ); }
00072 void merge( const CoreDict &dict ) { m_dict->merge( *dict.m_dict ); }
00073 void clear() { m_dict->clear(); }
00074
00079 Item *find( const String &key ) const;
00080
00081
00082
00083
00084 bool find( const Item &key, Item &value );
00085
00086 bool empty() const { return length() == 0; }
00087
00089 bool isBlessed() const { return m_blessed; }
00090
00101 bool getMethod( const String& name, Item &mth );
00102
00111 void bless( bool b ) { m_blessed = b; }
00112
00113 virtual void readProperty( const String &, Item &item );
00114 virtual void writeProperty( const String &, const Item &item );
00115 virtual void readIndex( const Item &pos, Item &target );
00116 virtual void writeIndex( const Item &pos, const Item &target );
00117
00118 virtual void gcMark( uint32 gen );
00119 };
00120
00121 }
00122
00123 #endif
00124
00125