Link to: header | other data directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
CMoneyIDComparator
CMoneyIDValueComparator
specific comparators for comparing money values in various structs. These
are usually used when sorting arrays for the sort command, or in other places
when we need an array of money values sorted by amount or id.
This class compares money amounts for the Goldenseal job cost accounting software,
project management software, construction
estimating software
and construction project estimating software.
SUPERCLASS = CTCS_ArrayComparator
Source Code
/*****************************************************************************
Compare TCS 12/11/00
Compare two money id structs. We only compare the ID with this comparator.
Use it for finding objects rather than for sorting by value.
******************************************************************************/
SInt32 CMoneyIDComparator::Compare(const void *inItemOne, const void *inItemTwo,
UInt32 inSizeOne, UInt32 inSizeTwo) const
{
// We want to be sure we are being passed SObjectInfo pointers
TCS_ASSERTMsg(inSizeOne == sizeof(SMoneyIDInfo) &&
inSizeTwo == sizeof(SMoneyIDInfo), TCS_GetErrString(errID_ProblemDataSize));
TCS_FailNILMsg(inItemOne, TCS_GetErrString(errID_BadComparator));
TCS_FailNILMsg(inItemTwo, TCS_GetErrString(errID_BadComparator));
// Get the structs
SMoneyIDInfo *structOne = ((SMoneyIDInfo *)inItemOne);
SMoneyIDInfo *structTwo = ((SMoneyIDInfo *)inItemTwo);
TCS_FailNILMsg(structOne, TCS_GetErrString(errID_BadComparator)); // TCS 12/2/02
TCS_FailNILMsg(structTwo, TCS_GetErrString(errID_BadComparator));
if (structOne->id < structTwo->id)
{
return compare_Less;
}
else if (structOne->id == structTwo->id)
{
return compare_Equal;
}
else
{
return compare_Greater;
}
}
/*****************************************************************************
Compare TCS 9/27/01
Compare two money id structs. We compare the money portion
******************************************************************************/
SInt32 CMoneyIDValueComparator::Compare(const void *inItemOne, const void *inItemTwo,
UInt32 inSizeOne, UInt32 inSizeTwo) const
{
// We want to be sure we are being passed SObjectInfo pointers
TCS_ASSERTMsg(inSizeOne == sizeof(SMoneyIDInfo) &&
inSizeTwo == sizeof(SMoneyIDInfo), TCS_GetErrString(errID_ProblemDataSize));
TCS_FailNILMsg(inItemOne, TCS_GetErrString(errID_BadComparator));
TCS_FailNILMsg(inItemTwo, TCS_GetErrString(errID_BadComparator));
// Get the structs
SMoneyIDInfo *structOne = ((SMoneyIDInfo *)inItemOne);
SMoneyIDInfo *structTwo = ((SMoneyIDInfo *)inItemTwo);
TCS_FailNILMsg(structOne, TCS_GetErrString(errID_BadComparator)); // TCS 12/2/02
TCS_FailNILMsg(structTwo, TCS_GetErrString(errID_BadComparator));
if (structOne->amount < structTwo->amount)
{
return compare_Less;
}
else if (structOne->amount == structTwo->amount)
{
return compare_Equal;
}
else
{
return compare_Greater;
}
}
|