#include "KM3NeTDBClient.h" #include #include #include using namespace std; using namespace KM3NeT; using namespace KM3NeT::DB; int main(int argc, char *argv[]) { if (argc < 4) { cout << endl << "usage: ex3 { }" << endl << "relational operators are: = != <> < > <= >=" << endl << "NOTICE: angled brackets must be enclosed in quotes (') to avoid mismatch with redirection operators. For examples SERIALNUMBER<34 must be written SERIALNUMBER '<' 34" << endl; return -1; } try { std::vector sels; unsigned i; for (i = 4; i + 2 < (unsigned) argc; i += 3) { Selector::RelOp const *pRO = nullptr; if (strcmp(argv[i + 1], "=") == 0) pRO = &Selector::RelOp::Equal; else if (strcmp(argv[i + 1], "!=") == 0 || strcmp(argv[i + 1], "<>") == 0) pRO = &Selector::RelOp::Different; else if (strcmp(argv[i + 1], "<") == 0) pRO = &Selector::RelOp::Less; else if (strcmp(argv[i + 1], "<=") == 0) pRO = &Selector::RelOp::LessEqual; else if (strcmp(argv[i + 1], ">") == 0) pRO = &Selector::RelOp::Greater; else if (strcmp(argv[i + 1], ">=") == 0) pRO = &Selector::RelOp::GreaterEqual; else throw DBException("Unknown relational operator", __LINE__); Selector s(argv[i], argv[i + 2], *pRO); sels.push_back(s); } auto client = Client::Create(Server::Default, argv[1], argv[2]); auto &rs = client->StreamDS(argv[3], sels); cout << endl << rs.FieldCount() << " fields found." << endl; for (i = 0; i < rs.FieldCount(); i++) { cout << rs.FieldName(i) << " "; } while (rs.Next()) { cout << endl; for (i = 0; i < rs.FieldCount(); i++) { cout << "\"" << rs.GetString(i) << "\" "; } } rs.Close(); } catch (DBException &x) { cout << endl << x.what() << endl; } return 0; }