[Swift-commit] cog r4044

swift at ci.uchicago.edu swift at ci.uchicago.edu
Wed Aug 27 17:35:06 CDT 2014


------------------------------------------------------------------------
r4044 | timgarmstrong | 2014-08-27 17:30:27 -0500 (Wed, 27 Aug 2014) | 1 line

Add feature to remove settings
------------------------------------------------------------------------
Index: modules/provider-coaster-c-client/src/coaster.cpp
===================================================================
--- modules/provider-coaster-c-client/src/coaster.cpp	(revision 4043)
+++ modules/provider-coaster-c-client/src/coaster.cpp	(working copy)
@@ -234,6 +234,19 @@
 }
 
 coaster_rc
+coaster_settings_remove(coaster_settings *settings,
+          const char *key, size_t key_len) COASTER_THROWS_NOTHING {
+  try {
+    settings->remove(key, key_len);
+    return COASTER_SUCCESS;
+  } catch (const CoasterError& err) {
+    return coaster_error_rc(err);
+  } catch (const std::exception& ex) {
+    return exception_rc(ex);
+  }
+}
+
+coaster_rc
 coaster_settings_get(coaster_settings *settings,
             const char *key, size_t key_len,
             const char **value, size_t *value_len) COASTER_THROWS_NOTHING {
Index: modules/provider-coaster-c-client/src/Settings.h
===================================================================
--- modules/provider-coaster-c-client/src/Settings.h	(revision 4043)
+++ modules/provider-coaster-c-client/src/Settings.h	(working copy)
@@ -34,6 +34,7 @@
 		void set(const char* key, size_t key_len,
 			 const char* value, size_t value_len);
 		void remove(const std::string& key);
+		void remove(const char* key, size_t key_len);
 		
 		bool contains(const std::string& key);
 
Index: modules/provider-coaster-c-client/src/Settings.cpp
===================================================================
--- modules/provider-coaster-c-client/src/Settings.cpp	(revision 4043)
+++ modules/provider-coaster-c-client/src/Settings.cpp	(working copy)
@@ -60,6 +60,10 @@
 	settings.erase(key);
 }
 
+void Settings::remove(const char* key, size_t key_len) {
+	settings.erase(key);
+}
+
 bool Settings::contains(const string& key) {
 	return settings.find(key) != settings.end();
 }
Index: modules/provider-coaster-c-client/src/coaster.h
===================================================================
--- modules/provider-coaster-c-client/src/coaster.h	(revision 4043)
+++ modules/provider-coaster-c-client/src/coaster.h	(working copy)
@@ -148,14 +148,25 @@
 coaster_rc
 coaster_settings_parse(coaster_settings *settings, const char *str,
              size_t str_len, char separator) COASTER_THROWS_NOTHING;
+
 /*
- * Set settings individually.
+ * Set settings individually.  Will overwrite previous values.
+ * key[_len]: settings key (must be non-null)
+ * values[_len]: settings value (must be non-null)
  */
 coaster_rc
 coaster_settings_set(coaster_settings *settings,
             const char *key, size_t key_len,
             const char *value, size_t value_len) COASTER_THROWS_NOTHING;
 /*
+ * Erase a key/value pair in settings.
+ * key[_len]: settings key (must be non-null)
+ */
+coaster_rc
+coaster_settings_remove(coaster_settings *settings,
+            const char *key, size_t key_len) COASTER_THROWS_NOTHING;
+
+/*
  * Get settings individually.
  * value[_len]: set to value of string, null if not present in settings.
  *      Settings retains ownership of strings: any subsequent



More information about the Swift-commit mailing list