Link to: header | other data directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
DB_MoneySelector
A selector for money values. Used for the find command.
This class finds money amounts for the Goldenseal job cost accounting software,
project management software, construction
estimating software
and construction project estimating software.
SUPERCLASS = DB_MemberSelector
Constructor
/*********************************************************************************
default constructor
*********************************************************************************/
DB_MoneySelector::DB_MoneySelector(const TagType aTag, const CMoney &aValue)
: DB_MemberSelector(aTag)
{
mValue = aValue;
mMemberType = type_money; // TCS 6/4/03
}
Source Code
/******************************************************************************
ReadFromStream TCS 6/4/03
read in data from the stream
*******************************************************************************/
void DB_MoneySelector::ReadFromStream(CNeoStream *aStream, const NeoTag aTag)
{
TCS_FailNILMsg(aStream, TCS_GetErrString(errID_BadStream));
THE_SUPERCLASS::ReadFromStream(aStream, aTag);
// read the data
mValue.ReadFromStream(aStream);
}
/******************************************************************************
WriteToStream TCS 6/4/03
write to stream
*******************************************************************************/
void DB_MoneySelector::WriteToStream(CNeoStream *aStream, const NeoTag aTag) const
{
TCS_FailNILMsg(aStream, TCS_GetErrString(errID_BadStream));
THE_SUPERCLASS::WriteToStream(aStream, aTag);
// write the data
mValue.WriteToStream(aStream);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
compare
this is the engine which runs the search. This function should return
one of the following;
kNeoLow -if the key refers to an object after the given one,
kNeoExact -if the key refers to the given object, or
kNeoHigh -if the key refers to an object before the given one.
*********************************************************************************/
NeoOrder DB_MoneySelector::compare(const CNeoPersist *aObject,
const short aOffset,
NeoOrder *aKeyOrder) const
{
NeoOrder order;
// fetch the proper tag to search for TCS 12/17/01
SInt32 matchTag;
if (UsesNegativeTag())
matchTag = -fSelectTag;
else
matchTag = fSelectTag;
if (fMatchAll)
order = kNeoExact;
else
{
CMoney value;
if (aOffset < 0)
aObject->GetMemberValue(matchTag, type_money, &value);
else
((CNeoCollection *)aObject)->getEntryValue(aOffset, matchTag,
type_money, &value);
order = CompareMoney(value);
}
*aKeyOrder = order;
return *aKeyOrder;
}
/*********************************************************************************
CompareMoney TCS 12/18/02
return whether this selector matches the given value. This is
a direct comparison that we use for matches with a menu array or index
array, rather than with an object
*********************************************************************************/
NeoOrder DB_MoneySelector::CompareMoney(const CMoney &value) const
{
NeoOrder order;
if (value == mValue)
order = kNeoExact;
else if (value < mValue)
order = kNeoLow;
else
order = kNeoHigh;
return compareOrder(order);
}
/*********************************************************************************
MatchesMoney TCS 12/18/02
return whether this selector matches the given value. This is
a direct comparison that we use for matches with a menu array or index
array, rather than with an object
*********************************************************************************/
Boolean DB_MoneySelector::MatchesMoney(const CMoney &value) const
{
NeoOrder order = CompareMoney(value); // bugfix TCS 1/5/03
return (order == kNeoExact);
}
|