kjs Library API Documentation

property_map.h

00001 // -*- c-basic-offset: 2 -*-
00002 /*
00003  *  This file is part of the KDE libraries
00004  *  Copyright (C) 2003 Apple Computer, Inc.
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Library General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Library General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Library General Public License
00017  *  along with this library; see the file COPYING.LIB.  If not, write to
00018  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019  *  Boston, MA 02111-1307, USA.
00020  *
00021  */
00022 
00023 #ifndef _KJS_PROPERTY_MAP_H_
00024 #define _KJS_PROPERTY_MAP_H_
00025 
00026 #include "identifier.h"
00027 
00028 namespace KJS {
00029 
00030     class Object;
00031     class ReferenceList;
00032     class ValueImp;
00033     
00034     class SavedProperty;
00035     
00036     struct PropertyMapHashTable;
00037     
00038     class SavedProperties {
00039     friend class PropertyMap;
00040     public:
00041         SavedProperties();
00042         ~SavedProperties();
00043         
00044     private:
00045         int _count;
00046         SavedProperty *_properties;
00047         
00048         SavedProperties(const SavedProperties&);
00049         SavedProperties& operator=(const SavedProperties&);
00050     };
00051     
00052     struct PropertyMapHashTableEntry
00053     {
00054         PropertyMapHashTableEntry() : key(0) { }
00055         UString::Rep *key;
00056         ValueImp *value;
00057         int attributes;
00058     };
00059 
00060     class PropertyMap {
00061     public:
00062         PropertyMap();
00063         ~PropertyMap();
00064 
00065         void clear();
00066         
00067         void put(const Identifier &name, ValueImp *value, int attributes);
00068         void remove(const Identifier &name);
00069         ValueImp *get(const Identifier &name) const;
00070         ValueImp *get(const Identifier &name, int &attributes) const;
00071 
00072         void mark() const;
00073         void addEnumerablesToReferenceList(ReferenceList &, const Object &) const;
00074     void addSparseArrayPropertiesToReferenceList(ReferenceList &, const Object &) const;
00075 
00076         void save(SavedProperties &) const;
00077         void restore(const SavedProperties &p);
00078 
00079     private:
00080         int hash(const UString::Rep *) const;
00081         static bool keysMatch(const UString::Rep *, const UString::Rep *);
00082         void expand();
00083         
00084         void insert(UString::Rep *, ValueImp *value, int attributes);
00085         
00086         void checkConsistency();
00087         
00088         typedef PropertyMapHashTableEntry Entry;
00089         typedef PropertyMapHashTable Table;
00090 
00091         Table *_table;
00092         
00093         Entry _singleEntry;
00094     };
00095 
00096 } // namespace
00097 
00098 #endif // _KJS_PROPERTY_MAP_H_
KDE Logo
This file is part of the documentation for kjs Library Version 3.2.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Feb 4 12:34:40 2004 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2003