Skip to content

Commit 3edd579

Browse files
committed
PageCompiler refactoring
1 parent e045036 commit 3edd579

14 files changed

Lines changed: 1310 additions & 634 deletions

‎PageCompiler/Makefile‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#
22
# Makefile
33
#
4-
# $Id: //poco/Main/PageCompiler/Makefile#1 $
4+
# $Id: //poco/Main/PageCompiler/Makefile#3 $
55
#
66
# Makefile for Poco C++ Server Page Compiler
77
#
88

99
include $(POCO_BASE)/build/rules/global
1010

11-
objects = Page PageCompiler
11+
objects = Page PageReader \
12+
CodeWriter ApacheCodeWriter OSPCodeWriter \
13+
PageCompiler
1214

1315
target = cpspc
1416
target_version = 1

‎PageCompiler/PageCompiler_vs71.vcproj‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,19 +260,43 @@
260260
<Filter
261261
Name="Source Files"
262262
Filter="">
263+
<File
264+
RelativePath=".\src\ApacheCodeWriter.cpp">
265+
</File>
266+
<File
267+
RelativePath=".\src\CodeWriter.cpp">
268+
</File>
269+
<File
270+
RelativePath=".\src\OSPCodeWriter.cpp">
271+
</File>
263272
<File
264273
RelativePath=".\src\Page.cpp">
265274
</File>
266275
<File
267276
RelativePath=".\src\PageCompiler.cpp">
268277
</File>
278+
<File
279+
RelativePath=".\src\PageReader.cpp">
280+
</File>
269281
</Filter>
270282
<Filter
271283
Name="Header Files"
272284
Filter="">
285+
<File
286+
RelativePath=".\src\ApacheCodeWriter.h">
287+
</File>
288+
<File
289+
RelativePath=".\src\CodeWriter.h">
290+
</File>
291+
<File
292+
RelativePath=".\src\OSPCodeWriter.h">
293+
</File>
273294
<File
274295
RelativePath=".\src\Page.h">
275296
</File>
297+
<File
298+
RelativePath=".\src\PageReader.h">
299+
</File>
276300
</Filter>
277301
</Files>
278302
<Globals>

