Last change
on this file was 829, checked in by イグトランス (egtra), 13 years ago |
svn:eol-styleとsvn:mime-type(文字コード指定含む)の設定
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/plain; charset=Shift_JIS
|
File size:
856 bytes
|
Line | |
---|
1 | #include "stdafx.h"
|
---|
2 |
|
---|
3 | using namespace Jenga::Common;
|
---|
4 |
|
---|
5 | void SourceTemplate::Values::Insert( const std::string &tagName, const std::string &value )
|
---|
6 | {
|
---|
7 | this->insert( Values::value_type(
|
---|
8 | tagName,
|
---|
9 | value
|
---|
10 | ) );
|
---|
11 | }
|
---|
12 |
|
---|
13 | SourceTemplate::SourceTemplate( const std::string &filePath )
|
---|
14 | {
|
---|
15 | Jenga::Common::File file = Jenga::Common::File( filePath );
|
---|
16 | source = file.Read();
|
---|
17 | }
|
---|
18 | std::string SourceTemplate::GetResult( const std::map<std::string,std::string> &values )
|
---|
19 | {
|
---|
20 | std::string result = source;
|
---|
21 |
|
---|
22 | std::map<std::string,std::string>::const_iterator it = values.begin();
|
---|
23 | while( it != values.end() )
|
---|
24 | {
|
---|
25 | while( true )
|
---|
26 | {
|
---|
27 | std::string::size_type index = result.find( it->first );
|
---|
28 | if( index == std::string::npos )
|
---|
29 | {
|
---|
30 | break;
|
---|
31 | }
|
---|
32 |
|
---|
33 | result = result.substr( 0, index ) + it->second + result.substr( index + it->first.length() );
|
---|
34 | }
|
---|
35 | it++;
|
---|
36 | }
|
---|
37 |
|
---|
38 | return result;
|
---|
39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.