Accounting Software
Small Business Software Estimating Software
Inventory SoftwareInventory Control SoftwareInventory Tracking SoftwareInventory Management SoftwareConstruction Management SoftwareProject Management SoftwareBusiness Management Software

Cost Category Comparators (Source Code)

Link to: header | other data directory

Copyright Turtle Creek Software 1996-2006. All Rights Reserved.

Comments

CCatIDComparator
CCatNameComparator

Comparators are a convenient way to sort a struct array based on the value
in one of the members. These sort category name arrays by id or name.

This class compares cost categories for the Goldenseal job cost accounting software,
project management software and construction project estimating software.



SUPERCLASS = CTCS_ArrayComparator

Source Code

/*****************************************************************************
CCatIDComparator Compare TCS 3/22/00
Compare two items by id
******************************************************************************/
SInt32 CCatIDComparator::Compare(const void *inItemOne, const void *inItemTwo,
UInt32 inSizeOne, UInt32 inSizeTwo) const
{
// We want to be sure we are being passed SCatNameInfo pointers
TCS_ASSERTMsg(inSizeOne == sizeof(SCatNameInfo) &&
inSizeTwo == sizeof(SCatNameInfo), TCS_GetErrString(errID_ProblemDataSize));
TCS_FailNILMsg(inItemOne, TCS_GetErrString(errID_BadComparator));
TCS_FailNILMsg(inItemTwo, TCS_GetErrString(errID_BadComparator));
// Get the structs
SCatNameInfo *structOne = ((SCatNameInfo *)inItemOne);
SCatNameInfo *structTwo = ((SCatNameInfo *)inItemTwo);

TCS_FailNILMsg(structOne, TCS_GetErrString(errID_BadComparator)); // TCS 12/2/02
TCS_FailNILMsg(structTwo, TCS_GetErrString(errID_BadComparator));
// Compare the names
if (structOne->id < structTwo->id)
{
return compare_Less;
}
else if (structOne->id == structTwo->id)
{
return compare_Equal;
}
else
{
return compare_Greater;
}
}
/*****************************************************************************
CCatNameComparator Compare TCS 3/22/00
Compare two items by name
******************************************************************************/
SInt32 CCatNameComparator::Compare(const void *inItemOne, const void *inItemTwo,
UInt32 inSizeOne, UInt32 inSizeTwo) const
{
// We want to be sure we are being passed SCostNameInfo pointers
TCS_ASSERTMsg(inSizeOne == sizeof(SCatNameInfo) &&
inSizeTwo == sizeof(SCatNameInfo), TCS_GetErrString(errID_ProblemDataSize));
TCS_FailNILMsg(inItemOne, TCS_GetErrString(errID_BadComparator));
TCS_FailNILMsg(inItemTwo, TCS_GetErrString(errID_BadComparator));
// Get the structs
SCatNameInfo *structOne = ((SCatNameInfo *)inItemOne);
SCatNameInfo *structTwo = ((SCatNameInfo *)inItemTwo);

TCS_FailNILMsg(structOne, TCS_GetErrString(errID_BadComparator)); // TCS 12/2/02
TCS_FailNILMsg(structTwo, TCS_GetErrString(errID_BadComparator));

CTextString str1 = structOne->itemName,
str2 = structTwo->itemName;
// Compare the names
if (str1 < str2)
{
return compare_Less;
}
else if (str1 == str2)
{
return compare_Equal;
}
else
{
return compare_Greater;
}
}