summaryrefslogtreecommitdiffabout
path: root/include/sitecing/sitecing_enflesher.h
blob: 8bc43a06d1b902e6d64367d812d827face00c756 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef __SITECING_SITECING_ENFLESHER_H
#define __SITECING_SITECING_ENFLESHER_H

#include <fstream>
#include <string>
using namespace std;

/**
 * @file
 * @brief The preprocessed source builder.
 */

#ifndef sitecing_enflesher_flexlexer_once
#define sitecing_enflesher_flexlexer_once
#undef yyFlexLexer
#define yyFlexLexer sitecing_enflesherFlexLexer
#include <FlexLexer.h>
#undef yyFlexLexerOnce
#endif

class sitecing_parser;
/**
 * The enfleshing of the skeleton file according to the in-memory parsed
 * component source.
 */
class sitecing_enflesher : public sitecing_enflesherFlexLexer {
    public:
	/**
	 * It is time to anchor output with the #line directive.
	 */
	bool anchor_time;
	/**
	 * The file currently being written is supposed to have #line
	 * directives all around the place.
	 */
	bool anchoraged;
	/**
	 * The reference to the parser object containg the parsed source.
	 */
	sitecing_parser& parser;
	/**
	 * The output stream.
	 */
	ofstream outs;
	/**
	 * the outs stream destination file.
	 * @see outs
	 */
	string outs_filename;

	/**
	 * @param p The parser object containing preparsed data.
	 */
	sitecing_enflesher(sitecing_parser& p)
	    : parser(p), anchor_time(true) { }

	/**
	 * Do the job.
	 */
	void enflesh();

	virtual void LexerOutput(const char *buf,int size);
	virtual int yylex();

	/**
	 * Put a #line anchor into output.
	 */
	void anchor();

	/**
	 * Close previously opened output stream, rename to the 'correct'
	 * destination filename, if needed, and open new file.
	 * @see outs
	 * @see outs_filename
	 */
	void outs_open(const string& nfile);
};

#endif /* __SITECING_SITECING_ENFLESHER_H */