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

Comparing trunk/WinXPFAQPoll/Poller.cpp (file contents):
Revision 118 by douglas, 2003-04-01T13:41:03-08:00 vs.
Revision 119 by douglas, 2003-04-01T14:49:17-08:00

# Line 22 | Line 22 | Poller::Poller()
22   void Poller::poll(bool nodelete, const string& file)
23   {
24          this->nodelete = nodelete;
25 +        this->file = file;
26 +
27 +        load();
28 +
29 +        //
30 +
31 + //      save();
32 + }
33 +
34 + void Poller::load()
35 + {
36 +        ifstream fin(file.c_str());
37 +        if (!fin.is_open())
38 +        {
39 +                ofstream fout(file.c_str());
40 +
41 +                fout << "_find_\n"
42 +                        << "reply=0\n"
43 +                        << "news=0\n"
44 +                        << "sig=0\n"
45 +                        << "search=0\n"
46 +                        << "link=0\n"
47 +                        << "browse=0\n"
48 +                        << "other=0\n"
49 +                        << "_help_\n"
50 +                        << "solved=0\n"
51 +                        << "note=0\n"
52 +                        << "link=0\n"
53 +                        << "news=0\n"
54 +                        << "lazy=0\n"
55 +                        << "_improve_\n"
56 +                        << "nothing=0\n"
57 +                        << "links=0\n"
58 +                        << "suggest=0\n";
59 +
60 +                fout.close();
61 +
62 +                fin.open(file.c_str());
63 +        }
64 +
65 +        do
66 +        {
67 +                enum { FIND, HELP, IMPROVE } type;
68 +                string vote;
69 +                unsigned count;
70 +                string text;
71 +
72 +                getline(fin, vote, '=');
73 +                if (debug) cerr << "vote = " << vote << "\n";
74 +
75 +                if (vote == "_find_")
76 +                {
77 +                        type = FIND;
78 +                        continue;
79 +                }
80 +                else if (vote == "_help_")
81 +                {
82 +                        type = HELP;
83 +                        continue;
84 +                }
85 +                else if (vote == "_improve_")
86 +                {
87 +                        type = IMPROVE;
88 +                        continue;
89 +                }
90 +                else if (vote == "approved" || vote == "approve")
91 +                {
92 +                        getline(fin, text);
93 +                }
94 +                else
95 +                {
96 +                        fin >> count;
97 +                        fin.get();
98 +                }
99 +
100 +                switch (type)
101 +                {
102 +                case FIND:
103 +                        if (vote == "reply")
104 +                        {
105 +                                find.reply = count;
106 +                        }
107 +                        else if (vote == "news")
108 +                        {
109 +                                find.news = count;
110 +                        }
111 +                        else if (vote == "sig")
112 +                        {
113 +                                find.sig = count;
114 +                        }
115 +                        else if (vote == "search")
116 +                        {
117 +                                find.search = count;
118 +                        }
119 +                        else if (vote == "link")
120 +                        {
121 +                                find.link = count;
122 +                        }
123 +                        else if (vote == "browse")
124 +                        {
125 +                                find.browse = count;
126 +                        }
127 +                        else if (vote == "other")
128 +                        {
129 +                                find.other = count;
130 +                        }
131 +                        else if (vote == "approved")
132 +                        {
133 +                                find.approved.push_back(text);
134 +                        }
135 +                        else if (vote == "approve")
136 +                        {
137 +                                find.approve.push_back(text);
138 +                        }
139 +                        break;
140 +                case HELP:
141 +                        if (vote == "solved")
142 +                        {
143 +                                help.solved = count;
144 +                        }
145 +                        else if (vote == "note")
146 +                        {
147 +                                help.note = count;
148 +                        }
149 +                        else if (vote == "link")
150 +                        {
151 +                                help.link = count;
152 +                        }
153 +                        else if (vote == "news")
154 +                        {
155 +                                help.news = count;
156 +                        }
157 +                        else if (vote == "lazy")
158 +                        {
159 +                                help.lazy = count;
160 +                        }
161 +                        break;
162 +                case IMPROVE:
163 +                        if (vote == "nothing")
164 +                        {
165 +                                improve.nothing = count;
166 +                        }
167 +                        else if (vote == "links")
168 +                        {
169 +                                improve.links = count;
170 +                        }
171 +                        else if (vote == "suggest")
172 +                        {
173 +                                improve.suggest = count;
174 +                        }
175 +                        else if (vote == "approved")
176 +                        {
177 +                                improve.approved.push_back(text);
178 +                        }
179 +                        else if (vote == "approve")
180 +                        {
181 +                                improve.approve.push_back(text);
182 +                        }
183 +                        break;
184 +                }
185 +        }
186 +        while (fin.good());
187 +
188 +        fin.close();
189 + }
190 +
191 + void Poller::save()
192 + {
193 +        ofstream fout(file.c_str());
194 +
195 +        //
196 +
197 +        fout.close();
198   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines