connection-parameters.cpp
Go to the documentation of this file.
1 //
2 // Copyright (C) 2013 Vadim Zeitlin
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 //
7 
8 #define SOCI_SOURCE
10 #include "soci-backend.h"
11 #include "backend-loader.h"
12 
13 using namespace soci;
14 
15 namespace // anonymous
16 {
17 
18 void parseConnectString(std::string const & connectString,
19  std::string & backendName,
20  std::string & connectionParameters)
21 {
22  std::string const protocolSeparator = "://";
23 
24  std::string::size_type const p = connectString.find(protocolSeparator);
25  if (p == std::string::npos)
26  {
27  throw soci_error("No backend name found in " + connectString);
28  }
29 
30  backendName = connectString.substr(0, p);
31  connectionParameters = connectString.substr(p + protocolSeparator.size());
32 }
33 
34 } // namespace anonymous
35 
37  : factory_(NULL)
38 {
39 }
40 
42  std::string const & connectString)
43  : factory_(&factory), connectString_(connectString)
44 {
45 }
46 
47 connection_parameters::connection_parameters(std::string const & backendName,
48  std::string const & connectString)
49  : factory_(&dynamic_backends::get(backendName)), connectString_(connectString)
50 {
51 }
52 
53 connection_parameters::connection_parameters(std::string const & fullConnectString)
54 {
55  std::string backendName;
56  std::string connectString;
57 
58  parseConnectString(fullConnectString, backendName, connectString);
59 
60  factory_ = &dynamic_backends::get(backendName);
62 }
backend_factory const & get(std::string const &name)
std::string connectString
Definition: test-db2.cpp:21
backend_factory const * factory_


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:40