2012-09-17 14:27:17 +08:00
|
|
|
#include "CCBValue.h"
|
|
|
|
|
|
|
|
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;
|
2013-07-28 00:31:09 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
ret->autorelease();
|
|
|
|
}
|
2013-07-28 00:31:09 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
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)
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
ret->_value.intValue = nValue;
|
2013-07-28 00:31:09 +08:00
|
|
|
ret->_type = Type::INT;
|
2012-09-17 14:27:17 +08:00
|
|
|
ret->autorelease();
|
|
|
|
}
|
2013-07-28 00:31:09 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCBValue* CCBValue::create(float fValue)
|
|
|
|
{
|
|
|
|
CCBValue *ret = new CCBValue();
|
|
|
|
if (ret)
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
ret->_value.floatValue = fValue;
|
2013-07-28 00:31:09 +08:00
|
|
|
ret->_type = Type::FLOAT;
|
2012-09-17 14:27:17 +08:00
|
|
|
ret->autorelease();
|
|
|
|
}
|
2013-07-28 00:31:09 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCBValue* CCBValue::create(bool vValue)
|
|
|
|
{
|
|
|
|
CCBValue *ret = new CCBValue();
|
|
|
|
if (ret)
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
ret->_value.intValue = vValue ? 1 : 0;
|
2013-07-28 00:31:09 +08:00
|
|
|
ret->_type = Type::BOOL;
|
2012-09-17 14:27:17 +08:00
|
|
|
ret->autorelease();
|
|
|
|
}
|
2013-07-28 00:31:09 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCBValue* CCBValue::create(unsigned char byte)
|
|
|
|
{
|
|
|
|
CCBValue *ret = new CCBValue();
|
|
|
|
if (ret)
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
ret->_value.intValue = byte;
|
2013-07-28 00:31:09 +08:00
|
|
|
ret->_type = Type::UNSIGNED_CHAR;
|
2012-09-17 14:27:17 +08:00
|
|
|
ret->autorelease();
|
|
|
|
}
|
2013-07-28 00:31:09 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
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-07-27 22:31:57 +08:00
|
|
|
ret->_strValue = pStringValue;
|
2013-07-28 00:31:09 +08:00
|
|
|
ret->_type = Type::STRING;
|
2012-09-17 14:27:17 +08:00
|
|
|
ret->autorelease();
|
|
|
|
}
|
2013-07-28 00:31:09 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
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-07-28 00:26:24 +08:00
|
|
|
ret->_type = Type::ARRAY;
|
2013-03-15 08:43:56 +08:00
|
|
|
ret->autorelease();
|
|
|
|
}
|
2013-07-28 00:31:09 +08:00
|
|
|
|
2013-03-15 08:43:56 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
int CCBValue::getIntValue()
|
|
|
|
{
|
2013-07-28 00:31:09 +08:00
|
|
|
CCASSERT(_type == Type::INT, "The type of CCBValue isn't integer.");
|
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
return _value.intValue;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float CCBValue::getFloatValue()
|
|
|
|
{
|
2013-07-28 00:31:09 +08:00
|
|
|
CCASSERT(_type == Type::FLOAT, "The type of CCBValue isn't float.");
|
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
return _value.floatValue;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CCBValue::getBoolValue()
|
|
|
|
{
|
2013-07-28 00:31:09 +08:00
|
|
|
CCASSERT(_type == Type::BOOL, "The type of CCBValue isn't boolean.");
|
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
return _value.intValue == 1 ? true : false;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char CCBValue::getByteValue()
|
|
|
|
{
|
2013-07-28 00:31:09 +08:00
|
|
|
CCASSERT(_type == Type::UNSIGNED_CHAR, "The type of CCBValue isn't unsigned char.");
|
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
return (unsigned char)(_value.intValue);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
Array* CCBValue::getArrayValue()
|
|
|
|
{
|
2013-07-28 00:31:09 +08:00
|
|
|
CCASSERT(_type == Type::ARRAY, "The type of CCBValue isn't array.");
|
|
|
|
|
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-07-28 00:31:09 +08:00
|
|
|
CCASSERT(_type == Type::STRING, "The type of CCBValue isn't string.");
|
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
return _strValue.c_str();
|
2013-01-21 18:37:17 +08:00
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
CCBValue::Type CCBValue::getType()
|
2013-01-21 18:37:17 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _type;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_EXT_END
|