scaffold  1.0.0
Generates files and directories based on templates and user input
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
scaffold.h
Go to the documentation of this file.
1 /* ========================================================================= */
2 /* ------------------------------------------------------------------------- *//*
12 
13 
14  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15  Please read COPYING and README files in root folder
16  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 */
18 /* ------------------------------------------------------------------------- */
19 /* ========================================================================= */
20 #ifndef __SCAFFOLD_INC__
21 #define __SCAFFOLD_INC__
22 //
23 //
24 //
25 //
26 /* INCLUDES ------------------------------------------------------------ */
27 
28 #include <libbbb/rexscript.h>
29 #include <libbbb/memtrack.h>
30 #include <libbbb/varmap.h>
31 #include <libbbb/list2d.h>
32 #include <libbbb/exit-codes.h>
33 
36 #include <scaffold/scaffold_config.h>
37 #include <scaffold/scaffold_version.h>
38 #include <scaffold/scafrex.h>
39 #include <scaffold/diff_match_patch.h>
40 
41 #include <QDebug>
42 #include <QString>
43 #include <QStringList>
44 #include <QList>
45 #include <QVector>
46 #include <QRegExp>
47 
48 /* INCLUDES ============================================================ */
49 //
50 //
51 //
52 //
53 /* DEFINITIONS --------------------------------------------------------- */
54 
55 class QCoreApplication;
56 
57 namespace scaffold {
58 class Project;
59 
60 /* DEFINITIONS ========================================================= */
61 //
62 //
63 //
64 //
65 /* CLASS --------------------------------------------------------------- */
66 
70 class Scaffold : public MemTrack {
71  BBM_TRACK( Scaffold );
72 
73  //
74  //
75  //
76  //
77  /* DEFINITIONS ----------------------------------------------------- */
78 
79 public:
80 
82 
86  enum LogTypes {
87  LOG_PROJECTS = 0x0000100,
88  LOG_GENERATORS = 0x0000200,
89  LOG_GENFILES = 0x0000400,
93  bbb::RexScript::LOG_ALL |
95  0
96  };
97 
98 
99  /* DEFINITIONS ===================================================== */
100  //
101  //
102  //
103  //
104  /* DATA ------------------------------------------------------------ */
105 
106 private:
107 
109  Scafrex srex_;
110 
112  List2Dh projects_;
113 
115  Project * project_crt_;
116 
118  diff_match_patch dmp_;
119 
121  static Scaffold * uniq_;
122 
123 
124  /* DATA ============================================================ */
125  //
126  //
127  //
128  //
129  /* FUNCTIONS ------------------------------------------------------- */
130 
131 private:
132 
133 
135  Scaffold (
136  const QStringList & init_files,
137  const bbb::VarMap & var_map
138  );
139 
141  virtual ~Scaffold ( void );
142 
143 
144 public:
145 
147  static Scaffold * unique ( void )
148  { return uniq_; }
149 
150 
152  static bool init (
153  const QStringList & init_files,
154  const bbb::VarMap & var_map
155  );
156 
158  static ExitCode perform ( QCoreApplication & app );
159 
161  static void end ( void );
162 
164  static Scafrex * scafrex ( void )
165  { return &uniq_->srex_; }
166 
168 
174  bool initDMP ( void );
175 
177  static bool blendTwoFiles (
178  const QString & s_path_1,
179  const QString & s_path_2
180  );
181 
183  static bool readTextFile (
184  const QString & s_path,
185  QString & s_out
186  );
187 
189  static bool writeTextFile (
190  const QString & s_path,
191  const QString & s_out
192  );
193 
194 
195  /* -------------------------------------------------------------------- */
199 
200 
202  static int findProjectId ( const QString & s_name );
203 
205  static int findProjectId ( const Project * trg );
206 
208  static Project * findProject ( const QString & s_name );
209 
211  static Project * getProject ( const QString & s_name );
212 
214  static Project * currentProject ( void )
215  { return uniq_->project_crt_; }
216 
218  static Project * getValidProject ( void );
219 
221  static Project * getValidProject ( const QString & s_name );
222 
224  static Project * startProject (
225  const QString & s_name
226  );
227 
229  QString defaultProjectPath ( void );
230 
232  /* ==================================================================== */
233 
234 
235  /* -------------------------------------------------------------------- */
239 
240 
242  static Generator * getValidGenerator ( void );
243 
245  static Generator * getValidGenerator ( const QString & s_name );
246 
248  /* ==================================================================== */
249 
250 
251  /* -------------------------------------------------------------------- */
255 
256 
258  static inline void fileError ( const QString & s ) {
259  uniq_->srex_.fileError( s );
260  }
261 
263  static inline void error ( const QString & s ) {
264  uniq_->srex_.error( s );
265  }
266 
268  static inline void info ( const QString & s ) {
269  uniq_->srex_.info( s );
270  }
271 
273  static inline void log ( int ty, const QString & s ) {
274  uniq_->srex_.log( ty, s );
275  }
276 
278  /* ==================================================================== */
279 
280 
281  /* FUNCTIONS ======================================================= */
282  //
283  //
284  //
285  //
286 
287 }; /* class SCAFFOLD */
288 
289 /* CLASS =============================================================== */
290 //
291 //
292 //
293 //
294 
295 } // namespace scaffold
296 
297 #endif // __SCAFFOLD_INC__
298 /* ------------------------------------------------------------------------- */
299 /* ========================================================================= */