FACT++  1.0
DatabaseName::DatabaseName ( const std::string &  database)
inline

Definition at line 17 of file Database.h.

18  {
19  static const boost::regex expr("(([[:word:].-]+)(:(.+))?@)?([[:word:].-]+)(:([[:digit:]]+))?(/([[:word:].-]+))");
20 
21  boost::smatch what;
22  if (!boost::regex_match(database, what, expr, boost::match_extra))
23  throw std::runtime_error("Couldn't parse database URI '"+database+"'.");
24 
25  if (what.size()!=10)
26  throw std::runtime_error("Error parsing database URI '"+database+"'.");
27 
28  user = what[2];
29  passwd = what[4];
30  server = what[5];
31  db = what[9];
32 
33  try
34  {
35  port = stoi(std::string(what[7]));
36  }
37  catch (...)
38  {
39  port = 0;
40  }
41  }
std::string user
Definition: Database.h:11
std::string db
Definition: Database.h:14
std::string passwd
Definition: Database.h:12
std::string server
Definition: Database.h:13