]> git.tdb.fi Git - libs/datafile.git/blob - tool/compiler.h
Cosmetic changes
[libs/datafile.git] / tool / compiler.h
1 #ifndef TOOL_COMPILER_H_
2 #define TOOL_COMPILER_H_
3
4 #include <msp/datafile/loader.h>
5 #include <msp/datafile/statement.h>
6 #include <msp/datafile/writer.h>
7 #include <msp/fs/path.h>
8
9 class Compiler: public Msp::DataFile::Loader
10 {
11         friend class File;
12         friend class ForEach;
13
14 private:
15         Msp::DataFile::Writer &writer;
16         bool reset_src;
17
18 public:
19         Compiler(Msp::DataFile::Writer &);
20 private:
21         void file(const std::string &);
22         void for_each(const std::vector<std::string> &);
23         void write(const Msp::DataFile::Statement &);
24
25         bool process_statement(const Msp::FS::Path &, Msp::DataFile::Statement &);
26         void process_file(const Msp::FS::Path &, const std::list<Msp::DataFile::Statement> &);
27         void process_file(const Msp::FS::Path &);
28 };
29
30
31 class File: public Msp::DataFile::Loader
32 {
33 private:
34         Compiler &compiler;
35         Msp::FS::Path filename;
36         std::list<Msp::DataFile::Statement> write_st;
37
38 public:
39         File(Compiler &, const Msp::FS::Path &);
40 private:
41         virtual void finish();
42
43         void write(const Msp::DataFile::Statement &);
44 };
45
46
47 class ForEach: public Msp::DataFile::Loader
48 {
49 private:
50         Compiler &compiler;
51         Msp::FS::Path base;
52         std::list<std::string> patterns;
53         std::list<std::string> excludes;
54         std::list<Msp::DataFile::Statement> write_st;
55
56 public:
57         ForEach(Compiler &, const Msp::FS::Path &, const std::list<std::string> &);
58 private:
59         virtual void finish();
60
61         void exclude(const std::string &);
62         void pattern(const std::string &);
63         void wrap();
64         void wrap_keyword(const std::string &);
65         void write(const Msp::DataFile::Statement &);
66 };
67
68 #endif