MCPcopy Create free account
hub / github.com/HumbleNet/HumbleNet / template_find_token

Function template_find_token

src/api_builder/build_csharp.cpp:18–38  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

16 * returns position to resume searching for tokens.
17 */
18size_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
40template< typename T >
41void template_replace_tokens( std::ostream& out, const std::string& _template, T& processToken ) {

Callers 1

template_replace_tokensFunction · 0.85

Calls 1

findMethod · 0.80

Tested by

no test coverage detected