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

Function template_replace_tokens

src/api_builder/build_csharp.cpp:41–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40template< typename T >
41void 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
63static bool has_option( json_value* options, const std::string& option ) {
64 if( !options )

Callers 2

write_functionsFunction · 0.85
buildCSharpFunction · 0.85

Calls 4

template_find_tokenFunction · 0.85
c_strMethod · 0.80
writeMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected