00001 /* 00002 * This file is part of the Standard Portable Library (SPL). 00003 * 00004 * SPL is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * SPL is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with SPL. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 #ifndef _jsobject_h 00018 #define _jsobject_h 00019 00020 #include <spl/types.h> 00021 #include <spl/Debug.h> 00022 #include <spl/collection/Hashtable.h> 00023 #include <spl/interp/IJsObject.h> 00024 #include <spl/Memory.h> 00025 #include <spl/String.h> 00026 #include <spl/Variant.h> 00027 00028 class JsObject; 00029 typedef RefCountPtrCast<JsObject, IJsObject, IJsObjectPtr> JsObjectPtr; 00030 00031 class JsObject : public IJsObject 00032 { 00033 protected: 00034 Hashtable<String, VariantPtr> m_properties; 00035 00036 public: 00037 JsObject(); 00038 JsObject(const JsObject& obj); 00039 virtual ~JsObject(); 00040 00041 virtual IJsObjectPtr New() const; 00042 00043 virtual VariantPtr GetProperty(const String& idx); 00044 virtual bool HasProperty(const String& idx) const; 00045 virtual void SetProperty(const String& idx, VariantPtr obj); 00046 00047 virtual bool Equals( const IComparable& a ) const; 00048 virtual int Compare( const IComparable& a ) const; 00049 00052 virtual int32 MajicNumber() const; 00053 virtual int32 HashCode() const; 00054 00055 virtual StringPtr ToString() const; 00056 00057 #if defined(DEBUG) || defined(_DEBUG) 00058 void CheckMem() const; 00059 void ValidateMem() const; 00060 #endif 00061 }; 00062 00063 REGISTER_TYPEOF2(699,Hashtable<String, VariantPtr>); 00064 00065 #endif