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 202 by Douglas Thrift, 2004-08-30T23:18:58-07:00 vs.
Revision 307 by douglas, 2004-12-12T23:07:27-08: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, const ext::String& relative) : include(include)
11   {
12 <        std::vector<std::string> args(1, FeepingCreaturism::program);
12 >        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 >
19 >        if (!relative.IsEmpty())
20 >        {
21 >                args.InsertLast("--stringparam");
22 >                args.InsertLast("relative");
23 >                args.InsertLast(relative);
24 >        }
25  
26 <        args.push_back(path);
27 <        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";
26 >        args.InsertLast("jargon.xsl");
27 >        args.InsertLast(ios::String() << path << "/" << jargon);
28   }
29  
30 < std::ostream& operator<<(std::ostream& sout, const Jargon& jargon)
30 > ios::PrintWriter& operator<<(ios::PrintWriter& pout, const Jargon& jargon)
31   {
32 <        ios::StreamBufOutputAdapter adaptor(*sout.rdbuf());
32 >        _S<api::Process> xslt("/usr/local/bin/xsltproc", jargon.args);
33 >
34 >        if (jargon.include) ios::ReadLine(*xslt.GetReader());
35 >
36 >        if (jargon.include)
37 >        {
38 >                ext::String line;
39 >                Matcher matcher("^(.*) xmlns=\"http://www.w3.org/1999/xhtml\"(.*)$");
40  
41 <        sout << jargon.word << '\n' << jargon.pronunciation << '\n'
42 <                << jargon.grammar << '\n' << jargon.definition.GetSize() << '\n';
41 >                while (ios::ReadLine(*xslt.GetReader(), line))
42 >                {
43 >                        while (line == matcher) line = matcher[1] + matcher[2];
44  
45 < /*      ios::PrintWriter writer(adaptor);
45 >                        pout << line << ios::NewLine;
46 >                }
47 >        }
48 >        else ios::ReadToWrite(*xslt.GetReader(), pout);
49  
50 <        writer << jargon.definition << '\n';*/
50 >        xslt.Join();
51  
52 <        return sout;
52 >        return pout;
53   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines