- Timestamp:
- 08/03/18 13:42:22 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Database.h
r14404 r19124 4 4 #include <exception> 5 5 #include <boost/regex.hpp> 6 #include <boost/algorithm/string.hpp> 6 7 7 8 #include <mysql++/mysql++.h> … … 14 15 std::string db; 15 16 int port; 17 char compression; 16 18 17 DatabaseName(const std::string &database) 19 DatabaseName(const std::string &database) : compression(0) 18 20 { 19 static const boost::regex expr("(([[:word:].-]+)(:(.+))?@)?([[:word:].-]+)(:([[:digit:]]+))?(/([[:word:].-]+)) ");21 static const boost::regex expr("(([[:word:].-]+)(:(.+))?@)?([[:word:].-]+)(:([[:digit:]]+))?(/([[:word:].-]+))(/[+-])?"); 20 22 21 23 boost::smatch what; … … 23 25 throw std::runtime_error("Couldn't parse database URI '"+database+"'."); 24 26 25 if (what.size()!=1 0)27 if (what.size()!=11) 26 28 throw std::runtime_error("Error parsing database URI '"+database+"'."); 27 29 … … 30 32 server = what[5]; 31 33 db = what[9]; 34 35 compression = std::string(what[10])[1]; 32 36 33 37 try … … 59 63 public: 60 64 Database(const std::string &desc) : DatabaseName(desc), 61 mysqlpp::Connection( db.c_str(), server.c_str(), user.c_str(), passwd.c_str(), port)65 mysqlpp::Connection() 62 66 { 67 if ((compression!='-' && boost::algorithm::to_lower_copy(server)!="localhost" && server!="127.0.0.1")|| 68 compression=='+') 69 set_option(new mysqlpp::CompressOption()); 70 71 // Connect to the database 72 connect(db.c_str(), server.c_str(), user.c_str(), passwd.c_str(), port); 63 73 } 64 74 };
Note:
See TracChangeset
for help on using the changeset viewer.