Ignore:
Timestamp:
02/21/13 16:20:42 (11 years ago)
Author:
lucsch
Message:

Copying Base and User SQL files into output file is now working

File:
1 edited

Legend:

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

    r6 r16  
    2727#include <wx/dir.h> 
    2828#include <wx/filename.h> 
     29#include "tmdmcreator.h" 
    2930 
    3031 
     
    3435        wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, 
    3536    { wxCMD_LINE_SWITCH, "v", "verbose", "Be more verbose" }, 
    36     { wxCMD_LINE_PARAM, NULL, NULL, "[structure sql file]"}, 
    37     { wxCMD_LINE_PARAM, NULL, NULL, "[content txt file]"}, 
    38     { wxCMD_LINE_PARAM, NULL, NULL, "[result sql file]"}, 
     37    { wxCMD_LINE_SWITCH, "t", "toolmap", "toolmap output" }, 
     38    { wxCMD_LINE_SWITCH, "o", "overwrite", "overwrite output" },     
     39    { wxCMD_LINE_PARAM, NULL, NULL, "[base structure sql file]"}, 
     40    { wxCMD_LINE_PARAM, NULL, NULL, "[user structure sql file]"}, 
     41    { wxCMD_LINE_PARAM, NULL, NULL, "[user content txt file]"}, 
     42    { wxCMD_LINE_PARAM, NULL, NULL, "[result file]"}, 
    3943    { wxCMD_LINE_NONE } 
    4044}; 
     
    4246 
    4347 
    44 void PrintArray(const wxArrayString & array, const wxString & msg){ 
    45     wxPrintf(msg + _T("\n")); 
     48void PrintArray(const wxArrayString & array, const wxString & msg = wxEmptyString){ 
     49    if (msg != wxEmptyString) { 
     50        wxPrintf(msg + _T("\n")); 
     51    } 
    4652    for (unsigned int i = 0; i< array.GetCount(); i++) { 
    4753        wxPrintf(array[i] + _T("\n")); 
     
    7480    // cmd line is correct !! 
    7581    wxPrintf(myLogoTxt); 
     82     
     83    bool bVerbose = parser.Found("verbose"); 
     84    bool bToolMap = parser.Found("toolmap"); 
     85    if (parser.Found("overwrite")) { 
     86        wxRemoveFile(parser.GetParam(3)); 
     87    } 
     88     
     89    if (bToolMap == true) { 
     90        wxPrintf(_("Exporting to ToolMap project not supported for now!\n")); 
     91        return 0; 
     92    } 
     93     
     94    wxASSERT(parser.GetParamCount() == 4); 
     95    TmDmCreator myCreator; 
     96    myCreator.SetBaseSQL(wxFileName(parser.GetParam(0))); 
     97    myCreator.SetUserSQL(wxFileName(parser.GetParam(1))); 
     98    myCreator.SetUserContent(wxFileName(parser.GetParam(2))); 
     99    myCreator.SetOutSQL(wxFileName(parser.GetParam(3))); 
     100     
     101    wxArrayString myErrors; 
     102    if (myCreator.CheckFiles(myErrors) == false) { 
     103        if (bVerbose == true) { 
     104            PrintArray(myErrors); 
     105        } 
     106        wxPrintf(_("Error while checking files, aborting!\n")); 
     107        return 0; 
     108    } 
     109     
     110    if (myCreator.ProcessFiles(myErrors) == false) { 
     111        if (bVerbose == true) { 
     112            PrintArray(myErrors); 
     113        } 
     114        wxPrintf(_("Error processing files, aborting\n")); 
     115        return 0; 
     116    } 
     117     
     118    wxPrintf(_("Processing succeed!\n")); 
    76119    return 0; 
    77120} 
Note: See TracChangeset for help on using the changeset viewer.