bool listAll(SDBConnectionPtr aSDB){ try { ListDomainsResponsePtr lRes = aSDB->listDomains(); std::cout << "list domains successfully" << std::endl; lRes->open(); std::string lDomain; while (lRes->next (lDomain)) { std::cout << " Domain: " << lDomain << std::endl; SDBQueryResponsePtr lRes = aSDB->query (lDomain, ""); int lCounter = 0; lRes->open(); std::string lItem; while (lRes->next (lItem)) { std::cout << " " << ++lCounter << ". Item: " << lItem; GetAttributesResponsePtr lRes = aSDB->getAttributes (lDomain, lItem); lRes->open(); std::pair<std::string, std::string> lAttr; while (lRes->next (lAttr)) { std::cout << " " << lAttr.first << ":" << lAttr.second ; } lRes->close(); std::cout << std::endl; } lRes->close(); } lRes->close(); } catch (ListDomainsException &e) { std::cerr << e.what() << std::endl; return false; } return true; }
bool query (SDBConnectionPtr aSDB, const std::string& aDomainName, const std::string& aQueryExpression, int aMaxNumberOfItems = 0, const std::string & aNextToken = "") { try { SDBQueryResponsePtr lRes = aSDB->query (aDomainName, aQueryExpression, aMaxNumberOfItems, aNextToken); std::cout << "query successfully" << std::endl; lRes->open(); std::string lItem; while (lRes->next (lItem)) { std::cout << " Item: " << lItem << std::endl; } lRes->close(); } catch (PutAttributesException &e) { std::cerr << e.what() << std::endl; return false; } return true; }
int query(SDBConnection* lCon) { try { std::string query("['amount'<'6']"); SDBQueryResponsePtr lPtr = lCon->query("testDomain", query); std::cout << "Query result for query " << query << ": " << std::endl; lPtr->open(); std::string name; while (lPtr->next(name)) { std::cout << name << std::endl; } printBoxUsage(*lPtr); } catch (QueryException& e) { std::cerr << "Couldn't query the query" << std::endl; std::cerr << e.what() << std::endl; return 1; } return 0; }