X-Git-Url: http://git.vrable.net/?p=cumulus.git;a=blobdiff_plain;f=util.cc;h=1f922dfde607d2debf87970db02adb5bc667cd84;hp=a51fa3d744b1d702d4bbd231cb783a4d65598142;hb=6bb973b965a30832c3e2d9f6a24e80d3309ef89e;hpb=6c94114148c42e795b8abbef9532f399c24f3ed5 diff --git a/util.cc b/util.cc index a51fa3d..1f922df 100644 --- a/util.cc +++ b/util.cc @@ -99,12 +99,21 @@ long long parse_int(const string &s) return strtoll(s.c_str(), NULL, 0); } -/* Output a dictionary of string key/value pairs to the given output stream. - * The format is a sequence of lines of the form "key: value". */ -void dict_output(ostream &o, map dict) +/* Encode a dictionary of string key/value pairs into a sequence of lines of + * the form "key: value". */ +string encode_dict(const map& dict) { + string result; for (map::const_iterator i = dict.begin(); i != dict.end(); ++i) { - o << i->first << ": " << i->second << "\n"; + result += i->first + ": " + i->second + "\n"; } + return result; +} + +/* Output a dictionary of string key/value pairs to the given output stream. + * The format is a sequence of lines of the form "key: value". */ +void dict_output(ostream &o, const map& dict) +{ + o << encode_dict(dict); }