+/* Encode a dictionary of string key/value pairs into a sequence of lines of
+ * the form "key: value". If it exists, the key "name" is treated specially
+ * and will be listed first. */
+static string encode_dict(const map<string, string>& dict)
+{
+ string result;
+
+ if (dict.find("name") != dict.end()) {
+ result += "name: " + dict.at("name") + "\n";
+ }
+
+ for (map<string, string>::const_iterator i = dict.begin();
+ i != dict.end(); ++i) {
+ if (i->first == "name")
+ continue;
+ result += i->first + ": " + i->second + "\n";
+ }
+
+ return result;
+}
+