1 | // |
2 | // CodeWriter.h |
3 | // |
4 | // Copyright (c) 2008, Applied Informatics Software Engineering GmbH. |
5 | // and Contributors. |
6 | // |
7 | // SPDX-License-Identifier: BSL-1.0 |
8 | // |
9 | |
10 | |
11 | #ifndef CodeWriter_INCLUDED |
12 | #define CodeWriter_INCLUDED |
13 | |
14 | |
15 | #include "Poco/Poco.h" |
16 | #include <ostream> |
17 | |
18 | |
19 | class Page; |
20 | |
21 | |
22 | class CodeWriter |
23 | /// This class implements the code generator for |
24 | /// generating C++ header and implementation files |
25 | /// from C++ Server Pages. |
26 | { |
27 | public: |
28 | (const Page& page, const std::string& clazz); |
29 | /// Creates the CodeWriter, using the given Page. |
30 | |
31 | virtual ~CodeWriter(); |
32 | /// Destroys the PageReader. |
33 | |
34 | virtual void (std::ostream& ostr, const std::string& ); |
35 | /// Writes the header file contents to the given stream. |
36 | |
37 | virtual void writeImpl(std::ostream& ostr, const std::string& ); |
38 | /// Writes the implementation file contents to the given stream. |
39 | |
40 | const Page& page() const; |
41 | /// Returns a const reference to the Page. |
42 | |
43 | const std::string& clazz() const; |
44 | /// Returns the name of the handler class. |
45 | |
46 | protected: |
47 | virtual void (std::ostream& ostr); |
48 | virtual void writeHandlerClass(std::ostream& ostr); |
49 | virtual void writeHandlerMembers(std::ostream& ostr); |
50 | virtual void writeFactoryClass(std::ostream& ostr); |
51 | virtual void writeImplIncludes(std::ostream& ostr); |
52 | virtual void writeConstructor(std::ostream& ostr); |
53 | virtual void writeHandler(std::ostream& ostr); |
54 | virtual void writeFactory(std::ostream& ostr); |
55 | virtual void writeSession(std::ostream& ostr); |
56 | virtual void writeForm(std::ostream& ostr); |
57 | virtual void writeResponse(std::ostream& ostr); |
58 | virtual void writeContent(std::ostream& ostr); |
59 | virtual void writeManifest(std::ostream& ostr); |
60 | |
61 | void beginGuard(std::ostream& ostr, const std::string& ); |
62 | void endGuard(std::ostream& ostr, const std::string& ); |
63 | void beginNamespace(std::ostream& ostr); |
64 | void endNamespace(std::ostream& ostr); |
65 | void handlerClass(std::ostream& ostr, const std::string& base, const std::string& ctorArg); |
66 | void factoryClass(std::ostream& ostr, const std::string& base); |
67 | void factoryImpl(std::ostream& ostr, const std::string& arg); |
68 | std::string cleanupHandler(std::string handler); |
69 | |
70 | private: |
71 | CodeWriter(); |
72 | CodeWriter(const CodeWriter&); |
73 | CodeWriter& operator = (const CodeWriter&); |
74 | |
75 | const Page& _page; |
76 | std::string _class; |
77 | }; |
78 | |
79 | |
80 | // |
81 | // inlines |
82 | // |
83 | inline const Page& CodeWriter::page() const |
84 | { |
85 | return _page; |
86 | } |
87 | |
88 | |
89 | inline const std::string& CodeWriter::clazz() const |
90 | { |
91 | return _class; |
92 | } |
93 | |
94 | |
95 | #endif // CodeWriter_INCLUDED |
96 | |