3 #ifndef STREAMBASE_URI_H
4 #define STREAMBASE_URI_H
6 #include "StreamBase.hpp"
8 #include "Exceptions.hpp"
13 SB_INTERNAL_FWD(Errors);
14 SB_INTERNAL_FWD(StreamBaseURIUtil);
40 static const unsigned int DEFAULT_PORT = 10000;
70 static const unsigned int DEFAULT_NODE_MANAGER_PORT = 10002;
71 static const char *
const ENVIRONMENT_VARIABLE;
73 static const char *
const URI_ENVIRONMENT_VARIABLE;
75 static const char *
const URI_PROPERTY_NAME;
79 typedef std::map<std::string, std::string> ParamMap;
83 std::string _container;
95 StreamBaseURI(
const std::string &host,
unsigned int port,
const std::string &user =
"",
const std::string &password =
"");
98 StreamBaseURI(
const std::string &host,
const std::string &container,
unsigned int port,
const std::string &user =
"",
const std::string &password =
"");
101 StreamBaseURI(
const std::string &host,
unsigned int port,
const ParamMap ¶mMap)
102 : _host(host), _port(port), _container(NO_CONTAINER)
104 copy(paramMap.begin(), paramMap.end(), inserter(_params, _params.begin()));
109 StreamBaseURI(
const std::string &host,
const std::string &container,
unsigned int port,
const ParamMap ¶mMap)
110 : _host(host), _port(port), _container(container)
112 copy(paramMap.begin(), paramMap.end(), inserter(_params, _params.begin()));
119 static std::vector<StreamBaseURI> vectorFromString(
const std::string& uris);
122 static std::string as_string(
const std::vector<StreamBaseURI> &uris);
125 std::string as_string()
const;
135 unsigned int getPort()
const {
return _port; }
138 std::string
getUser()
const {
return getParameter(USER_PARAM); }
141 std::string
getPassword()
const {
return getParameter(PASSWORD_PARAM); }
144 std::string
getParameter(
const std::string &key)
const {
return NMSTL::lookup(_params, key); }
147 std::string
getParam(
const std::string &key)
const {
return NMSTL::lookup(_params, key); }
152 bool getParameter(
const std::string &key, std::string& value)
const;
155 void addParameter(
const std::string &key,
const std::string &value) { _params[key] = value; }
164 operator const void *()
const {
return _host.empty() ? 0 :
this; }
170 static std::vector < StreamBaseURI > vectorFromEnvironment();
176 void init(NMSTL::Address address,
const std::string &container);
178 void processParams(
const std::string &uri, std::string::size_type paramsPos);
183 int auth(
const std::string& user,
const std::string& password);
185 friend class sb_internal::StreamBaseURIUtil;
190 inline std::ostream& operator << (std::ostream& os,
const sb::StreamBaseURI& uri) {