Ignore:
Timestamp:
May 2, 2008, 2:56:06 PM (16 years ago)
Author:
dai_9181
Message:

SourceTemplateクラスをLexicalAnalyzerクラスのインナークラスにした

Location:
trunk/ab5.0/abdev/BasicCompiler_Common
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h

    r525 r531  
    66class LexicalAnalyzer
    77{
     8    class SourceTemplate
     9    {
     10        std::string source;
     11    public:
     12        SourceTemplate( const std::string &filePath );
     13        ~SourceTemplate()
     14        {
     15        }
     16
     17        std::string GetResult( const std::map<std::string,std::string> &values );
     18    };
     19
    820public:
    921
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Source.h

    r523 r531  
    252252};
    253253typedef std::vector<BasicSource> BasicSources;
    254 
    255 class SourceTemplate
    256 {
    257     std::string source;
    258 public:
    259     SourceTemplate( const std::string &filePath );
    260     ~SourceTemplate()
    261     {
    262     }
    263 
    264     std::string GetResult( const std::map<std::string,std::string> &values );
    265 };
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer.cpp

    r511 r531  
    22
    33using namespace ActiveBasic::Compiler;
     4
     5LexicalAnalyzer::SourceTemplate::SourceTemplate( const std::string &filePath )
     6{
     7    Jenga::Common::File file = Jenga::Common::File( GetApplicationBaseFullPath( filePath ) );
     8    source = file.Read();
     9}
     10std::string LexicalAnalyzer::SourceTemplate::GetResult( const std::map<std::string,std::string> &values )
     11{
     12    std::string result = source;
     13
     14    std::map<std::string,std::string>::const_iterator it = values.begin();
     15    while( it != values.end() )
     16    {
     17        while( true )
     18        {
     19            std::string::size_type index = result.find( it->first );
     20            if( index == std::string::npos )
     21            {
     22                break;
     23            }
     24
     25            result = result.substr( 0, index ) + it->second + result.substr( index + it->first.length() );
     26        }
     27        it++;
     28    }
     29
     30    return result;
     31}
     32
    433
    534bool LexicalAnalyzer::CollectNamespaces( const char *source, NamespaceScopesCollection &namespaceScopesCollection )
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Source.cpp

    r523 r531  
    10231023    return 1;
    10241024}
    1025 
    1026 
    1027 SourceTemplate::SourceTemplate( const std::string &filePath )
    1028 {
    1029     Jenga::Common::File file = Jenga::Common::File( GetApplicationBaseFullPath( filePath ) );
    1030     source = file.Read();
    1031 }
    1032 std::string SourceTemplate::GetResult( const std::map<std::string,std::string> &values )
    1033 {
    1034     std::string result = source;
    1035 
    1036     std::map<std::string,std::string>::const_iterator it = values.begin();
    1037     while( it != values.end() )
    1038     {
    1039         while( true )
    1040         {
    1041             std::string::size_type index = result.find( it->first );
    1042             if( index == std::string::npos )
    1043             {
    1044                 break;
    1045             }
    1046 
    1047             result = result.substr( 0, index ) + it->second + result.substr( index + it->first.length() );
    1048         }
    1049         it++;
    1050     }
    1051 
    1052     return result;
    1053 }
Note: See TracChangeset for help on using the changeset viewer.