- bool connection::option(const string &key, const string &val) {
- // No way to tell whether ZOOM_connection_option_set() accepts key
- ZOOM_connection_option_set(c, key.c_str(), val.c_str());
- return true;
+ connection::connection(const std::string &hostname, int portnum) {
+ ZOOM_options o = ZOOM_options_create();
+ c = ZOOM_connection_create(o);
+ connect(hostname, portnum);
+ }
+
+ std::string connection::option(const std::string &key) const {
+ const char* val = ZOOM_connection_option_get(c, key.c_str());
+ return (val) ? val : std::string();
+ }
+
+ bool connection::option(const std::string &key, const std::string &val) {
+ // No way to tell whether ZOOM_connection_option_set() accepts key
+ ZOOM_connection_option_set(c, key.c_str(), val.c_str());
+ return true;