| 39 | |
| 40 | template< typename T > |
| 41 | void template_replace_tokens( std::ostream& out, const std::string& _template, T& processToken ) { |
| 42 | size_t start = 0; |
| 43 | size_t end = 0; |
| 44 | size_t last = 0; |
| 45 | |
| 46 | std::string token; |
| 47 | |
| 48 | while( ( end = template_find_token( _template, start, token ) ) != _template.npos ) { |
| 49 | // write content just before the found token |
| 50 | if( start-last > 0 ) |
| 51 | out.write( _template.c_str() + last, start-last ); |
| 52 | |
| 53 | processToken( out, token ); |
| 54 | |
| 55 | start = last = end; |
| 56 | } |
| 57 | |
| 58 | // write anything remaining. |
| 59 | if( start < _template.length() ) |
| 60 | out.write( _template.c_str() + last, _template.length() - last ); |
| 61 | } |
| 62 | |
| 63 | static bool has_option( json_value* options, const std::string& option ) { |
| 64 | if( !options ) |
no test coverage detected