"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "html/muscle-by-example/examples/queryfilter/example_1_basic_usage.cpp" between
muscle8.20.zip and muscle8.30.zip

About: MUSCLE (Multi User Server Client Linking Environment) is a messaging server and networking API. The included server program ("muscled") lets its clients message each other, and/or store information in its serverside hierarchical database.

example_1_basic_usage.cpp  (muscle8.20):example_1_basic_usage.cpp  (muscle8.30)
skipping to change at line 16 skipping to change at line 16
static void PrintExampleDescription() static void PrintExampleDescription()
{ {
printf("\n"); printf("\n");
printf("This example demonstrates basic usage of the muscle::QueryFilter clas s to test whether a Message object matches various test-conditions.\n"); printf("This example demonstrates basic usage of the muscle::QueryFilter clas s to test whether a Message object matches various test-conditions.\n");
printf("\n"); printf("\n");
} }
static void TestTheMessage(const Message & msg, const char * filterDescription, const QueryFilter & qf) static void TestTheMessage(const Message & msg, const char * filterDescription, const QueryFilter & qf)
{ {
ConstMessageRef msgRef(&msg, false); DummyConstMessageRef msgRef(msg);
LogTime(MUSCLE_LOG_ERROR, "QueryFilter \"%s\" says the Message %s\n", filterD escription, qf.Matches(msgRef, NULL)?"MATCHES":"doesn't match"); LogTime(MUSCLE_LOG_ERROR, "QueryFilter \"%s\" says the Message %s\n", filterD escription, qf.Matches(msgRef, NULL)?"MATCHES":"doesn't match");
} }
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {
CompleteSetupSystem css; CompleteSetupSystem css;
PrintExampleDescription(); PrintExampleDescription();
Message testMsg(1234); Message testMsg(1234);
skipping to change at line 66 skipping to change at line 66
Int32QueryFilter answerIs37("answer", Int32QueryFilter::OP_EQUAL_TO, 37); Int32QueryFilter answerIs37("answer", Int32QueryFilter::OP_EQUAL_TO, 37);
Int32QueryFilter answerIsNegative("answer", Int32QueryFilter::OP_LESS_THAN, 0 ); Int32QueryFilter answerIsNegative("answer", Int32QueryFilter::OP_LESS_THAN, 0 );
Int32QueryFilter answerIsPositive("answer", Int32QueryFilter::OP_GREATER_THAN , 0); Int32QueryFilter answerIsPositive("answer", Int32QueryFilter::OP_GREATER_THAN , 0);
TestTheMessage(testMsg, "answerIs42", answerIs42); // does field "answer" contain the value 42? TestTheMessage(testMsg, "answerIs42", answerIs42); // does field "answer" contain the value 42?
TestTheMessage(testMsg, "answerIs37", answerIs37); // does field "answer" contain the value 37? TestTheMessage(testMsg, "answerIs37", answerIs37); // does field "answer" contain the value 37?
TestTheMessage(testMsg, "answerIsNegative", answerIsNegative); // does field "answer" contain a value less than 0? TestTheMessage(testMsg, "answerIsNegative", answerIsNegative); // does field "answer" contain a value less than 0?
TestTheMessage(testMsg, "answerIsPositive", answerIsPositive); // does field "answer" contain a value greater than 0? TestTheMessage(testMsg, "answerIsPositive", answerIsPositive); // does field "answer" contain a value greater than 0?
// Lastly we'll compose a few boolean expressions // Lastly we'll compose a few boolean expressions
AndQueryFilter answerIs42AndThereIsPi(ConstQueryFilterRef(&answerIs42, false) , ConstQueryFilterRef(&piExists, false)); AndQueryFilter answerIs42AndThereIsPi((DummyConstQueryFilterRef(answerIs42)), DummyConstQueryFilterRef(piExists)); // extra parens to avoid most-vexing-pars e problem
TestTheMessage(testMsg, "answerIs42AndThereIsPi", answerIs42AndThereIsPi); // does field "answer" contain 42 AND the field "pi" exists? TestTheMessage(testMsg, "answerIs42AndThereIsPi", answerIs42AndThereIsPi); // does field "answer" contain 42 AND the field "pi" exists?
OrQueryFilter answerIs37OrThereIsPi(ConstQueryFilterRef(&answerIs37, false), ConstQueryFilterRef(&piExists, false)); OrQueryFilter answerIs37OrThereIsPi((DummyConstQueryFilterRef(answerIs37)), D ummyConstQueryFilterRef(piExists)); // extra parens to avoid most-vexing-parse problem
TestTheMessage(testMsg, "answerIs37OrThereIsPi", answerIs37OrThereIsPi); // d oes field "answer" contain 37 OR the field "pi" exists? TestTheMessage(testMsg, "answerIs37OrThereIsPi", answerIs37OrThereIsPi); // d oes field "answer" contain 37 OR the field "pi" exists?
OrQueryFilter answerIs37OrThereIsFnord; OrQueryFilter answerIs37OrThereIsFnord;
answerIs37OrThereIsFnord.GetChildren().AddTail(ConstQueryFilterRef(&answerIs3 answerIs37OrThereIsFnord.GetChildren().AddTail(DummyConstQueryFilterRef(answe
7, false)); rIs37));
answerIs37OrThereIsFnord.GetChildren().AddTail(ConstQueryFilterRef(&fnordExis answerIs37OrThereIsFnord.GetChildren().AddTail(DummyConstQueryFilterRef(fnord
ts, false)); Exists));
TestTheMessage(testMsg, "answerIs37OrThereIsFnord", answerIs37OrThereIsFnord) ; // does field "answer" contain 37 OR the field "fnord" exists? TestTheMessage(testMsg, "answerIs37OrThereIsFnord", answerIs37OrThereIsFnord) ; // does field "answer" contain 37 OR the field "fnord" exists?
return 0; return 0;
} }
 End of changes. 4 change blocks. 
7 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)