Exemplo n.º 1
0
void writeFundamental(void * address, const GMetaType & metaType, const GVariant & v)
{
	size_t size = metaType.getVariantSize();;
	if(vtIsReal(metaType.getVariantType())) {
		switch(size) {
			case 4:
				*(GFixedTypeFloat32::Signed *)(address) = fromVariant<GFixedTypeFloat32::Signed>(v);
				break;

			case 8:
				*(GFixedTypeFloat64::Signed *)(address) = fromVariant<GFixedTypeFloat64::Signed>(v);
				break;

			default:
				if(metaType.getVariantType() == vtLongDouble) { // long double has vary size on GCC...
					*(GFixedTypeFloat80::Signed *)(address) = fromVariant<GFixedTypeFloat80::Signed>(v);
					break;
				}
				GASSERT(false);
				break;
		}
	}
	else {
		switch(metaType.getVariantType()) {
			case vtBool:
				doWriteInteger<bool>(address, size, v);
				break;

			case vtChar:
				doWriteInteger<char>(address, size, v);
				break;

			case vtWchar:
				doWriteInteger<wchar_t>(address, size, v);
				break;

			case vtSignedChar:
				doWriteInteger<signed char>(address, size, v);
				break;

			case vtUnsignedChar:
				doWriteInteger<unsigned char>(address, size, v);
				break;

			case vtSignedShort:
				doWriteInteger<signed short>(address, size, v);
				break;

			case vtUnsignedShort:
				doWriteInteger<unsigned short>(address, size, v);
				break;

			case vtSignedInt:
				doWriteInteger<signed int>(address, size, v);
				break;

			case vtUnsignedInt:
				doWriteInteger<unsigned int>(address, size, v);
				break;

			case vtSignedLong:
				doWriteInteger<signed long>(address, size, v);
				break;

			case vtUnsignedLong:
				doWriteInteger<unsigned long>(address, size, v);
				break;

			case vtSignedLongLong:
				doWriteInteger<signed long long>(address, size, v);
				break;

			case vtUnsignedLongLong:
				doWriteInteger<unsigned long long>(address, size, v);
				break;

			default:
				GASSERT(false);
				break;

		}
	}
}
Exemplo n.º 2
0
GVariant readFundamental(const void * address, const GMetaType & metaType)
{
	size_t size = metaType.getVariantSize();
	if(vtIsReal(metaType.getVariantType())) {
		switch(size) {
			case 4:
				return *(GFixedTypeFloat32::Signed *)(address);

			case 8:
				return *(GFixedTypeFloat64::Signed *)(address);

			default:
				if(metaType.getVariantType() == vtLongDouble) { // long double has vary size on GCC...
					return *(GFixedTypeFloat80::Signed *)(address);
					break;
				}
				GASSERT(false);
				break;
		}
	}
	else {
		switch(metaType.getVariantType()) {
			case vtBool:
				return doReadInteger<bool>(address, size);

			case vtChar:
				return doReadInteger<char>(address, size);

			case vtWchar:
				return doReadInteger<wchar_t>(address, size);

			case vtSignedChar:
				return doReadInteger<signed char>(address, size);

			case vtUnsignedChar:
				return doReadInteger<unsigned char>(address, size);

			case vtSignedShort:
				return doReadInteger<signed short>(address, size);

			case vtUnsignedShort:
				return doReadInteger<unsigned short>(address, size);

			case vtSignedInt:
				return doReadInteger<signed int>(address, size);

			case vtUnsignedInt:
				return doReadInteger<unsigned int>(address, size);

			case vtSignedLong:
				return doReadInteger<signed long>(address, size);

			case vtUnsignedLong:
				return doReadInteger<unsigned long>(address, size);

			case vtSignedLongLong:
				return doReadInteger<signed long long>(address, size);

			case vtUnsignedLongLong:
				return doReadInteger<unsigned long long>(address, size);

			default:
				GASSERT(false);
				break;

		}
	}

	return GVariant();
}