A C++ DAL / ORM code generation framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.9 KiB

  1. /*
  2. WORM - a DAL/ORM code generation framework
  3. Copyright (C) 2011 Erik Winn <sidewalksoftware@gmail.com>
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef WORMCLASSGENERATOR_H
  16. #define WORMCLASSGENERATOR_H
  17. #include <string>
  18. #include <vector>
  19. #include "wsqldatabase.h"
  20. #include "wormcodetemplate.h"
  21. namespace WSql {
  22. class WormClassGenerator
  23. {
  24. public:
  25. WormClassGenerator(WSqlDatabase& db);
  26. void run();
  27. bool init();
  28. void addTable(const std::string tablename){_tablesToGenerate.push_back(tablename);}
  29. void setTemplateDirectory(const std::string dir);
  30. void setOutputDirectory(const std::string dir);
  31. private:
  32. bool writeFile(const std::string content, const std::string filename);
  33. std::string createOutFileName(const WormCodeTemplate::Type type, const WSqlTable& table);
  34. std::string expand( const std::string &filename, const WSql::WSqlTable &table, WSql::WormCodeTemplate::Type template_type );
  35. WSqlDatabase& _db;
  36. std::string _templateDirectory;
  37. std::string _outputDirectory;
  38. std::vector<std::string> _tablesToGenerate;
  39. std::vector<WormCodeTemplate> _templates;
  40. bool usesBaseClass;
  41. };
  42. } //namespace WSql
  43. #endif // WORMCLASSGENERATOR_H