Пример #1
0
Any Any::operator + (const Any &r) const {
	switch (this->type()) {
		case Any::Int:
			switch (r.type()) {
				case Any::Int: return this->getInt() + r.getInt();
				case Any::Float: return this->getInt() + r.getFloat();
				case Any::String: return boost::lexical_cast<string>(this->getInt()) + r.getString();
			}
			break;
		case Any::Float:
			switch (r.type()) {
				case Any::Int: return this->getFloat() + r.getInt();
				case Any::Float: return this->getFloat() + r.getFloat();
				case Any::String: return boost::lexical_cast<string>(this->getFloat()) + r.getString();
			}
			break;
		case Any::String:
			switch (r.type()) {
				case Any::Int: return this->getString() + boost::lexical_cast<string>(r.getInt());
				case Any::Float: return this->getString() + boost::lexical_cast<string>(r.getFloat());
				case Any::String: return this->getString() + r.getString();
			}
			break;
	}
	FIXME("Unsupported operation %s + %s", this->typeInfo().name(), r.typeInfo().name());
	return 0;
}
Пример #2
0
Any Any::operator << (const Any &r) const {
	if (this->type() == Any::Int && r.type() == Any::Int) {
		int32_t a = this->getInt();
		int32_t b = r.getInt();
		uint32_t ret = *reinterpret_cast<uint32_t*>( &a ) << *reinterpret_cast<uint32_t*>( &b );
		return *reinterpret_cast<int32_t*>( &ret );
	}
	FIXME("Unsupported operation %s << %s", this->typeInfo().name(), r.typeInfo().name());
	return 0;
}
Пример #3
0
Any Any::operator / (const Any &r) const {
	switch (this->type()) {
		case Any::Int:
			switch (r.type()) {
				case Any::Int: return this->getInt() / r.getInt();
				case Any::Float: return this->getInt() / r.getFloat();
			}
			break;
		case Any::Float:
			switch (r.type()) {
				case Any::Int: return this->getFloat() / r.getInt();
				case Any::Float: return this->getFloat() / r.getFloat();
			}
			break;
	}
	FIXME("Unsupported operation %s / %s", this->typeInfo().name(), r.typeInfo().name());
	return 0;
}
Пример #4
0
Any Any::operator % (const Any &r) const {
	switch (this->type()) {
		case Any::Int:
			switch (r.type()) {
				case Any::Int: return this->getInt() % r.getInt();
				case Any::Float: return (float)fmod((double)this->getInt(), (double)r.getFloat());
			}
			break;
		case Any::Float:
			switch (r.type()) {
				case Any::Int: return (float)fmod((double)this->getFloat(), (double)r.getInt());
				case Any::Float: return (float)fmod(this->getFloat(), r.getFloat());
			}
			break;
	}
	FIXME("Unsupported operation %s % %s", this->typeInfo().name(), r.typeInfo().name());
	return 0;
}