5 #include <boost/regex.hpp> 6 #include <mysql++/mysql++.h> 10 static const boost::regex expr(
"(([[:word:].-]+)(:(.+))?@)?([[:word:].-]+)(:([[:digit:]]+))?(/([[:word:].-]+))");
18 if (!boost::regex_match(database, what, expr, boost::match_extra))
19 throw runtime_error(
"Couldn't parse '"+database+
"'.");
22 throw runtime_error(
"Error parsing '"+database+
"'.");
24 const string user = what[2];
25 const string passwd = what[4];
26 const string server = what[5];
27 const string db = what[9];
28 const int port = atoi(
string(what[7]).c_str());
30 mysqlpp::Connection conn(db.c_str(), server.c_str(), user.c_str(), passwd.c_str(), port);
32 const mysqlpp::StoreQueryResult res =
33 conn.query(
"SELECT fPatchNumber, AVG(fVoltageNom), fOffset " 35 " LEFT JOIN BiasOffsets USING(fPatchNumber) " 36 " GROUP BY fPatchNumber").store();
41 for (vector<mysqlpp::Row>::const_iterator v=res.begin(); v<res.end(); v++)
43 const int id = (*v)[0];
48 str <<
"Invalid channel id " <<
id <<
" received from database.";
49 throw runtime_error(str.str());
55 entry.hv_channel =
id%32;
65 throw runtime_error(
"Number of rows retrieved from the database does not match 416.");
68 throw runtime_error(
"Number of entries retrived from database does not match 416.");
void Retrieve(const std::string &database)