* find the next token replacement. * * start - where the search should start in the template, if a match is found start is updated to point to the start of the match. * token - the found token * * returns position to resume searching for tokens. */
| 16 | * returns position to resume searching for tokens. |
| 17 | */ |
| 18 | size_t template_find_token( const std::string& tpl, size_t& pos, std::string& token ) { |
| 19 | size_t start = tpl.find("@", pos); |
| 20 | if( start == tpl.npos ) |
| 21 | return tpl.npos; |
| 22 | |
| 23 | size_t end = tpl.find("@", start+1); |
| 24 | if( end == tpl.npos ) |
| 25 | return tpl.npos; |
| 26 | |
| 27 | // ignore @@ |
| 28 | if( end - start == 1 ) { |
| 29 | pos = end+1; |
| 30 | return template_find_token( tpl, pos, token ); |
| 31 | } |
| 32 | |
| 33 | token = tpl.substr(start+1, end - start-1); |
| 34 | |
| 35 | pos = start; |
| 36 | |
| 37 | return end+1; |
| 38 | } |
| 39 | |
| 40 | template< typename T > |
| 41 | void template_replace_tokens( std::ostream& out, const std::string& _template, T& processToken ) { |
no test coverage detected