2012-09-17 14:27:17 +08:00
|
|
|
#include "CCBValue.h"
|
|
|
|
|
|
|
|
using namespace cocos2d;
|
|
|
|
|
|
|
|
NS_CC_EXT_BEGIN
|
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
// Implementation of Color3BWapper
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
Color3BWapper* Color3BWapper::create(const Color3B& color)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-07-05 16:49:22 +08:00
|
|
|
Color3BWapper *ret = new Color3BWapper();
|
2012-09-17 14:27:17 +08:00
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ret->color.r = color.r;
|
|
|
|
ret->color.g = color.g;
|
|
|
|
ret->color.b = color.b;
|
|
|
|
|
|
|
|
ret->autorelease();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
const Color3B& Color3BWapper::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-06-15 14:03:30 +08:00
|
|
|
ret->_value = pStringValue;
|
2013-01-21 18:37:17 +08:00
|
|
|
ret->mType = kStringValue;
|
2012-09-17 14:27:17 +08:00
|
|
|
ret->autorelease();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-03-15 08:43:56 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
CCBValue* CCBValue::create(Array *pArrValue)
|
2013-03-15 08:43:56 +08:00
|
|
|
{
|
|
|
|
CCBValue *ret = new CCBValue();
|
|
|
|
if (ret)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
ret->_arrValue = pArrValue;
|
2013-03-15 08:43:56 +08:00
|
|
|
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-06-20 14:15:53 +08:00
|
|
|
Array* CCBValue::getArrayValue() {
|
2013-03-15 08:43:56 +08:00
|
|
|
assert(mType == kArrayValue);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
return _arrValue;
|
2013-03-15 08:43:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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-06-15 14:03:30 +08:00
|
|
|
return _value.c_str();
|
2013-01-21 18:37:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int CCBValue::getType()
|
|
|
|
{
|
|
|
|
return mType;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_EXT_END
|