~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/server_detect.h

  • Committer: Olaf van der Spek
  • Date: 2011-08-04 08:13:04 UTC
  • mfrom: (2384 drizzle)
  • mto: This revision was merged to the branch mainline in revision 2385.
  • Revision ID: olafvdspek@gmail.com-20110804081304-rlejjpvoos17bjdf
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#ifndef CLIENT_SERVER_DETECT_H
22
 
#define CLIENT_SERVER_DETECT_H
 
21
#pragma once
23
22
 
24
23
#include <boost/regex.hpp>
25
 
#include <iostream>
 
24
#include <iosfwd>
26
25
 
27
26
class ServerDetect
28
27
{
36
35
    server_type getServerType() { return type; }
37
36
    std::string& getServerVersion() { return version; }
38
37
 
39
 
    ServerDetect(drizzle_con_st *connection) :
40
 
      type(SERVER_UNKNOWN_FOUND),
41
 
      version("")
42
 
    {
43
 
      boost::match_flag_type flags = boost::match_default;
44
 
 
45
 
      boost::regex mysql_regex("^([3-9]\\.[0-9]+\\.[0-9]+)");
46
 
      boost::regex drizzle_regex("^(20[0-9]{2}\\.(0[1-9]|1[012])\\.[0-9]+)");
47
 
 
48
 
      version= drizzle_con_server_version(connection);
49
 
 
50
 
      if (regex_search(version, drizzle_regex, flags))
51
 
      {
52
 
        type= SERVER_DRIZZLE_FOUND;
53
 
      }
54
 
      else if (regex_search(version, mysql_regex, flags))
55
 
      {
56
 
        type= SERVER_MYSQL_FOUND;
57
 
      }
58
 
      else
59
 
      {
60
 
        std::cerr << "Server version not detectable. Assuming MySQL." << std::endl;
61
 
        type= SERVER_MYSQL_FOUND;
62
 
      }
63
 
    }
 
38
    ServerDetect(drizzle_con_st *connection);
64
39
 
65
40
  private:
66
41
    server_type type;
67
42
    std::string version;
68
43
};
69
 
 
70
 
#endif /* CLIENT_SERVER_DETECT_H */