4 |
|
// |
5 |
|
// $Id$ |
6 |
|
|
7 |
+ |
#include <cxx/standard.hh> |
8 |
+ |
|
9 |
+ |
#include <api/pcre/regex.hpp> |
10 |
+ |
|
11 |
|
#include "Jargon.hpp" |
8 |
– |
#include "Matcher/Matcher.hpp" |
12 |
|
|
13 |
< |
Jargon::Jargon(const ext::String& path, const ext::String& jargon, bool include, const ext::String& relative) : include(include) |
13 |
> |
Jargon::Jargon(const cse::String &path, const cse::String &jargon, bool include, const cse::String &relative) : include(include) |
14 |
|
{ |
15 |
< |
args.InsertLast("--stringparam"); |
16 |
< |
args.InsertLast("jargon"); |
15 |
> |
args.InsertLast(_B("--stringparam")); |
16 |
> |
args.InsertLast(_B("jargon")); |
17 |
|
args.InsertLast(jargon); |
18 |
< |
args.InsertLast("--param"); |
19 |
< |
args.InsertLast("include"); |
20 |
< |
args.InsertLast(ios::String() << include << "()"); |
18 |
> |
args.InsertLast(_B("--param")); |
19 |
> |
args.InsertLast(("include")); |
20 |
> |
args.InsertLast(_S<ios::String>() << include << _B("()")); |
21 |
|
|
22 |
|
if (!relative.IsEmpty()) |
23 |
|
{ |
24 |
< |
args.InsertLast("--stringparam"); |
25 |
< |
args.InsertLast("relative"); |
24 |
> |
args.InsertLast(_B("--stringparam")); |
25 |
> |
args.InsertLast(_B("relative")); |
26 |
|
args.InsertLast(relative); |
27 |
|
} |
28 |
|
|
29 |
< |
args.InsertLast("jargon.xsl"); |
30 |
< |
args.InsertLast(ios::String() << path << "/" << jargon); |
29 |
> |
args.InsertLast(_B("jargon.xsl")); |
30 |
> |
args.InsertLast(_S<ios::String>() << path << _B("/") << jargon); |
31 |
|
} |
32 |
|
|
33 |
< |
ios::PrintWriter& operator<<(ios::PrintWriter& pout, const Jargon& jargon) |
33 |
> |
ios::PrintWriter &operator<<(ios::PrintWriter &output, const Jargon &jargon) |
34 |
|
{ |
35 |
< |
_S<api::Process> xslt("/usr/local/bin/xsltproc", jargon.args); |
35 |
> |
_S<api::Process> xslt(_B("/usr/local/bin/xsltproc"), jargon.args); |
36 |
|
|
37 |
|
if (jargon.include) ios::ReadLine(*xslt.GetReader()); |
38 |
|
|
39 |
|
if (jargon.include) |
40 |
|
{ |
41 |
< |
ext::String line; |
42 |
< |
Matcher matcher("^(.*) xmlns=\"http://www.w3.org/1999/xhtml\"(.*)$"); |
41 |
> |
ext::Buffer line; |
42 |
> |
api::Pcre::RegEx matcher(_B("^(.*) xmlns=\"http://www.w3.org/1999/xhtml\"(.*)$")); |
43 |
|
|
44 |
|
while (ios::ReadLine(*xslt.GetReader(), line)) |
45 |
|
{ |
46 |
< |
while (line == matcher) line = matcher[1] + matcher[2]; |
46 |
> |
while (api::Pcre::RegEx::Match match = matcher(line)) |
47 |
> |
line = _S<ios::Buffer>() << match[1] << match[2]; |
48 |
|
|
49 |
< |
pout << line << ios::NewLine; |
49 |
> |
output << line << ios::NewLine; |
50 |
|
} |
51 |
|
} |
52 |
< |
else ios::ReadToWrite(*xslt.GetReader(), pout); |
52 |
> |
else |
53 |
> |
ios::ReadToWrite(*xslt.GetReader(), output); |
54 |
|
|
55 |
< |
return pout; |
55 |
> |
return output; |
56 |
|
} |