| Example Program ModView How to modify strings with a per-character functor. Remarks Take a look at the file seqan/modifier/modifier_functors.h to see what functors are already part of SeqAn. File "modifier_modview.cpp"
1 | #include <iostream>
2 | #include <seqan/file.h>
3 | #include <seqan/modifier.h>
4 |
5 | using namespace std;
6 | using namespace seqan;
7 |
8 | struct MyFunctor : public unary_function<char,char>
9 | {
10 | inline char operator()(char x) const
11 | {
12 | if (('a' <= x) && (x <= 'z')) return (x + ('A' - 'a'));
13 | return x;
14 | }
15 | };
16 |
17 |
18 | int main ()
19 | {
20 | String<char> myString = "A man, a plan, a canal-Panama";
21 | ModifiedString< String<char>, ModView<MyFunctor> > myModifier(myString);
22 |
23 | cout << myString << endl;
24 | cout << myModifier << endl;
25 |
26 | infix(myString, 9, 9) = "master ";
27 |
28 | cout << myString << endl;
29 | cout << myModifier << endl;
30 |
31 | return 0;
32 | }
Output weese@tanne:~/seqan$ cd demos weese@tanne:~/seqan/demos$ make modifier_modview weese@tanne:~/seqan/demos$ ./modifier_modview A man, a plan, a canal-Panama A MAN, A PLAN, A CANAL-PANAMA A man, a master plan, a canal-Panama A MAN, A MASTER PLAN, A CANAL-PANAMA weese@tanne:~/seqan/demos$ See ModifiedString, ModView, String SeqAn - Sequence Analysis Library - www.seqan.de