WORM 0.2
A C++ DAL/ORM code generation framework

src/orm/wormclassgenerator.h

Go to the documentation of this file.
00001 /*
00002     WORM - a DAL/ORM code generation framework
00003     Copyright (C) 2011  Erik Winn <sidewalksoftware@gmail.com>
00004 
00005     This program is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 
00020 #ifndef WORMCLASSGENERATOR_H
00021 #define WORMCLASSGENERATOR_H
00022 
00023 #include <string>
00024 #include <vector>
00025 #include "wsqldatabase.h"
00026 #include "wormcodetemplate.h"
00027 
00028 namespace WSql {
00029 
00030 class WormClassGenerator
00031 {
00032 
00033     public:
00034         
00035         WormClassGenerator(WSqlDatabase& db);
00036         void run();
00037         bool init();
00038         
00039         void addTable(const std::string tablename){_tablesToGenerate.push_back(tablename);}
00040         void setTemplateDirectory(const std::string dir);
00041         void setOutputDirectory(const std::string dir);
00042     private:
00043     
00044         bool writeFile(const std::string content, const std::string filename);
00045         std::string createOutFileName(const WormCodeTemplate::Type type, const WSqlTable& table);    
00046         std::string expand( const std::string& filename, const WSqlTable& table );
00047         
00048         WSqlDatabase& _db;
00049         std::string _templateDirectory;
00050         std::string _outputDirectory;
00051         std::vector<std::string> _tablesToGenerate;
00052         std::vector<WormCodeTemplate> _templates;
00053 };
00054 
00055 } //namespace WSql
00056 
00057 #endif // WORMCLASSGENERATOR_H
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Defines