@@ -36,29 +36,29 @@ ConnectionOptions::ConnectionOptions(const std::string &uri) :
36
36
ConnectionOptions (_parse_uri(uri)) {}
37
37
38
38
ConnectionOptions ConnectionOptions::_parse_uri (const std::string &uri) const {
39
- std::string type ;
39
+ std::string scheme ;
40
40
std::string auth;
41
- std::string path ;
42
- std::tie (type , auth, path ) = _split_uri (uri);
41
+ std::string spath ;
42
+ std::tie (scheme , auth, spath ) = _split_uri (uri);
43
43
44
44
ConnectionOptions opts;
45
45
46
46
_set_auth_opts (auth, opts);
47
47
48
- auto db = 0 ;
48
+ auto db_num = 0 ;
49
49
std::string parameter_string;
50
- std::tie (path, db , parameter_string) = _split_path (path );
50
+ std::tie (spath, db_num , parameter_string) = _split_path (spath );
51
51
52
52
_parse_parameters (parameter_string, opts);
53
53
54
- opts.db = db ;
54
+ opts.db = db_num ;
55
55
56
- if (type == " tcp" ) {
57
- _set_tcp_opts (path , opts);
58
- } else if (type == " unix" ) {
59
- _set_unix_opts (path , opts);
56
+ if (scheme == " tcp" ) {
57
+ _set_tcp_opts (spath , opts);
58
+ } else if (scheme == " unix" ) {
59
+ _set_unix_opts (spath , opts);
60
60
} else {
61
- throw Error (" invalid URI: invalid type " );
61
+ throw Error (" invalid URI: invalid scheme " );
62
62
}
63
63
64
64
return opts;
@@ -167,42 +167,42 @@ auto ConnectionOptions::_split_uri(const std::string &uri) const
167
167
throw Error (" invalid URI: no scheme" );
168
168
}
169
169
170
- auto type = uri.substr (0 , pos);
170
+ auto scheme = uri.substr (0 , pos);
171
171
172
172
auto start = pos + 3 ;
173
173
pos = uri.find (" @" , start);
174
174
if (pos == std::string::npos) {
175
175
// No auth info.
176
- return std::make_tuple (type , std::string{}, uri.substr (start));
176
+ return std::make_tuple (scheme , std::string{}, uri.substr (start));
177
177
}
178
178
179
179
auto auth = uri.substr (start, pos - start);
180
180
181
- return std::make_tuple (type , auth, uri.substr (pos + 1 ));
181
+ return std::make_tuple (scheme , auth, uri.substr (pos + 1 ));
182
182
}
183
183
184
- auto ConnectionOptions::_split_path (const std::string &path ) const
184
+ auto ConnectionOptions::_split_path (const std::string &spath ) const
185
185
-> std::tuple<std::string, int, std::string> {
186
- auto parameter_pos = path .rfind (" ?" );
186
+ auto parameter_pos = spath .rfind (" ?" );
187
187
std::string parameter_string;
188
188
if (parameter_pos != std::string::npos) {
189
- parameter_string = path .substr (parameter_pos + 1 );
189
+ parameter_string = spath .substr (parameter_pos + 1 );
190
190
}
191
191
192
- auto pos = path .rfind (" /" );
192
+ auto pos = spath .rfind (" /" );
193
193
if (pos != std::string::npos) {
194
194
// Might specified a db number.
195
195
try {
196
- auto db = std::stoi (path .substr (pos + 1 ));
196
+ auto db_num = std::stoi (spath .substr (pos + 1 ));
197
197
198
- return std::make_tuple (path .substr (0 , pos), db , parameter_string);
198
+ return std::make_tuple (spath .substr (0 , pos), db_num , parameter_string);
199
199
} catch (const std::exception &) {
200
200
// Not a db number, and it might be a path to unix domain socket.
201
201
}
202
202
}
203
203
204
204
// No db number specified, and use default one, i.e. 0.
205
- return std::make_tuple (path .substr (0 , parameter_pos), 0 , parameter_string);
205
+ return std::make_tuple (spath .substr (0 , parameter_pos), 0 , parameter_string);
206
206
}
207
207
208
208
void ConnectionOptions::_set_auth_opts (const std::string &auth, ConnectionOptions &opts) const {
@@ -221,25 +221,25 @@ void ConnectionOptions::_set_auth_opts(const std::string &auth, ConnectionOption
221
221
}
222
222
}
223
223
224
- void ConnectionOptions::_set_tcp_opts (const std::string &path , ConnectionOptions &opts) const {
224
+ void ConnectionOptions::_set_tcp_opts (const std::string &spath , ConnectionOptions &opts) const {
225
225
opts.type = ConnectionType::TCP;
226
226
227
- auto pos = path .find (" :" );
227
+ auto pos = spath .find (" :" );
228
228
if (pos != std::string::npos) {
229
229
// Port number specified.
230
230
try {
231
- opts.port = std::stoi (path .substr (pos + 1 ));
231
+ opts.port = std::stoi (spath .substr (pos + 1 ));
232
232
} catch (const std::exception &) {
233
233
throw Error (" invalid URI: invalid port" );
234
234
}
235
235
} // else use default port, i.e. 6379.
236
236
237
- opts.host = path .substr (0 , pos);
237
+ opts.host = spath .substr (0 , pos);
238
238
}
239
239
240
- void ConnectionOptions::_set_unix_opts (const std::string &path , ConnectionOptions &opts) const {
240
+ void ConnectionOptions::_set_unix_opts (const std::string &spath , ConnectionOptions &opts) const {
241
241
opts.type = ConnectionType::UNIX;
242
- opts.path = path ;
242
+ opts.path = spath ;
243
243
}
244
244
245
245
class Connection ::Connector {
@@ -404,7 +404,7 @@ void Connection::send(CmdArgs &args) {
404
404
assert (ctx != nullptr );
405
405
406
406
if (redisAppendCommandArgv (ctx,
407
- args.size (),
407
+ static_cast < int >( args.size () ),
408
408
args.argv (),
409
409
args.argv_len ()) != REDIS_OK) {
410
410
throw_error (*ctx, " Failed to send command" );
0 commit comments