//============================================================================ // NCFNumber::SetObject : Set the object. //---------------------------------------------------------------------------- bool NCFNumber::SetObject(CFNumberRef cfObject, bool takeOwnership) { NCFObject theObject(cfObject, takeOwnership); float64_t valueFloat64; float32_t valueFloat32; int64_t valueInt64; bool isValid; // Get the state we need isValid = (cfObject != NULL); SetInt8(0); // Set the object if (isValid) { if (CFNumberGetValue( cfObject, kCFNumberLongLongType, &valueInt64)) SetInt64(valueInt64); else if (CFNumberGetValue(cfObject, kCFNumberFloatType, &valueFloat32)) SetFloat32(valueFloat32); else if (CFNumberGetValue(cfObject, kCFNumberDoubleType, &valueFloat64)) SetFloat64(valueFloat64); else NN_LOG("Unable to convert CFNumber to NNumber"); } return(isValid); }
void CMdbPara::SetNumber(register uint32 nFieldNo, register void* pVal, register uint32 nOperator) { switch(GetType(nFieldNo)) { case MDB_INT8_FIELD: SetInt8(nFieldNo, *(int8*)pVal, nOperator); break; case MDB_INT16_FIELD: SetInt16(nFieldNo, *(int16*)pVal, nOperator); break; case MDB_INT32_FIELD: SetInt32(nFieldNo, *(int32*)pVal, nOperator); break; case MDB_INT64_FIELD: SetInt64(nFieldNo, *(int64*)pVal, nOperator); break; case MDB_UINT8_FIELD: SetUInt8(nFieldNo, *(uint8*)pVal, nOperator); break; case MDB_UINT16_FIELD: SetUInt16(nFieldNo, *(uint16*)pVal, nOperator); break; case MDB_UINT32_FIELD: SetUInt32(nFieldNo, *(uint32*)pVal, nOperator); break; case MDB_UINT64_FIELD: SetUInt64(nFieldNo, *(uint64*)pVal, nOperator); break; case MDB_FLOAT_FIELD: SetFloat(nFieldNo, *(float*)pVal, nOperator); break; case MDB_DOUBLE_FIELD: SetDouble(nFieldNo, *(double*)pVal, nOperator); break; case MDB_DATE_FIELD: SetDate(nFieldNo, *(CDate*)pVal, nOperator); break; case MDB_TIME_FIELD: SetTime(nFieldNo, *(CTime*)pVal, nOperator); break; case MDB_DATETIME_FIELD: SetDateTime(nFieldNo, *(CDateTime*)pVal, nOperator); break; } }
//============================================================================ // NNumber::SetValue : Set the value. //---------------------------------------------------------------------------- bool NNumber::SetValue(const NVariant &theValue) { uint8_t valueUInt8; uint16_t valueUInt16; uint32_t valueUInt32; uint64_t valueUInt64; int8_t valueSInt8; int16_t valueSInt16; int32_t valueSInt32; int64_t valueSInt64; float32_t valueFloat32; float64_t valueFloat64; int valueInt; long valueLong; NString valueString; // Set the value // // NVariant treats some unsized types as numeric, to support literal constants. if (theValue.GetValue(*this)) ; // Assigned to this else if (theValue.GetValue(valueUInt8)) SetUInt8(valueUInt8); else if (theValue.GetValue(valueUInt16)) SetUInt16(valueUInt16); else if (theValue.GetValue(valueUInt32)) SetUInt32(valueUInt32); else if (theValue.GetValue(valueUInt64)) SetUInt64(valueUInt64); else if (theValue.GetValue(valueSInt8)) SetInt8(valueSInt8); else if (theValue.GetValue(valueSInt16)) SetInt16(valueSInt16); else if (theValue.GetValue(valueSInt32)) SetInt32(valueSInt32); else if (theValue.GetValue(valueSInt64)) SetInt64(valueSInt64); else if (theValue.GetValue(valueFloat32)) SetFloat32(valueFloat32); else if (theValue.GetValue(valueFloat64)) SetFloat64(valueFloat64); else if (theValue.GetValue(valueInt)) SetInt64(valueInt); else if (theValue.GetValue(valueLong)) SetInt64(valueLong); else if (theValue.GetValue(valueString)) return(SetValue(valueString)); else return(false); return(true); }