LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
home
lsstsw
stack
Linux64
daf_persistence
11.0-1-g7418c06
src
DbStorageLocation.cc
Go to the documentation of this file.
1
// -*- lsst-c++ -*-
2
3
/*
4
* LSST Data Management System
5
* Copyright 2008, 2009, 2010 LSST Corporation.
6
*
7
* This product includes software developed by the
8
* LSST Project (http://www.lsst.org/).
9
*
10
* This program is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
*
20
* You should have received a copy of the LSST License Statement and
21
* the GNU General Public License along with this program. If not,
22
* see <http://www.lsstcorp.org/LegalNotices/>.
23
*/
24
25
37
#ifndef __GNUC__
38
# define __attribute__(x)
/*NOTHING*/
39
#endif
40
static
char
const
* SVNid
__attribute__
((unused)) =
"$Id$"
;
41
42
#include "
lsst/daf/persistence/DbStorageLocation.h
"
43
44
#include <boost/regex.hpp>
45
46
#include "
lsst/pex/exceptions.h
"
47
#include "
lsst/daf/persistence/DbAuth.h
"
48
49
namespace
lsst {
50
namespace
daf {
51
namespace
persistence {
52
55
DbStorageLocation::DbStorageLocation
(
void
) :
56
lsst::daf::base::Citizen(typeid(*this)),
57
_dbType(), _hostname(), _port(), _username(), _password(), _dbName() {
58
}
59
64
DbStorageLocation::DbStorageLocation
(std::string
const
& url) :
65
lsst::daf::base::Citizen(typeid(*this)) {
66
boost::smatch what;
67
boost::regex
68
expression(
"(\\w+)://(\\S+):(\\d+)/(\\S+)"
);
69
if
(boost::regex_match(url, what, expression)) {
70
_dbType
= what[1];
71
_hostname
= what[2];
72
_port
= what[3];
73
_dbName
= what[4];
74
_username
=
DbAuth::username
(
_hostname
,
_port
);
75
_password
=
DbAuth::password
(
_hostname
,
_port
);
76
}
77
else
{
78
throw
LSST_EXCEPT
(lsst::pex::exceptions::InvalidParameterError,
79
"Unparseable connection string passed to DbStorageLocation: "
+
80
url);
81
}
82
}
83
86
DbStorageLocation::~DbStorageLocation
(
void
) {
87
}
88
92
std::string
DbStorageLocation::toString
(
void
)
const
{
93
return
_dbType
+
"://"
+
_username
+
":"
+
_password
+
"@"
+
94
_hostname
+
":"
+
_port
+
"/"
+
_dbName
;
95
}
96
101
std::string
DbStorageLocation::getConnString
(
void
)
const
{
102
return
_dbType
+
"://"
+
_hostname
+
":"
+
_port
+
"/"
+
_dbName
;
103
}
104
108
std::string
const
&
DbStorageLocation::getDbType
(
void
)
const
{
109
return
_dbType
;
110
}
111
115
std::string
const
&
DbStorageLocation::getHostname
(
void
)
const
{
116
return
_hostname
;
117
}
118
122
std::string
const
&
DbStorageLocation::getPort
(
void
)
const
{
123
return
_port
;
124
}
125
129
std::string
const
&
DbStorageLocation::getUsername
(
void
)
const
{
130
return
_username
;
131
}
132
136
std::string
const
&
DbStorageLocation::getPassword
(
void
)
const
{
137
return
_password
;
138
}
139
143
std::string
const
&
DbStorageLocation::getDbName
(
void
)
const
{
144
return
_dbName
;
145
}
146
147
}}}
// namespace lsst::daf::persistence
DbAuth.h
Interface for DbAuth class.
lsst::daf::persistence::DbStorageLocation::toString
virtual std::string toString(void) const
Definition:
DbStorageLocation.cc:92
lsst::daf::persistence::DbStorageLocation::_dbType
std::string _dbType
Database type (e.g. "mysql").
Definition:
DbStorageLocation.h:76
__attribute__
#define __attribute__(x)
Definition:
DbStorageLocation.cc:38
exceptions.h
Include files required for standard LSST Exception handling.
lsst::daf::persistence::DbStorageLocation::DbStorageLocation
DbStorageLocation(void)
Definition:
DbStorageLocation.cc:55
lsst::daf::persistence::DbStorageLocation::getPort
virtual std::string const & getPort(void) const
Definition:
DbStorageLocation.cc:122
lsst::daf::persistence::DbStorageLocation::getDbType
virtual std::string const & getDbType(void) const
Definition:
DbStorageLocation.cc:108
lsst::daf::persistence::DbStorageLocation::getConnString
virtual std::string getConnString(void) const
Definition:
DbStorageLocation.cc:101
lsst::daf::persistence::DbStorageLocation::~DbStorageLocation
virtual ~DbStorageLocation(void)
Definition:
DbStorageLocation.cc:86
lsst::daf::persistence::DbStorageLocation::_port
std::string _port
Definition:
DbStorageLocation.h:78
lsst::daf::persistence::DbStorageLocation::getPassword
virtual std::string const & getPassword(void) const
Definition:
DbStorageLocation.cc:136
lsst::daf::persistence::DbStorageLocation::_username
std::string _username
Definition:
DbStorageLocation.h:79
lsst::daf::persistence::DbStorageLocation::getHostname
virtual std::string const & getHostname(void) const
Definition:
DbStorageLocation.cc:115
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Definition:
Exception.h:46
lsst::daf::persistence::DbAuth::username
static std::string username(std::string const &host, std::string const &port)
Definition:
DbAuth.cc:158
lsst::daf::persistence::DbAuth::password
static std::string password(std::string const &host, std::string const &port)
Definition:
DbAuth.cc:169
lsst::daf::persistence::DbStorageLocation::_dbName
std::string _dbName
Database (not server) name.
Definition:
DbStorageLocation.h:81
lsst::daf::persistence::DbStorageLocation::_hostname
std::string _hostname
Definition:
DbStorageLocation.h:77
lsst::daf::persistence::DbStorageLocation::getDbName
virtual std::string const & getDbName(void) const
Definition:
DbStorageLocation.cc:143
lsst::daf::persistence::DbStorageLocation::getUsername
virtual std::string const & getUsername(void) const
Definition:
DbStorageLocation.cc:129
lsst::daf::persistence::DbStorageLocation::_password
std::string _password
Definition:
DbStorageLocation.h:80
DbStorageLocation.h
Interface for DbStorageLocation class.
Generated on Thu Sep 24 2015 02:29:19 for LSSTApplications by
1.8.5