Skip to content

Commit

Permalink
Issue #198: Implement dictionary string expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
amyreese committed Mar 9, 2011
1 parent 3a09f6c commit df891c0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions notifo.cpp
Expand Up @@ -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
Expand Down

0 comments on commit df891c0

Please sign in to comment.