bool TimeDateValue::Compare (Value* v, CSSM_DB_OPERATOR op) { if (v->GetValueType () != mBaseFormat) { CSSMError::ThrowCSSMError (CSSMERR_DL_INCOMPATIBLE_FIELD_FORMAT); } TimeDateValue* sv = (TimeDateValue*) v; time_t vRaw = sv->GetRawValue (); time_t myRaw = GetRawValue (); switch (op) { case CSSM_DB_EQUAL: return vRaw == myRaw; case CSSM_DB_NOT_EQUAL: return vRaw != myRaw; case CSSM_DB_LESS_THAN: return myRaw < vRaw; case CSSM_DB_GREATER_THAN: return myRaw > vRaw; } CSSMError::ThrowCSSMError (CSSMERR_DL_UNSUPPORTED_OPERATOR); }
bool BlobValue::Compare (Value* v, CSSM_DB_OPERATOR op) { if (v->GetValueType () != mBaseFormat) CSSMError::ThrowCSSMError (CSSMERR_DL_INCOMPATIBLE_FIELD_FORMAT); BlobValue* sv = (BlobValue*) v; const uint8 *vRaw, *myRaw; size_t vLength, myLength; vRaw = sv->GetRawValue (vLength); myRaw = GetRawValue (myLength); switch (op) { case CSSM_DB_CONTAINS: case CSSM_DB_EQUAL: case CSSM_DB_CONTAINS_INITIAL_SUBSTRING: case CSSM_DB_CONTAINS_FINAL_SUBSTRING: return CompareBlobs (vRaw, vLength, myRaw, myLength); case CSSM_DB_NOT_EQUAL: return !CompareBlobs (vRaw, vLength, myRaw, myLength); } CSSMError::ThrowCSSMError (CSSMERR_DL_UNSUPPORTED_OPERATOR); }
Float32 ZKMORHP_StereoPanControl::GetValue() const { Float32 theAnswer = 0.0; SInt32 theRawValue = GetRawValue(); Float32 theSpan; if(theRawValue == mCenterRawValue) { theAnswer = 0.5; } else if(theRawValue > mCenterRawValue) { theSpan = mFullRightRawValue - mCenterRawValue; theAnswer = theRawValue - mCenterRawValue; theAnswer *= 0.5; theAnswer /= theSpan; theAnswer += 0.5; } else { theSpan = mCenterRawValue - mFullLeftRawValue; theAnswer = theRawValue - mFullLeftRawValue; theAnswer *= 0.5; theAnswer /= theSpan; } return theAnswer; }
const char* ApplicationLayer::Models::RollModel::GetFormattedValue() const { static char formatted[4] = { 0 }; itoa2(GetRawValue(), formatted, 10); return formatted; }
HRESULT CColorValue::FormatBuffer(TCHAR* szBuffer, UINT uMaxLen, BOOL fReturnAsHex6/*=FALSE*/) const { HRESULT hr = S_OK; const struct COLORVALUE_PAIR* pColorPair; LONG lValue; DWORD type = GetType(); INT idx; DWORD dwSysColor; TCHAR achFmt[5] = _T("<0C>"); switch(type) { default: case TYPE_UNDEF: *szBuffer = 0; break; case TYPE_NAME: // requests from the OM set fReturnAsHex to true, so instead // of returning "red; we want to return "#ff0000" if(!fReturnAsHex6) { pColorPair = FindColorByValue(GetRawValue()); Assert(pColorPair); _tcsncpy(szBuffer, pColorPair->szName, uMaxLen); break; } // else fall through !!! case TYPE_RGB: // requests from the OM set fReturnAsHex to true, so instead // of returning "rgb(255,0,0)" we want to return "#ff0000" if(!fReturnAsHex6) { hr = Format(_afxGlobalData._hInstResource, 0, szBuffer, uMaxLen, _T("rgb(<0d>,<1d>,<2d>)"), (_dwValue&0x0000FF), (_dwValue&0x00FF00)>>8, (_dwValue&0xFF0000)>>16); break; } // else fall through !!! case TYPE_SYSINDEX: case TYPE_POUND6: case TYPE_POUND5: case TYPE_POUND4: achFmt[2] = _T('c'); case TYPE_POUND3: case TYPE_POUND2: case TYPE_POUND1: lValue = (LONG)GetColorRef(); if(fReturnAsHex6) { achFmt[2] = _T('c'); } hr = Format(_afxGlobalData._hInstResource, 0, szBuffer, uMaxLen, achFmt, lValue); if(!fReturnAsHex6 && (type!=TYPE_POUND6)) { szBuffer[((TYPE_POUND1-type)>>24)+2] = _T('\0'); }
bool StringValue::Compare (Value* v, CSSM_DB_OPERATOR op) { if (v->GetValueType () != mBaseFormat) CSSMError::ThrowCSSMError (CSSMERR_DL_INCOMPATIBLE_FIELD_FORMAT); StringValue* sv = (StringValue*) v; const char* vRaw = sv->GetRawValue (); const char* myRaw = GetRawValue (); switch (op) { case CSSM_DB_EQUAL: return strcmp (myRaw, vRaw) == 0; case CSSM_DB_NOT_EQUAL: return strcmp (myRaw, vRaw) != 0; case CSSM_DB_LESS_THAN: return strcmp (myRaw, vRaw) < 0; case CSSM_DB_GREATER_THAN: return strcmp (myRaw, vRaw) > 0; default: break; } const char* strLocation = strstr (vRaw, myRaw); switch (op) { case CSSM_DB_CONTAINS: return strLocation != NULL; case CSSM_DB_CONTAINS_INITIAL_SUBSTRING: return strLocation == myRaw; case CSSM_DB_CONTAINS_FINAL_SUBSTRING: int vRawLen = strlen (vRaw); int myRawLen = strlen (myRaw); return strLocation == myRaw + myRawLen - vRawLen; } CSSMError::ThrowCSSMError (CSSMERR_DL_UNSUPPORTED_OPERATOR); }
const char* ApplicationLayer::Models::VoltageModel::GetFormattedValue() const { static char formatted[5] = { 0 }; int32_t rawValue = GetRawValue(); int16_t integerPart = rawValue / 100; int16_t fractionalPart = rawValue % 100; if (integerPart > 10) { itoa2(integerPart, formatted, 10); formatted[2] = '.'; itoa2(fractionalPart, formatted + 3, 10); } else { itoa2(integerPart, formatted, 10); formatted[1] = '.'; itoa2(fractionalPart, formatted + 2, 10); } return formatted; }
Float32 ZKMORHP_LevelControl::GetScalarValue() const { SInt32 theRawValue = GetRawValue(); Float32 theScalarValue = mVolumeCurve.ConvertRawToScalar(theRawValue); return theScalarValue; }
double GetValueD(struct matrix *m, const int *indices) { double value; assert(m->type_of_entry == DOUBLE); GetRawValue(m, (byte *)indices, (void *)&value); return (value); }
float GetValueF(struct matrix *m, const int *indices) { float value; assert(m->type_of_entry == FLOAT); GetRawValue(m, (byte *)indices, (void *)&value); return (value); }