2012-08-29 14:52:30 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2012 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
2012-08-28 12:04:51 +08:00
|
|
|
|
|
|
|
#ifndef cocos2dx_ccTypeInfo_h
|
|
|
|
#define cocos2dx_ccTypeInfo_h
|
|
|
|
|
|
|
|
#include "platform/CCPlatformMacros.h"
|
|
|
|
|
|
|
|
#include <typeinfo>
|
2012-09-26 11:16:44 +08:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
2012-08-28 12:04:51 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
|
|
|
class TypeInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual long getClassTypeInfo() = 0;
|
|
|
|
};
|
|
|
|
|
2012-09-26 11:16:44 +08:00
|
|
|
static inline unsigned int getHashCodeByString(const char *key)
|
2012-08-29 14:52:30 +08:00
|
|
|
{
|
2013-07-20 13:01:27 +08:00
|
|
|
size_t len = strlen(key);
|
2012-08-29 14:52:30 +08:00
|
|
|
const char *end=key+len;
|
|
|
|
unsigned int hash;
|
|
|
|
|
|
|
|
for (hash = 0; key < end; key++)
|
|
|
|
{
|
|
|
|
hash *= 16777619;
|
|
|
|
hash ^= (unsigned int) (unsigned char) toupper(*key);
|
|
|
|
}
|
|
|
|
return (hash);
|
|
|
|
}
|
2012-08-28 12:04:51 +08:00
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif
|