ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/zoe/trunk/Zoe.cpp
Revision: 14
Committed: 2004-07-12T17:14:48-07:00 (20 years, 11 months ago) by douglas
File size: 2079 byte(s)
Log Message:
Now, with color.

File Contents

# User Rev Content
1 douglas 5 // Zoe AIM Away Message RSS Feed Generator
2     //
3     // Seth King and Douglas Thrift
4     //
5     // $Id$
6    
7     #include "Matcher.hpp"
8 douglas 13 #include "Collector.hpp"
9     #include "Publisher.hpp"
10 douglas 5
11 douglas 14 enum Color { reset, bright, dim, underscore = 4, blink, reverse = 7, hidden,
12     black = 30, red, green, yellow, blue, magenta, cyan, white, _black = 40,
13     _red, _green, _yellow, _blue, _magenta, _cyan, _white };
14    
15     inline std::ostream& operator<<(std::ostream& sout, Color color)
16     {
17     sout << "\033[" << unsigned(color) << 'm';
18    
19     return sout;
20     }
21    
22 douglas 5 int main(int argc, char* argv[])
23     {
24 douglas 7 Zoe::program = argv[0];
25 douglas 5
26 douglas 7 for (int index(1); index < argc; ++index)
27     {
28     ext::String arg(argv[index]);
29     Matcher matcher;
30    
31     if (arg == matcher("^-config=(.*)$"))
32     {
33     Zoe::config = matcher[1];
34     }
35 douglas 13 else if (arg == "-collector")
36     {
37     if (!Zoe::collector) Zoe::collector = true;
38     }
39     else if (arg == "-publisher")
40     {
41     if (!Zoe::publisher) Zoe::publisher = true;
42     }
43 douglas 7 else if (arg == "-D")
44     {
45     if (!Zoe::debug) Zoe::debug = true;
46     }
47     else
48     {
49 douglas 14 cerr << bright << "Usage: " << cyan << Zoe::program << reset << " ["
50     << bright << blue << "-config=" << yellow << "config" << reset
51     << "] [" << bright << blue << "-collector" << reset << "] ["
52     << bright << blue << "-publisher" << reset << "] [" << bright
53     << blue << "-D" << reset << "]\n";
54 douglas 9
55     return 1;
56 douglas 7 }
57     }
58    
59     Zoe zoe;
60    
61 douglas 5 return 0;
62     }
63 douglas 7
64 douglas 12 Zoe::Zoe()
65 douglas 7 {
66     configure();
67 douglas 8
68 douglas 13 if (collector) Collector collector(buddies);
69     if (publisher) Publisher publisher(buddies);
70 douglas 7 }
71    
72 douglas 13 bool Zoe::debug(false), Zoe::collector(false), Zoe::publisher(false);
73 douglas 7 ext::String Zoe::program, Zoe::config("zoe.xml");
74    
75     void Zoe::configure()
76     {
77     ext::Handle<xml::Document> document(xml::Parse(config));
78     ext::Handle<xml::Node> zoe(*document/"zoe");
79    
80 douglas 12 login = std::string(*zoe/"login");
81     password = std::string(*zoe/"password");
82 douglas 7
83 douglas 12 xml::NodeSet buddies(*zoe/"buddy");
84    
85     for (xml::NodeSet::Iterator buddy(buddies.Begin()); buddy != buddies.End();
86     ++buddy)
87     {
88     this->buddies.insert(Buddy(**buddy/"login", **buddy/"rss"));
89     }
90 douglas 13
91     if (!collector && !publisher)
92     {
93     collector = true;
94     publisher = true;
95     }
96 douglas 7 }

Properties

Name Value
svn:eol-style native
svn:keywords Id