From df891c0c698c3aa4a3e0b4b516d29f897f4d467b Mon Sep 17 00:00:00 2001 From: John Reese Date: Wed, 9 Mar 2011 10:41:55 -0500 Subject: [PATCH] Issue #198: Implement dictionary string expansion --- notifo.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/notifo.cpp b/notifo.cpp index bd5efee..ce92bf5 100644 --- a/notifo.cpp +++ b/notifo.cpp @@ -137,6 +137,27 @@ class CNotifoMod : public CModule notifo_auth = auth.Base64Encode_n(); } + /** + * Performs string expansion on a set of keywords. + * Given an initial string and a dictionary of string replacments, + * iterate over the dictionary, expanding keywords one-by-one. + * + * @param content String contents + * @param replace Dictionary of string replacements + * @return Result of string replacements + */ + CString expand(const CString& content, MCString& replace) + { + CString result = content.c_str(); + + for(MCString::iterator i = replace.begin(); i != replace.end(); i++) + { + result.Replace(i->first, i->second); + } + + return result; + } + /** * Send a message to the currently-configured Notifo account. * Requires (and assumes) that the user has already configured their