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 254 by Douglas Thrift, 2004-09-14T17:42:21-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 >        args(1, FeepingCreaturism::program)
13   {
14 <        std::vector<std::string> args(1, FeepingCreaturism::program);
14 >        args.push_back("-m");
15 >        args.push_back("-p");
16 >        args.push_back("jargon");
17 >        args.push_back("\"" + jargon + "\"");
18 >        args.push_back("-p");
19 >        args.push_back("include");
20 >        args.push_back(lexical_cast<ext::String>(include) + "()");
21 >
22 >        if (!relative.IsEmpty())
23 >        {
24 >                args.push_back("-p");
25 >                args.push_back("relative");
26 >                args.push_back("\"" + relative + "\"");
27 >        }
28  
29 <        args.push_back(path);
29 >        args.push_back(path + "/" + jargon);
30          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";
31   }
32  
33 < std::ostream& operator<<(std::ostream& sout, const Jargon& jargon)
33 > ios::PrintWriter& operator<<(ios::PrintWriter& pout, const Jargon& jargon)
34   {
35 <        ios::StreamBufOutputAdapter adaptor(*sout.rdbuf());
35 >        redi::ipstream pin("/usr/local/bin/Xalan", jargon.args);
36 >
37 >        if (jargon.include)
38 >        {
39 >                std::string ignore;
40 >
41 >                std::getline(pin, ignore);
42 >        }
43 >
44 >        do
45 >        {
46 >                std::string line;
47 >
48 >                std::getline(pin, line);
49  
50 <        sout << jargon.word << '\n' << jargon.pronunciation << '\n'
51 <                << jargon.grammar << '\n' << jargon.definition.GetSize() << '\n';
50 >                while (jargon.include && line.find(" xmlns=") != std::string::npos)
51 >                {
52 >                        std::string::size_type position(line.find(" xmlns="));
53  
54 < /*      ios::PrintWriter writer(adaptor);
54 >                        line.replace(position, 37, "");
55 >                }
56  
57 <        writer << jargon.definition << '\n';*/
57 >                pout << line << "\n";
58 >        }
59 >        while (pin.good());
60  
61 <        return sout;
61 >        return pout;
62   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines