2012-09-17 14:27:17 +08:00
|
|
|
#include "CCBValue.h"
|
|
|
|
|
|
|
|
using namespace cocos2d;
|
|
|
|
|
|
|
|
NS_CC_EXT_BEGIN
|
|
|
|
|
|
|
|
// Implementation of ccColor3BWapper
|
|
|
|
|
2012-09-24 11:08:10 +08:00
|
|
|
ccColor3BWapper* ccColor3BWapper::create(const ccColor3B& color)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
ccColor3BWapper *ret = new ccColor3BWapper();
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ret->color.r = color.r;
|
|
|
|
ret->color.g = color.g;
|
|
|
|
ret->color.b = color.b;
|
|
|
|
|
|
|
|
ret->autorelease();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-01-14 16:06:18 +08:00
|
|
|
const ccColor3B& ccColor3BWapper::getColor() const
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implementation of CCBValue
|
|
|
|
|
|
|
|
CCBValue* CCBValue::create(int nValue)
|
|
|
|
{
|
|
|
|
CCBValue *ret = new CCBValue();
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ret->mValue.nValue = nValue;
|
|
|
|
ret->mType = kIntValue;
|
|
|
|
ret->autorelease();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCBValue* CCBValue::create(float fValue)
|
|
|
|
{
|
|
|
|
CCBValue *ret = new CCBValue();
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ret->mValue.fValue = fValue;
|
|
|
|
ret->mType = kFloatValue;
|
|
|
|
ret->autorelease();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCBValue* CCBValue::create(bool vValue)
|
|
|
|
{
|
|
|
|
CCBValue *ret = new CCBValue();
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ret->mValue.nValue = vValue ? 1 : 0;
|
|
|
|
ret->mType = kBoolValue;
|
|
|
|
ret->autorelease();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCBValue* CCBValue::create(unsigned char byte)
|
|
|
|
{
|
|
|
|
CCBValue *ret = new CCBValue();
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ret->mValue.nValue = byte;
|
|
|
|
ret->mType = kUnsignedCharValue;
|
|
|
|
ret->autorelease();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-01-21 18:37:17 +08:00
|
|
|
CCBValue* CCBValue::create(const char *pStringValue)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
CCBValue *ret = new CCBValue();
|
|
|
|
if (ret)
|
|
|
|
{
|
2013-01-21 18:37:17 +08:00
|
|
|
ret->m_strValue = pStringValue;
|
|
|
|
ret->mType = kStringValue;
|
2012-09-17 14:27:17 +08:00
|
|
|
ret->autorelease();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-03-15 08:43:56 +08:00
|
|
|
|
|
|
|
CCBValue* CCBValue::create(CCArray *pArrValue)
|
|
|
|
{
|
|
|
|
CCBValue *ret = new CCBValue();
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ret->m_arrValue = pArrValue;
|
|
|
|
ret->mType = kArrayValue;
|
|
|
|
ret->autorelease();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
int CCBValue::getIntValue()
|
|
|
|
{
|
|
|
|
assert(mType == kIntValue);
|
|
|
|
|
|
|
|
return mValue.nValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
float CCBValue::getFloatValue()
|
|
|
|
{
|
|
|
|
assert(mType == kFloatValue);
|
|
|
|
|
|
|
|
return mValue.fValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CCBValue::getBoolValue()
|
|
|
|
{
|
|
|
|
assert(mType == kBoolValue);
|
|
|
|
|
|
|
|
return mValue.nValue == 1 ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char CCBValue::getByteValue()
|
|
|
|
{
|
2013-05-13 19:26:56 +08:00
|
|
|
assert(mType == kUnsignedCharValue);
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
return (unsigned char)(mValue.nValue);
|
|
|
|
}
|
|
|
|
|
2013-03-15 08:43:56 +08:00
|
|
|
CCArray* CCBValue::getArrayValue() {
|
|
|
|
assert(mType == kArrayValue);
|
|
|
|
|
|
|
|
return m_arrValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-21 18:37:17 +08:00
|
|
|
const char* CCBValue::getStringValue()
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-01-21 18:37:17 +08:00
|
|
|
assert(mType == kStringValue);
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-01-21 18:37:17 +08:00
|
|
|
return m_strValue.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
int CCBValue::getType()
|
|
|
|
{
|
|
|
|
return mType;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_EXT_END
|