Ignore:
Timestamp:
02/22/13 13:30:00 (11 years ago)
Author:
lucsch
Message:
  • Preliminary code for processing user_content.txt. Processing thematic_layers is now working
  • Corrected base_structure and user_structure.sql
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tmdmcreator/src/tmdmprocessor.cpp

    r17 r18  
    6161 
    6262 
    63 bool TmDmProcessorSimple::ProcessBlock(int blockstart) { 
    64     wxString mySQLCols = wxEmptyString; 
    65     wxString mySQLTxt = wxEmptyString; 
     63bool TmDmProcessorSimple::ProcessBlock(int blockstart, const wxString & tablename) { 
     64    wxArrayString mySQLCols; 
     65    TmDmCopier myCopier(m_FileDst); 
    6666     
    6767    wxFileInputStream input(m_FileSrc.GetFullPath()); 
     
    6969    long myLineIndex = 0; 
    7070    while(input.IsOk() && !input.Eof() ){ 
     71        wxString myRow = text.ReadLine(); 
    7172        if (myLineIndex <= blockstart) { 
    7273            myLineIndex++; 
     
    7475        } 
    7576         
    76         wxString myRow = text.ReadLine(); 
     77        if (myLineIndex == blockstart+1) { 
     78            mySQLCols = wxStringTokenize(myRow, _T("\t"), wxTOKEN_RET_EMPTY); 
     79            myLineIndex++; 
     80            continue; 
     81        } 
    7782         
    78         // HERE !!!  
     83        wxArrayString myValues = wxStringTokenize(myRow, _T("\t"), wxTOKEN_RET_EMPTY_ALL); 
     84        bool bEmpty = true; 
     85        for (unsigned int i = 0; i< myValues.GetCount(); i++) { 
     86            if (myValues[i] != wxEmptyString) { 
     87                bEmpty = false; 
     88                break; 
     89            } 
     90        } 
     91        if (bEmpty == true) { 
     92            // ok empty line found 
     93            return true; 
     94        } 
    7995         
    80          
    81          
     96        // write insert sentence 
     97        wxString myInsert = wxString::Format(_T("INSERT INTO `%s` ("), tablename); 
     98        for (unsigned int i = 0; i< mySQLCols.GetCount(); i++) { 
     99            myInsert.Append(wxString::Format(_T("%s,"), mySQLCols.Item(i))); 
     100        } 
     101        myInsert.RemoveLast(); 
     102        myInsert.Append(_T(") VALUES (")); 
     103        for (unsigned int i = 0; i< mySQLCols.GetCount(); i++) { 
     104            myInsert.Append(wxString::Format(_T("\"%s\","), myValues.Item(i))); 
     105        } 
     106        myInsert.RemoveLast(); 
     107        myInsert.Append(_T(");\n")); 
     108        myCopier.CopyFrom(myInsert); 
    82109        myLineIndex++; 
    83110    } 
    84     return wxNOT_FOUND; 
    85  
    86      
    87      
    88      
    89111    return false; 
    90112} 
     
    104126} 
    105127 
    106 bool TmDmProcessorAttributs::ProcessBlock(int blockstart) { 
     128bool TmDmProcessorAttributs::ProcessBlock(int blockstart, const wxString & tablename) { 
    107129    return false; 
    108130} 
Note: See TracChangeset for help on using the changeset viewer.