Changeset 17 for trunk/tmdmcreator/src


Ignore:
Timestamp:
02/21/13 17:14:39 (12 years ago)
Author:
lucsch
Message:

Preliminary code for processing user_content.txt

Location:
trunk/tmdmcreator/src
Files:
3 edited

Legend:

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

    r16 r17  
    1717#include "tmdmcreator.h" 
    1818#include "tmdmcopier.h" 
     19#include "tmdmprocessor.h" 
    1920 
    2021TmDmCreator::TmDmCreator() { 
     
    9293bool TmDmCreator::ProcessFiles(wxArrayString & errorsmsg) { 
    9394    errorsmsg.Clear(); 
    94     // Copy structure to out 
     95    // Copy structure 
    9596    TmDmCopier myCopier(m_FileNameOutSQL); 
    9697    if (myCopier.CopyFrom(m_FileNameBaseSQL) == false) { 
     
    104105    } 
    105106     
    106      
    107      
     107    // Process layers 
     108    TmDmProcessorSimple myLayerProc(m_FileNameUserContent, m_FileNameOutSQL); 
     109    int myThematicLayersStart = myLayerProc.FindBlock(_T("thematic_layers")); 
     110    if (myThematicLayersStart == wxNOT_FOUND) { 
     111        errorsmsg.Add(wxString::Format(_("'thematic_layers' field not found in %s"), m_FileNameUserContent.GetFullPath())); 
     112        return false; 
     113    } 
     114    if (myLayerProc.ProcessBlock(myThematicLayersStart)==false) { 
     115        errorsmsg.Add(wxString::Format(_("Processing 'thematic_layers' failed in %s"), m_FileNameUserContent.GetFullPath())); 
     116        return false; 
     117    } 
    108118    return true; 
    109119} 
  • trunk/tmdmcreator/src/tmdmprocessor.cpp

    r16 r17  
    1818#include "tmdmcopier.h" 
    1919 
    20 TmDmProcessor::TmDmProcessor() { 
     20TmDmProcessor::TmDmProcessor(const wxFileName & src, const wxFileName & dest) { 
     21    m_FileSrc = src; 
     22    m_FileDst = dest; 
    2123} 
    2224 
     
    2931 
    3032int TmDmProcessor::FindBlock(const wxString & blockname) { 
     33    wxFileInputStream input(m_FileSrc.GetFullPath()); 
     34    wxTextInputStream text(input); 
     35    long myLineIndex = 0; 
     36    while(input.IsOk() && !input.Eof() ){ 
     37        wxString myLine = text.ReadLine(); 
     38        if (myLine.StartsWith(blockname)==true){ 
     39            return myLineIndex; 
     40        } 
     41        myLineIndex++; 
     42    } 
    3143    return wxNOT_FOUND; 
    3244} 
     
    3951 
    4052 
    41 TmDmProcessorSimple::TmDmProcessorSimple() { 
     53TmDmProcessorSimple::TmDmProcessorSimple(const wxFileName & src, const wxFileName & dest) : TmDmProcessor(src,dest) { 
    4254} 
    4355 
     
    4961 
    5062 
    51 bool TmDmProcessorSimple::ProcessBlock(int blockstart, TmDmCopier * copier) { 
     63bool TmDmProcessorSimple::ProcessBlock(int blockstart) { 
     64    wxString mySQLCols = wxEmptyString; 
     65    wxString mySQLTxt = wxEmptyString; 
     66     
     67    wxFileInputStream input(m_FileSrc.GetFullPath()); 
     68    wxTextInputStream text(input); 
     69    long myLineIndex = 0; 
     70    while(input.IsOk() && !input.Eof() ){ 
     71        if (myLineIndex <= blockstart) { 
     72            myLineIndex++; 
     73            continue; 
     74        } 
     75         
     76        wxString myRow = text.ReadLine(); 
     77         
     78        // HERE !!!  
     79         
     80         
     81         
     82        myLineIndex++; 
     83    } 
     84    return wxNOT_FOUND; 
     85 
     86     
     87     
     88     
    5289    return false; 
    5390} 
     
    6198 
    6299 
    63 TmDmProcessorAttributs::TmDmProcessorAttributs() { 
     100TmDmProcessorAttributs::TmDmProcessorAttributs(const wxFileName & src, const wxFileName & dest) : TmDmProcessor(src,dest) { 
    64101} 
    65102 
     
    67104} 
    68105 
    69 bool TmDmProcessorAttributs::ProcessBlock(int blockstart, TmDmCopier * copier) { 
     106bool TmDmProcessorAttributs::ProcessBlock(int blockstart) { 
    70107    return false; 
    71108} 
  • trunk/tmdmcreator/src/tmdmprocessor.h

    r16 r17  
    1717#define _TMDMPROCESSOR_H_ 
    1818 
    19 // For compilers that support precompilation, includes "wx/wx.h". 
    2019#include "wx/wxprec.h" 
    21  
    22 // Include wxWidgets' headers 
    2320#ifndef WX_PRECOMP 
    2421#include <wx/wx.h> 
    2522#endif 
     23#include <wx/filename.h> 
     24#include <wx/wfstream.h> 
     25#include <wx/txtstrm.h> 
     26 
    2627 
    2728class TmDmCopier; 
    2829class TmDmProcessor { 
    2930protected: 
    30     TmDmCopier * m_Copier; 
     31    wxFileName m_FileSrc; 
     32    wxFileName m_FileDst; 
    3133     
    3234public: 
    33     TmDmProcessor(); 
     35    TmDmProcessor(const wxFileName & src, const wxFileName & dest); 
    3436    virtual ~TmDmProcessor(); 
    3537     
    3638    int FindBlock(const wxString & blockname); 
    37     virtual bool ProcessBlock(int blockstart, TmDmCopier * copier) = 0; 
     39    virtual bool ProcessBlock(int blockstart) = 0; 
    3840}; 
    3941 
     
    4648class TmDmProcessorSimple : public TmDmProcessor { 
    4749public: 
    48     TmDmProcessorSimple(); 
     50    TmDmProcessorSimple(const wxFileName & src, const wxFileName & dest); 
    4951    virtual ~TmDmProcessorSimple(); 
    5052     
    51     virtual bool ProcessBlock(int blockstart, TmDmCopier * copier); 
     53    virtual bool ProcessBlock(int blockstart); 
    5254}; 
    5355 
     
    6062class TmDmProcessorAttributs : public TmDmProcessor { 
    6163public: 
    62     TmDmProcessorAttributs(); 
     64    TmDmProcessorAttributs(const wxFileName & src, const wxFileName & dest); 
    6365    virtual ~TmDmProcessorAttributs(); 
    6466     
    65     virtual bool ProcessBlock(int blockstart, TmDmCopier * copier); 
     67    virtual bool ProcessBlock(int blockstart); 
    6668}; 
    6769#endif 
Note: See TracChangeset for help on using the changeset viewer.