sptk2 logo
SPTK Home Page
DatabaseConnectionString.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <sptk5/Strings.h>
30#include <sptk5/net/HttpParams.h>
31
32namespace sptk {
33
56{
57public:
62 explicit DatabaseConnectionString(const String& connectionString = "")
63 : m_connectionString(connectionString)
64 {
65 if (!m_connectionString.empty())
66 {
67 parse();
68 }
69 }
70
76
82
87
91 const String& driverName() const
92 {
93 return m_driverName;
94 }
95
99 const String& hostName() const
100 {
101 return m_hostName;
102 }
103
107 const String& userName() const
108 {
109 return m_userName;
110 }
111
115 const String& password() const
116 {
117 return m_password;
118 }
119
123 const String& databaseName() const
124 {
125 return m_databaseName;
126 }
127
131 const String& schema() const
132 {
133 return m_schema;
134 }
135
139 uint16_t portNumber() const
140 {
141 return m_portNumber;
142 }
143
148 void userName(const String& user)
149 {
150 m_userName = user;
151 }
152
157 void password(const String& pass)
158 {
159 m_password = pass;
160 }
161
167 String parameter(const String& name) const;
168
172 bool empty() const;
173
174protected:
178 void parse();
179
180private:
184 String m_connectionString;
185
189 String m_hostName;
190
194 uint16_t m_portNumber {0};
195
199 String m_userName;
200
204 String m_password;
205
209 String m_databaseName;
210
214 String m_schema;
215
219 HttpParams m_parameters;
220
224 String m_driverName;
225};
226
227using SDatabaseConnectionString = std::shared_ptr<DatabaseConnectionString>;
228
232} // namespace sptk
Definition: DatabaseConnectionString.h:56
DatabaseConnectionString & operator=(const DatabaseConnectionString &cs)=default
DatabaseConnectionString(const String &connectionString="")
Definition: DatabaseConnectionString.h:62
uint16_t portNumber() const
Definition: DatabaseConnectionString.h:139
String parameter(const String &name) const
const String & userName() const
Definition: DatabaseConnectionString.h:107
const String & hostName() const
Definition: DatabaseConnectionString.h:99
const String & databaseName() const
Definition: DatabaseConnectionString.h:123
DatabaseConnectionString(const DatabaseConnectionString &cs)=default
void password(const String &pass)
Definition: DatabaseConnectionString.h:157
const String & driverName() const
Definition: DatabaseConnectionString.h:91
void userName(const String &user)
Definition: DatabaseConnectionString.h:148
const String & schema() const
Definition: DatabaseConnectionString.h:131
const String & password() const
Definition: DatabaseConnectionString.h:115
Definition: HttpParams.h:69
Definition: String.h:49

Fri Oct 14 2022 09:58:31: SPTK 5.4.1