CppDB
cppdb/utils.h
00001 
00002 //                                                                             
00003 //  Copyright (C) 2010-2011  Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>     
00004 //                                                                             
00005 //  Distributed under:
00006 //
00007 //                   the Boost Software License, Version 1.0.
00008 //              (See accompanying file LICENSE_1_0.txt or copy at 
00009 //                     http://www.boost.org/LICENSE_1_0.txt)
00010 //
00011 //  or (at your opinion) under:
00012 //
00013 //                               The MIT License
00014 //                 (See accompanying file MIT.txt or a copy at
00015 //              http://www.opensource.org/licenses/mit-license.php)
00016 //
00018 #ifndef CPPDB_UTIL_H
00019 #define CPPDB_UTIL_H
00020 
00021 #include <cppdb/defs.h>
00022 #include <string>
00023 #include <ctime>
00024 #include <map>
00025 
00026 
00027 namespace cppdb {
00028 
00034         CPPDB_API std::tm parse_time(char const *value);
00040         CPPDB_API std::string format_time(std::tm const &v);
00046         CPPDB_API std::tm parse_time(std::string const &v);
00047 
00065         CPPDB_API void parse_connection_string( std::string const &cs,
00066                                                 std::string &driver_name,
00067                                                 std::map<std::string,std::string> &props);
00068 
00072         class CPPDB_API connection_info {
00073         public:
00077                 std::string connection_string;
00081                 std::string driver;
00085                 typedef std::map<std::string,std::string> properties_type;
00089                 properties_type properties;
00090                 
00094                 bool has(std::string const &prop) const;
00098                 std::string get(std::string const &prop,std::string const &default_value=std::string()) const;
00103                 int get(std::string const &prop,int default_value) const;
00104         
00108                 connection_info()
00109                 {
00110                 }
00114                 explicit connection_info(std::string const &cs) :
00115                         connection_string(cs)
00116                 {
00117                         parse_connection_string(cs,driver,properties);
00118                 }
00119 
00120         };
00121 
00122 }
00123 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator