ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/FeepingCreaturism/Jargon.cpp
(Generate patch)

Comparing FeepingCreaturism/Jargon.cpp (file contents):
Revision 201 by Douglas Thrift, 2004-08-30T19:24:40-07:00 vs.
Revision 270 by Douglas Thrift, 2004-10-27T23:44:48-07:00

# Line 5 | Line 5
5   // $Id$
6  
7   #include "Jargon.hpp"
8 + #include "Matcher.hpp"
9  
10 < Jargon::Jargon(const std::string& path)
10 > Jargon::Jargon(const ext::String& path, const ext::String& jargon, bool include,
11 >        const ext::String& relative) : include(include)
12   {
13 <        std::vector<std::string> args(1, FeepingCreaturism::program);
13 >        args.InsertLast("--stringparam");
14 >        args.InsertLast("jargon");
15 >        args.InsertLast(jargon);
16 >        args.InsertLast("--param");
17 >        args.InsertLast("include");
18 >        args.InsertLast(ios::String() << include << "()");
19 >
20 >        if (!relative.IsEmpty())
21 >        {
22 >                args.InsertLast("--stringparam");
23 >                args.InsertLast("relative");
24 >                args.InsertLast(relative);
25 >        }
26  
27 <        args.push_back(path);
28 <        args.push_back("jargon.xsl");
15 <
16 <        redi::pstreambuf pin("/usr/local/bin/Xalan", args, std::ios_base::in);
17 <        ios::StreamBufInputAdapter adaptor(pin);
18 <        ext::Handle<xml::Document> document(xml::Parse(adaptor));
19 <        ext::Handle<xml::Node> jargon(*document/"Jargon");
20 <
21 <        word = *jargon/"Word";
22 <        pronunciation = *jargon/"Pronunciation";
23 <        grammar = *jargon/"Grammar";
24 <        definition = *jargon/"Definition";
27 >        args.InsertLast("jargon.xsl");
28 >        args.InsertLast(ios::String() << path << "/" << jargon);
29   }
30  
31 < std::ostream& operator<<(std::ostream& sout, const Jargon& jargon)
31 > ios::PrintWriter& operator<<(ios::PrintWriter& pout, const Jargon& jargon)
32   {
33 <        ios::StreamBufOutputAdapter adaptor(*sout.rdbuf());
33 >        _S<api::Process> xslt("/usr/local/bin/xsltproc", jargon.args);
34 >
35 >        if (jargon.include) ios::ReadLine(*xslt.GetReader());
36 >
37 >        if (jargon.include)
38 >        {
39 >                ext::String line;
40 >                Matcher matcher("^(.*) xmlns=\"http://www.w3.org/1999/xhtml\"(.*)$");
41  
42 <        sout << jargon.word << '\n' << jargon.pronunciation << '\n'
43 <                << jargon.grammar << '\n' << jargon.definition.GetSize() << '\n';
42 >                while (ios::ReadLine(*xslt.GetReader(), line))
43 >                {
44 >                        while (line == matcher) line = matcher[1] + matcher[2];
45  
46 < /*      ios::PrintWriter writer(adaptor);
46 >                        pout << line << ios::NewLine;
47 >                }
48 >        }
49 >        else ios::ReadToWrite(*xslt.GetReader(), pout);
50  
51 <        writer << jargon.definition << '\n';*/
51 >        xslt.Join();
52  
53 <        return sout;
53 >        return pout;
54   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines