------------------------------------------------------------ revno: 9 committer: poy <p...@123gen.com> branch nick: TestPlugin timestamp: Tue 2013-01-29 20:15:05 +0100 message: add a test for the tagger text replacement function modified: src/Plugin.cpp
-- lp:~dcplusplus-team/dcpp-plugin-sdk-cpp/TestPlugin https://code.launchpad.net/~dcplusplus-team/dcpp-plugin-sdk-cpp/TestPlugin Your team Dcplusplus-team is subscribed to branch lp:~dcplusplus-team/dcpp-plugin-sdk-cpp/TestPlugin. To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcpp-plugin-sdk-cpp/TestPlugin/+edit-subscription
=== modified file 'src/Plugin.cpp' --- src/Plugin.cpp 2013-01-29 18:25:58 +0000 +++ src/Plugin.cpp 2013-01-29 19:15:05 +0000 @@ -112,5 +112,19 @@ end = start + pattern.size(); Tagger::handle()->add_tag(tags, start, end, "b", ""); } + + // replace instances of replPattern by replText. + const string replPattern = "BC"; + const string replText = "haha"; + + const auto delta = static_cast<int>(replText.size()) - static_cast<int>(replPattern.size()); + int offset = 0; + + end = 0; + while((start = text.find(replPattern, end)) != string::npos) { + end = start + replPattern.size(); + Tagger::handle()->replace_text(tags, start + offset, end + offset, replText.c_str()); + offset += delta; + } return true; }
_______________________________________________ Mailing list: https://launchpad.net/~linuxdcpp-team Post to : linuxdcpp-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~linuxdcpp-team More help : https://help.launchpad.net/ListHelp