|
// PersonChooser.cpp: implementation of the CPersonChooser class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "InterpreterPatternTst.h"
#include "PersonChooser.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CPersonChooser::CPersonChooser(const CPerson& person)
{
m_person=person;
}
CPersonChooser::~CPersonChooser()
{
}
BOOL CPersonChooser::IsTrue(CMetaCondition& metaCondition)
{
switch (metaCondition.m_iKey) {
case KEY_NAME:
switch(metaCondition.m_op) {
case metaCondition.KEYVALUE_OP_EQUAL:
return (m_person.name == metaCondition.m_tsValue);
case metaCondition.KEYVALUE_OP_NOT_EQUAL:
return (m_person.name != metaCondition.m_tsValue);
case metaCondition.KEYVALUE_OP_GREATER_THAN:
return (m_person.name > metaCondition.m_tsValue);
case metaCondition.KEYVALUE_OP_LESS_THAN:
return (m_person.name < metaCondition.m_tsValue);
default:
break;
}
break;
case KEY_GENDER:
switch(metaCondition.m_op) {
case metaCondition.KEYVALUE_OP_EQUAL:
return (m_person.gender == metaCondition.m_tsValue);
case metaCondition.KEYVALUE_OP_NOT_EQUAL:
return (m_person.gender != metaCondition.m_tsValue);
default:
break;
}
break;
case KEY_HEIGHT:
switch(metaCondition.m_op) {
case metaCondition.KEYVALUE_OP_EQUAL:
return (m_person.height == atoi(metaCondition.m_tsValue.c_str()));
case metaCondition.KEYVALUE_OP_NOT_EQUAL:
return (m_person.height != atoi(metaCondition.m_tsValue.c_str()));
case metaCondition.KEYVALUE_OP_GREATER_THAN:
return (m_person.height > atoi(metaCondition.m_tsValue.c_str()));
case metaCondition.KEYVALUE_OP_LESS_THAN:
return (m_person.height < atoi(metaCondition.m_tsValue.c_str()));
default:
break;
}
break;
case KEY_WEIGHT:
switch(metaCondition.m_op) {
case metaCondition.KEYVALUE_OP_EQUAL:
return (m_person.weight == atoi(metaCondition.m_tsValue.c_str()));
case metaCondition.KEYVALUE_OP_NOT_EQUAL:
return (m_person.weight != atoi(metaCondition.m_tsValue.c_str()));
case metaCondition.KEYVALUE_OP_GREATER_THAN:
return (m_person.weight > atoi(metaCondition.m_tsValue.c_str()));
case metaCondition.KEYVALUE_OP_LESS_THAN:
return (m_person.weight < atoi(metaCondition.m_tsValue.c_str()));
default:
break;
}
break;
}
return FALSE;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here