Changeset 322 in dev for trunk/abdev/BasicCompiler_Common/src/Source.cpp
- Timestamp:
- Sep 24, 2007, 2:58:10 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/src/Source.cpp
r305 r322 422 422 int i,i2; 423 423 424 bool isMustChange = false; 425 for( i=0; ; i++ ){ 426 if( buffer[i] == '\0' ){ 427 break; 428 } 429 if( buffer[i]=='\n' ) 430 { 431 if( i>0 ) 432 { 433 if( buffer[i-1] == '\r' ) 434 { 435 isMustChange = true; 436 } 437 } 438 } 439 } 440 441 if( !isMustChange ) 442 { 443 // 改行コードの変換は必要ない 444 return; 445 } 446 424 447 #ifdef _DEBUG 425 448 //改行コードの整合性チェック … … 806 829 } 807 830 831 void BasicSource::Initialize( const std::string &source ) 832 { 833 Clear(); 834 Add( source ); 835 836 // 改行コードをCRLFからLFに変換 837 ChangeReturnLineChar(); 838 839 // コメントを削除 840 RemoveComments(); 841 842 //最終行には文字を含ませないようにする 843 if( lstrlen(buffer)>0 && buffer[lstrlen(buffer)-1] != '\n' ) 844 { 845 Realloc( length + 1 ); 846 lstrcat( buffer, "\n" ); 847 } 848 849 // アンダーバーによる改行を正規表現に戻す 850 RemoveReturnLineUnderbar(); 851 } 852 808 853 void BasicSource::SetBuffer( const char *buffer ){ 809 854 this->buffer = (char *)calloc( lstrlen(buffer) + 1, 1 ); … … 987 1032 return 1; 988 1033 } 1034 1035 1036 SourceTemplate::SourceTemplate( const std::string &filePath ) 1037 { 1038 Jenga::Common::File file = Jenga::Common::File( GetApplicationBaseFullPath( filePath ) ); 1039 source = file.Read(); 1040 } 1041 std::string SourceTemplate::GetResult( const std::map<std::string,std::string> &values ) 1042 { 1043 std::string result = source; 1044 1045 std::map<std::string,std::string>::const_iterator it = values.begin(); 1046 while( it != values.end() ) 1047 { 1048 while( true ) 1049 { 1050 std::string::size_type index = result.find( "#" + it->first + "#" ); 1051 if( index == std::string::npos ) 1052 { 1053 break; 1054 } 1055 1056 result = result.substr( 0, index ) + it->second + result.substr( index + it->first.length() + 2 ); 1057 } 1058 it++; 1059 } 1060 1061 return result; 1062 }
Note:
See TracChangeset
for help on using the changeset viewer.