‎PageCompiler/PageCompiler_vs80.vcproj‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,18 @@
206206
<Filter
207207
Name="Source Files"
208208
>
209+
<File
210+
RelativePath=".\src\ApacheCodeWriter.cpp"
211+
>
212+
</File>
213+
<File
214+
RelativePath=".\src\CodeWriter.cpp"
215+
>
216+
</File>
217+
<File
218+
RelativePath=".\src\OSPCodeWriter.cpp"
219+
>
220+
</File>
209221
<File
210222
RelativePath=".\src\Page.cpp"
211223
>
@@ -214,14 +226,34 @@
214226
RelativePath=".\src\PageCompiler.cpp"
215227
>
216228
</File>
229+
<File
230+
RelativePath=".\src\PageReader.cpp"
231+
>
232+
</File>
217233
</Filter>
218234
<Filter
219235
Name="Header Files"
220236
>
237+
<File
238+
RelativePath=".\src\ApacheCodeWriter.h"
239+
>
240+
</File>
241+
<File
242+
RelativePath=".\src\CodeWriter.h"
243+
>
244+
</File>
245+
<File
246+
RelativePath=".\src\OSPCodeWriter.h"
247+
>
248+
</File>
221249
<File
222250
RelativePath=".\src\Page.h"
223251
>
224252
</File>
253+
<File
254+
RelativePath=".\src\PageReader.h"
255+
>
256+
</File>
225257
</Filter>
226258
</Files>
227259
<Globals>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//
2+
// ApacheCodeWriter.cpp
3+
//
4+
// $Id: //poco/Main/PageCompiler/src/ApacheCodeWriter.cpp#1 $
5+
//
6+
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
7+
// and Contributors.
8+
//
9+
// Permission is hereby granted, free of charge, to any person or organization
10+
// obtaining a copy of the software and accompanying documentation covered by
11+
// this license (the "Software") to use, reproduce, display, distribute,
12+
// execute, and transmit the Software, and to prepare derivative works of the
13+
// Software, and to permit third-parties to whom the Software is furnished to
14+
// do so, all subject to the following:
15+
//
16+
// The copyright notices in the Software and this entire statement, including
17+
// the above license grant, this restriction and the following disclaimer,
18+
// must be included in all copies of the Software, in whole or in part, and
19+
// all derivative works of the Software, unless such copies or derivative
20+
// works are solely in the form of machine-executable object code generated by
21+
// a source language processor.
22+
//
23+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25+
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
26+
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
27+
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
28+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29+
// DEALINGS IN THE SOFTWARE.
30+
//
31+
32+
33+
#include "ApacheCodeWriter.h"
34+
#include "Page.h"
35+
36+
37+
ApacheCodeWriter::ApacheCodeWriter(const Page& page, const std::string& clazz):
38+
CodeWriter(page, clazz)
39+
{
40+
}
41+
42+
43+
ApacheCodeWriter::~ApacheCodeWriter()
44+
{
45+
}
46+
47+
48+
void ApacheCodeWriter::writeHeaderIncludes(std::ostream& ostr)
49+
{
50+
CodeWriter::writeHeaderIncludes(ostr);
51+
ostr << "#include \"Poco/Net/HTTPRequestHandlerFactory.h\"\n";
52+
}
53+
54+
55+
void ApacheCodeWriter::writeFactoryClass(std::ostream& ostr)
56+
{
57+
ostr << "\n\n";
58+
factoryClass(ostr, "Poco::Net::HTTPRequestHandlerFactory");
59+
}
60+
61+
62+
void ApacheCodeWriter::writeImplIncludes(std::ostream& ostr)
63+
{
64+
CodeWriter::writeImplIncludes(ostr);
65+
ostr << "#include \"Poco/ClassLibrary.h\"\n";
66+
}
67+
68+
69+
void ApacheCodeWriter::writeFactory(std::ostream& ostr)
70+
{
71+
ostr << "\n\n";
72+
factoryImpl(ostr, "");
73+
}
74+
75+
76+
void ApacheCodeWriter::writeManifest(std::ostream& ostr)
77+
{
78+
std::string ns = page().get("page.namespace", "");
79+
if (!ns.empty()) ns += "::";
80+
ostr << "\n\n";
81+
ostr << "POCO_BEGIN_MANIFEST(Poco::Net::HTTPRequestHandlerFactory)\n";
82+
ostr << "\tPOCO_EXPORT_CLASS(" << ns << clazz() << "Factory)\n";
83+
ostr << "POCO_END_MANIFEST\n";
84+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//
2+
// ApacheCodeWriter.h
3+
//
4+
// $Id: //poco/Main/PageCompiler/src/ApacheCodeWriter.h#1 $
5+
//
6+
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
7+
// and Contributors.
8+
//
9+
// Permission is hereby granted, free of charge, to any person or organization
10+
// obtaining a copy of the software and accompanying documentation covered by
11+
// this license (the "Software") to use, reproduce, display, distribute,
12+
// execute, and transmit the Software, and to prepare derivative works of the
13+
// Software, and to permit third-parties to whom the Software is furnished to
14+
// do so, all subject to the following:
15+
//
16+
// The copyright notices in the Software and this entire statement, including
17+
// the above license grant, this restriction and the following disclaimer,
18+
// must be included in all copies of the Software, in whole or in part, and
19+
// all derivative works of the Software, unless such copies or derivative
20+
// works are solely in the form of machine-executable object code generated by
21+
// a source language processor.
22+
//
23+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25+
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
26+
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
27+
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
28+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29+
// DEALINGS IN THE SOFTWARE.
30+
//
31+
32+
33+
#ifndef ApacheCodeWriter_INCLUDED
34+
#define ApacheCodeWriter_INCLUDED
35+
36+
37+
#include "CodeWriter.h"
38+
39+
40+
class ApacheCodeWriter: public CodeWriter
41+
/// Code generator for ApacheConnector request handlers.
42+
{
43+
public:
44+
ApacheCodeWriter(const Page& page, const std::string& clazz);
45+
/// Creates the CodeWriter, using the given Page.
46+
47+
~ApacheCodeWriter();
48+
/// Destroys the PageReader.
49+
50+
protected:
51+
virtual void writeHeaderIncludes(std::ostream& ostr);
52+
virtual void writeFactoryClass(std::ostream& ostr);
53+
virtual void writeImplIncludes(std::ostream& ostr);
54+
virtual void writeFactory(std::ostream& ostr);
55+
virtual void writeManifest(std::ostream& ostr);
56+
};
57+
58+
59+
#endif // CodeWriter_INCLUDED

0 commit comments

Comments
 (0)