12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

94 FLASH TEXT EXTRACTOR ANNOYANCE-FILTER §115<br />

115. Return the next string (which may contain any number of tokens) from the Flash file. If the<br />

strings queue contains already-parsed strings, return and delete the the item at the head of the queue.<br />

Otherwise, we parse our way through the Flash file, adding any strings which appear in tags to the<br />

strings queue. If, after parsing a tag, we find strings non-empty, we return the first item in the queue.<br />

<strong>The</strong> method returns true if a string was stored and false when the end of the Flash file is encountered.<br />

<strong>The</strong> first time this method is called, we read the Flash file header and validate it. If an error occurs<br />

in the process, we treat the event as a logical end of file.<br />

〈 Class implementations 11 〉 +≡<br />

bool flashTextExtractor ::nextString (string &s)<br />

{<br />

if (¬initialised ) {<br />

initialised = true ;<br />

readHeader ( );<br />

if (¬isOK ( )) {<br />

if (verbose ) {<br />

cerr ≪ "Invalid␣header␣in␣Flash␣application␣file." ≪ endl ;<br />

close ( );<br />

while (¬isEOF ( )) {<br />

get8 ( ); /∗ Discard contents after error ∗/<br />

}<br />

return false ;<br />

}<br />

}<br />

}<br />

while (true ) {<br />

haveStrings :<br />

〈 Check for strings in the queue and return first if queue not empty 116 〉;<br />

while ((¬isEOF ( )) ∧ (¬isError ( )) ∧ nextTag ( )) {<br />

unsigned int variant = 0; /∗ Twiddley-puke variant type for tags ∗/<br />

switch (tType ) {<br />

case stagDefineFont :<br />

〈 Parse Flash DefineFont tag 117 〉;<br />

break;<br />

case stagDefineFont2 :<br />

〈 Parse Flash DefineFont2 tag 118 〉;<br />

break;<br />

case stagDefineFontInfo:<br />

〈 Parse Flash DefineFontInfo tag 119 〉;<br />

break;<br />

case stagDefineText2 : /∗ Like stagDefineText , but colour is RGBA ∗/<br />

variant = 2; /∗ Note fall-through ∗/<br />

case stagDefineText :<br />

〈 Parse Flash DefineText tags 120 〉;<br />

break;<br />

case stagDefineEditText :<br />

〈 Parse Flash DefineEditText tag 122 〉;<br />

break;<br />

case stagFrameLabel :<br />

〈 Parse Flash FrameLabel tag 123 〉;<br />

break;<br />

case stagDoAction :<br />

〈 Parse Flash DoAction tag 124 〉;

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

Saved successfully!

Ooh no, something went wrong!