Changeset 18 for trunk/tmdmcreator/src
- Timestamp:
- 02/22/13 13:30:00 (12 years ago)
- Location:
- trunk/tmdmcreator/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tmdmcreator/src/main.cpp
r16 r18 83 83 bool bVerbose = parser.Found("verbose"); 84 84 bool bToolMap = parser.Found("toolmap"); 85 if (parser.Found("overwrite") ) {85 if (parser.Found("overwrite") && wxFileExists(parser.GetParam(3))) { 86 86 wxRemoveFile(parser.GetParam(3)); 87 87 } -
trunk/tmdmcreator/src/tmdmcopier.cpp
r16 r18 26 26 27 27 TmDmCopier::~TmDmCopier() { 28 m_File->Flush(); 28 29 wxDELETE(m_File); 29 30 } … … 49 50 50 51 bool TmDmCopier::CopyFrom(const wxString & text) { 52 m_File->SeekEnd(); 51 53 if (m_File->Write(text) == false) { 52 54 m_Errors.Add(wxString::Format(_("Writing to: %s failed!"), m_File->GetName())); -
trunk/tmdmcreator/src/tmdmcreator.cpp
r17 r18 94 94 errorsmsg.Clear(); 95 95 // Copy structure 96 TmDmCopier myCopier(m_FileNameOutSQL); 97 if (myCopier.CopyFrom(m_FileNameBaseSQL) == false) { 98 errorsmsg.Add(wxString::Format(_("Copying: %s failed!"), m_FileNameBaseSQL.GetFullPath())); 99 return false; 96 { // needed to destroy the copier before processing layers 97 TmDmCopier myCopier(m_FileNameOutSQL); 98 if (myCopier.CopyFrom(m_FileNameBaseSQL) == false) { 99 errorsmsg.Add(wxString::Format(_("Copying: %s failed!"), m_FileNameBaseSQL.GetFullPath())); 100 return false; 101 } 102 103 if (myCopier.CopyFrom(m_FileNameUserSQL) == false) { 104 errorsmsg.Add(wxString::Format(_("Copying: %s failed!"), m_FileNameUserSQL.GetFullPath())); 105 return false; 106 } 100 107 } 101 102 if (myCopier.CopyFrom(m_FileNameUserSQL) == false) { 103 errorsmsg.Add(wxString::Format(_("Copying: %s failed!"), m_FileNameUserSQL.GetFullPath())); 104 return false; 105 } 106 108 107 109 // Process layers 108 110 TmDmProcessorSimple myLayerProc(m_FileNameUserContent, m_FileNameOutSQL); … … 112 114 return false; 113 115 } 114 if (myLayerProc.ProcessBlock(myThematicLayersStart )==false) {116 if (myLayerProc.ProcessBlock(myThematicLayersStart, _T("thematic_layers"))==false) { 115 117 errorsmsg.Add(wxString::Format(_("Processing 'thematic_layers' failed in %s"), m_FileNameUserContent.GetFullPath())); 116 118 return false; -
trunk/tmdmcreator/src/tmdmprocessor.cpp
r17 r18 61 61 62 62 63 bool TmDmProcessorSimple::ProcessBlock(int blockstart ) {64 wx String mySQLCols = wxEmptyString;65 wxString mySQLTxt = wxEmptyString;63 bool TmDmProcessorSimple::ProcessBlock(int blockstart, const wxString & tablename) { 64 wxArrayString mySQLCols; 65 TmDmCopier myCopier(m_FileDst); 66 66 67 67 wxFileInputStream input(m_FileSrc.GetFullPath()); … … 69 69 long myLineIndex = 0; 70 70 while(input.IsOk() && !input.Eof() ){ 71 wxString myRow = text.ReadLine(); 71 72 if (myLineIndex <= blockstart) { 72 73 myLineIndex++; … … 74 75 } 75 76 76 wxString myRow = text.ReadLine(); 77 if (myLineIndex == blockstart+1) { 78 mySQLCols = wxStringTokenize(myRow, _T("\t"), wxTOKEN_RET_EMPTY); 79 myLineIndex++; 80 continue; 81 } 77 82 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 } 79 95 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); 82 109 myLineIndex++; 83 110 } 84 return wxNOT_FOUND;85 86 87 88 89 111 return false; 90 112 } … … 104 126 } 105 127 106 bool TmDmProcessorAttributs::ProcessBlock(int blockstart ) {128 bool TmDmProcessorAttributs::ProcessBlock(int blockstart, const wxString & tablename) { 107 129 return false; 108 130 } -
trunk/tmdmcreator/src/tmdmprocessor.h
r17 r18 24 24 #include <wx/wfstream.h> 25 25 #include <wx/txtstrm.h> 26 #include <wx/tokenzr.h> 26 27 27 28 … … 37 38 38 39 int FindBlock(const wxString & blockname); 39 virtual bool ProcessBlock(int blockstart ) = 0;40 virtual bool ProcessBlock(int blockstart, const wxString & tablename) = 0; 40 41 }; 41 42 … … 51 52 virtual ~TmDmProcessorSimple(); 52 53 53 virtual bool ProcessBlock(int blockstart );54 virtual bool ProcessBlock(int blockstart, const wxString & tablename); 54 55 }; 55 56 … … 65 66 virtual ~TmDmProcessorAttributs(); 66 67 67 virtual bool ProcessBlock(int blockstart );68 virtual bool ProcessBlock(int blockstart, const wxString & tablename); 68 69 }; 69 70 #endif
Note: See TracChangeset
for help on using the changeset viewer.