- const char *connection::option(const char *key, const char *val) {
- // ### There may be memory-management issues here.
- const char *old = ZOOM_connection_option_get(c, key);
- ZOOM_connection_option_set(c, key, val);
- return old;
+ 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;