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.

§68 ANNOYANCE-FILTER DECODER PARENT CLASS 63<br />

68. Decoder parent class.<br />

This is the abstract parent class of all specific decoders. Albeit abstract in the details, we provide a<br />

variety of services to derived classes.<br />

〈 Class definitions 10 〉 +≡<br />

class MBCSdecoder {<br />

protected:<br />

const string ∗src;<br />

string ::size type p;<br />

mailFolder ∗mf ;<br />

public:<br />

MBCSdecoder(mailFolder ∗m = Λ)<br />

: src(Λ), p(0), mf (Λ) { }<br />

virtual ∼MBCSdecoder( )<br />

{ }<br />

virtual string name (void) = 0; /∗ Name of decoder ∗/<br />

virtual void setSource (const string &s)<br />

{ /∗ Set input source line ∗/<br />

src = &s;<br />

p = 0;<br />

}<br />

virtual void setMailFolder (mailFolder ∗m = Λ)<br />

{<br />

mf = m;<br />

}<br />

virtual void reset (void)<br />

{ /∗ Reset stateful decoder to ground state ∗/<br />

}<br />

virtual int getNextDecodedChar (void) = 0; /∗ Get next decoded character ∗/<br />

virtual int getNextEncodedByte (void)<br />

{<br />

if (p ≥ src ⃗ length ( )) {<br />

return −1;<br />

}<br />

return ((∗src)[p++]) & # FF;<br />

}<br />

protected:<br />

virtual int getNextNBytes (const unsigned int n);<br />

virtual int getNext2Bytes (void)<br />

{<br />

return getNextNBytes (2);<br />

}<br />

virtual int getNext3Bytes (void)<br />

{<br />

return getNextNBytes (3);<br />

}<br />

virtual int getNext4Bytes (void)<br />

{<br />

return getNextNBytes (4);<br />

}

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

Saved successfully!

Ooh no, something went wrong!