1 |
Douglas Thrift |
196 |
// Feeping Creaturism |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
|
|
#include "Jargon.hpp" |
8 |
Douglas Thrift |
224 |
#include "Matcher.hpp" |
9 |
Douglas Thrift |
196 |
|
10 |
douglas |
307 |
Jargon::Jargon(const ext::String& path, const ext::String& jargon, bool include, const ext::String& relative) : include(include) |
11 |
Douglas Thrift |
196 |
{ |
12 |
Douglas Thrift |
267 |
args.InsertLast("--stringparam"); |
13 |
|
|
args.InsertLast("jargon"); |
14 |
|
|
args.InsertLast(jargon); |
15 |
|
|
args.InsertLast("--param"); |
16 |
|
|
args.InsertLast("include"); |
17 |
|
|
args.InsertLast(ios::String() << include << "()"); |
18 |
Douglas Thrift |
225 |
|
19 |
|
|
if (!relative.IsEmpty()) |
20 |
|
|
{ |
21 |
Douglas Thrift |
267 |
args.InsertLast("--stringparam"); |
22 |
|
|
args.InsertLast("relative"); |
23 |
|
|
args.InsertLast(relative); |
24 |
Douglas Thrift |
225 |
} |
25 |
Douglas Thrift |
267 |
|
26 |
|
|
args.InsertLast("jargon.xsl"); |
27 |
|
|
args.InsertLast(ios::String() << path << "/" << jargon); |
28 |
Douglas Thrift |
227 |
} |
29 |
Douglas Thrift |
196 |
|
30 |
Douglas Thrift |
227 |
ios::PrintWriter& operator<<(ios::PrintWriter& pout, const Jargon& jargon) |
31 |
|
|
{ |
32 |
Douglas Thrift |
267 |
_S<api::Process> xslt("/usr/local/bin/xsltproc", jargon.args); |
33 |
Douglas Thrift |
196 |
|
34 |
Douglas Thrift |
265 |
if (jargon.include) ios::ReadLine(*xslt.GetReader()); |
35 |
Douglas Thrift |
224 |
|
36 |
Douglas Thrift |
267 |
if (jargon.include) |
37 |
|
|
{ |
38 |
|
|
ext::String line; |
39 |
|
|
Matcher matcher("^(.*) xmlns=\"http://www.w3.org/1999/xhtml\"(.*)$"); |
40 |
Douglas Thrift |
224 |
|
41 |
Douglas Thrift |
267 |
while (ios::ReadLine(*xslt.GetReader(), line)) |
42 |
|
|
{ |
43 |
|
|
while (line == matcher) line = matcher[1] + matcher[2]; |
44 |
|
|
|
45 |
|
|
pout << line << ios::NewLine; |
46 |
|
|
} |
47 |
|
|
} |
48 |
|
|
else ios::ReadToWrite(*xslt.GetReader(), pout); |
49 |
|
|
|
50 |
Douglas Thrift |
270 |
xslt.Join(); |
51 |
|
|
|
52 |
Douglas Thrift |
227 |
return pout; |
53 |
Douglas Thrift |
196 |
} |