12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

§182 ANNOYANCE-FILTER TOKEN PARSER 155<br />

182. <strong>The</strong> messageQueue can be used to store the lines of a message: “what the parser saw,” after<br />

MIME decoding (but not elision of HTML comments or other processing in the parser itself). This is<br />

handy when debugging the lower level stuff. To enable saving messages in the queue, call setSaveMessage<br />

with an argument of true . <strong>The</strong> contents of messageQueue may be examined directly (it is a public<br />

member of the class), or written to an ostream with writeMessageQueue . One little detail—if you<br />

examine the messageQueue after the start of the next message in a folder has been detected, the first<br />

line of the next message will be the last item in the message queue; writeMessageQueue understands<br />

this and doesn’t write the line, but if you’re looking at the queue yourself it’s up to you to cope with<br />

this.<br />

〈 Message queue utilities 182 〉 ≡<br />

void setSaveMessage (bool v)<br />

{<br />

saveMessage = v;<br />

source ⃗ setDiagnosticList (saveMessage ? (&messageQueue ) : Λ);<br />

}<br />

bool getSaveMessage (void) const<br />

{<br />

return saveMessage ;<br />

}<br />

void clearMessageQueue (void)<br />

{<br />

if (saveMessage ) {<br />

string s;<br />

}<br />

}<br />

if (isNewMessage ( )) {<br />

s = messageQueue .back ( );<br />

}<br />

messageQueue .clear ( );<br />

if (isNewMessage ( )) {<br />

messageQueue .push back (s);<br />

}<br />

void writeMessageQueue (ostream &os )<br />

{<br />

list〈string〉::size type l = messageQueue .size ( ), n = 0;<br />

for (list〈string〉::iterator p = messageQueue .begin ( ); p ≠ messageQueue .end ( ); p++, n++) {<br />

if (¬((n ≡ (l − 1)) ∧ (p ⃗ substr (0, (sizeof messageSentinel ) − 1) ≡ messageSentinel ))) {<br />

os ≪ ∗p ≪ endl ;<br />

}<br />

}<br />

}<br />

This code is used in section 173.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!