コード例 #1
0
ファイル: Value.cpp プロジェクト: estump/MSCL
	bool Value::as_bool() const
	{
		try
		{
			switch(m_storedAs)
			{
				case valueType_bool:
					return any_cast<bool>(m_value);

				case valueType_int16:
				case valueType_uint32:
				case valueType_uint16:
				case valueType_uint8:
				case valueType_int32:
					return as_uint32() != 0;

				case valueType_float:
				case valueType_double:
					return as_double() != 0.0;

				case valueType_string:
				default:
					return as_uint32() != 0;
			}
		}
		catch(...)
		{
			throw Error_BadDataType();
		}
	}
コード例 #2
0
ファイル: Value.cpp プロジェクト: estump/MSCL
	std::string Value::as_string() const
	{
		//if the data is stored as a string
		if(m_storedAs == valueType_string)
		{
			try
			{
				return any_cast<std::string>(m_value);
			}
			catch(std::bad_cast&)
			{
				throw Error_BadDataType();
			}
		}

		//build the string depending on how the value is stored
		switch(m_storedAs)
		{
		case valueType_uint8:	return Utils::toStr(static_cast<uint16>(as_uint8()));
		case valueType_uint16:	return Utils::toStr(as_uint16());
		case valueType_uint32:	return Utils::toStr(as_uint32());
		case valueType_int16:	return Utils::toStr(as_int16());
		case valueType_int32:	return Utils::toStr(as_int32());
		case valueType_float:	return Utils::toStr(as_float());
		case valueType_double:	return Utils::toStr(as_double());
		case valueType_bool:	return Utils::toStr(as_bool());

		default:
			throw Error_BadDataType();
		}
	}
コード例 #3
0
ファイル: Value.cpp プロジェクト: estump/MSCL
	bool Value::isSameValue(const Value& other) const
	{
		switch(m_storedAs)
		{
			case valueType_float:	return as_float() == other.as_float();
			case valueType_double:	return as_double() == other.as_double();
			case valueType_uint16:	return as_uint16() == other.as_uint16();
			case valueType_uint32:	return as_uint32() == other.as_uint32();
			case valueType_int16:	return as_int16() == other.as_int16();
			case valueType_int32:	return as_int32() == other.as_int32();
			case valueType_uint8:	return as_uint8() == other.as_uint8();
			case valueType_bool:	return as_bool() == other.as_bool();
			case valueType_string:	return as_string() == other.as_string();

			default:
				return false;
		}
	}
コード例 #4
0
TEST_F(CtypeOpsFromStringTest, uint32_max) {
    EXPECT_EQ(0, parse("uint32", "4294967295"));
    EXPECT_EQ(0xFFFFFFFF, as_uint32());
}
コード例 #5
0
TEST_F(CtypeOpsFromStringTest, uint32_min) {
    EXPECT_EQ(0, parse("uint32", "0"));
    EXPECT_EQ(0U, as_uint32());
}
コード例 #6
0
ファイル: yaggo.hpp プロジェクト: bryopsis/trinity
 uint32_t as_uint32_suffix() const { return as_uint32(true); }
コード例 #7
0
ファイル: arguments.hpp プロジェクト: atlasicus/intercept
 operator uint32_t() const { return as_uint32(); }