double ff::Dict::GetDouble(ff::StringRef name, double defaultValue) const
{
	Value *value = GetValue(name);

	if (value)
	{
		if (value->IsType(Value::Type::Double))
		{
			return value->AsDouble();
		}
		else
		{
			ValuePtr newValue;

			if (value->Convert(Value::Type::Double, &newValue))
			{
				return newValue->AsDouble();
			}
		}
	}

	return defaultValue;
}
Esempio n. 2
0
bool ff::Value::operator==(const Value &r) const
{
	if (this == &r)
	{
		return true;
	}

	if (GetType() != r.GetType())
	{
		return false;
	}

	switch (GetType())
	{
		case Type::Null:
			return true;

		case Type::Bool:
			return AsBool() == r.AsBool();

		case Type::Double:
			return AsDouble() == r.AsDouble();

		case Type::Float:
			return AsFloat() == r.AsFloat();

		case Type::Int:
			return AsInt() == r.AsInt();

		case Type::Object:
			return AsObject() == r.AsObject();

		case Type::Point:
			return AsPoint() == r.AsPoint();

		case Type::PointF:
			return AsPointF() == r.AsPointF();

		case Type::Rect:
			return AsRect() == r.AsRect();

		case Type::RectF:
			return AsRectF() == r.AsRectF();

		case Type::String:
			return AsString() == r.AsString();

		case Type::StringVector:
			return AsStringVector() == r.AsStringVector();

		case Type::ValueVector:
			return AsValueVector() == r.AsValueVector();

		case Type::Guid:
			return AsGuid() == r.AsGuid() ? true : false;

		case Type::IntVector:
			return AsIntVector() == r.AsIntVector();

		case Type::DoubleVector:
			return AsDoubleVector() == r.AsDoubleVector();

		case Type::FloatVector:
			return AsFloatVector() == r.AsFloatVector();

		case Type::DataVector:
			return AsDataVector() == r.AsDataVector();

		case Type::Data:
			return AsData() == r.AsData();

		case Type::SavedData:
		case Type::SavedDict:
			return AsSavedData() == r.AsSavedData();

		default:
			assert(false);
			return false;
	}
}