- /**
- Encodes a single character. Derived classes should use the append
- function to put the result into the internal buffer.
- */
- virtual void encode_char(wchar_t) =0;
-
- /**
- Encodes a string.
- */
- virtual void encode(const std::wstring &s)
- { for(std::wstring::const_iterator i=s.begin(); i!=s.end(); ++i) encode_char(*i); }
-
- /**
- Brings the encoder back to its initial state. This allows the encoded
- sequence to be extracted or flushed without loss of integrity.
- */
- virtual void sync() { }
-
- /**
- Returns a reference to the encoded sequence. Call sync() first to make
- sure it's a valid encoded string by itself.
- */
- const std::string &get() const { return buffer_; }
-
- /**
- Returns the number of bytes in the output buffer.
- */
- unsigned size() const { return buffer_.size(); }
-
- /**
- Clears the encoded sequence. Encoder state is left intact.
- */
- void flush() { buffer_.clear(); }
-