Issue #198: Implement dictionary string expansion

This commit is contained in:
John Reese 2011-03-09 10:41:55 -05:00
parent 3a09f6c1fc
commit df891c0c69
1 changed files with 21 additions and 0 deletions

View File

@ -137,6 +137,27 @@ class CNotifoMod : public CModule
notifo_auth = auth.Base64Encode_n(); 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. * Send a message to the currently-configured Notifo account.
* Requires (and assumes) that the user has already configured their * Requires (and assumes) that the user has already configured their