The Annoyance Filter.pdf - Fourmilab
The Annoyance Filter.pdf - Fourmilab
The Annoyance Filter.pdf - Fourmilab
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
§114 ANNOYANCE-FILTER FLASH TEXT EXTRACTOR 93<br />
114. Flash text extractor.<br />
<strong>The</strong> flashTextExtractor extends flashStream to parse tags containing text fields and return them<br />
with the nextString method. We define this as a separate class in order to encapsulate all of the string<br />
parsing machinery in one place, while leaving flashStream a general-purpose .swf file parser adaptable<br />
to other purposes.<br />
〈 Class definitions 10 〉 +≡<br />
class flashTextExtractor : public flashStream {<br />
protected: map〈unsigned short, vector〈unsigned short〉 ∗〉 fontMap;<br />
map〈unsigned short, unsigned short〉 fontGlyphCount ;<br />
map〈unsigned short, fontFlags〉 fontInfoBits ;<br />
queue〈string〉 strings ;<br />
bool initialised ; /∗ Options ∗/<br />
bool textOnly ; /∗ Return only text (not font names, URLs, etc.) ∗/<br />
public: flashTextExtractor(mailFolder ∗f = Λ)<br />
: flashStream(f), initialised (false ), textOnly (false ) { }<br />
∼flashTextExtractor( )<br />
{<br />
close ( );<br />
}<br />
virtual string name (void) const<br />
{<br />
return "Flash";<br />
}<br />
void setTextOnly (const bool tf )<br />
{<br />
textOnly = tf ;<br />
}<br />
bool getTextOnly (void) const<br />
{<br />
return textOnly ;<br />
}<br />
bool nextString (string &s); /∗ Return next string from Flash file ∗/<br />
virtual void close (void)<br />
{<br />
while (¬fontMap.empty ( )) {<br />
delete fontMap.begin ( ) ⃗ second ;<br />
fontMap.erase (fontMap.begin ( ));<br />
}<br />
fontGlyphCount .clear ( );<br />
fontInfoBits .clear ( );<br />
while (¬strings .empty ( )) {<br />
strings .pop( );<br />
}<br />
initialised = textOnly = false ;<br />
flashStream ::close ( );<br />
}<br />
};