ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/zoe/trunk/Zoe.cpp
(Generate patch)

Comparing trunk/Zoe.cpp (file contents):
Revision 5 by douglas, 2004-07-09T15:04:18-07:00 vs.
Revision 13 by douglas, 2004-07-11T23:49:09-07:00

# Line 4 | Line 4
4   //
5   // $Id$
6  
7 #include "Zoe.hpp"
7   #include "Matcher.hpp"
8 + #include "Collector.hpp"
9 + #include "Publisher.hpp"
10  
11   int main(int argc, char* argv[])
12   {
13 <        //
13 >        Zoe::program = argv[0];
14 >
15 >        for (int index(1); index < argc; ++index)
16 >        {
17 >                ext::String arg(argv[index]);
18 >                Matcher matcher;
19 >
20 >                if (arg == matcher("^-config=(.*)$"))
21 >                {
22 >                        Zoe::config = matcher[1];
23 >                }
24 >                else if (arg == "-collector")
25 >                {
26 >                        if (!Zoe::collector) Zoe::collector = true;
27 >                }
28 >                else if (arg == "-publisher")
29 >                {
30 >                        if (!Zoe::publisher) Zoe::publisher = true;
31 >                }
32 >                else if (arg == "-D")
33 >                {
34 >                        if (!Zoe::debug) Zoe::debug = true;
35 >                }
36 >                else
37 >                {
38 >                        cerr << "Usage: " << Zoe::program << " [-config=config] [-collector"
39 >                           << "] [-publisher] [-D]\n";
40 >
41 >                        return 1;
42 >                }
43 >        }
44 >
45 >        Zoe zoe;
46  
47          return 0;
48   }
49 +
50 + Zoe::Zoe()
51 + {
52 +        configure();
53 +
54 +        if (collector) Collector collector(buddies);
55 +        if (publisher) Publisher publisher(buddies);
56 + }
57 +
58 + bool Zoe::debug(false), Zoe::collector(false), Zoe::publisher(false);
59 + ext::String Zoe::program, Zoe::config("zoe.xml");
60 +
61 + void Zoe::configure()
62 + {
63 +        ext::Handle<xml::Document> document(xml::Parse(config));
64 +        ext::Handle<xml::Node> zoe(*document/"zoe");
65 +
66 +        login = std::string(*zoe/"login");
67 +        password = std::string(*zoe/"password");
68 +
69 +        xml::NodeSet buddies(*zoe/"buddy");
70 +
71 +        for (xml::NodeSet::Iterator buddy(buddies.Begin()); buddy != buddies.End();
72 +                ++buddy)
73 +        {
74 +                this->buddies.insert(Buddy(**buddy/"login", **buddy/"rss"));
75 +        }
76 +
77 +        if (!collector && !publisher)
78 +        {
79 +                collector = true;
80 +                publisher = true;
81 +        }
82 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines