- virtual void decode_char(const std::string &, std::string::const_iterator &) =0;
- virtual void decode(const std::string &s)
- { for(std::string::const_iterator i=s.begin(); i!=s.end(); ) decode_char(s, i); }
+ virtual ~Decoder() { }
+
+ /**
+ Decodes a single character from a string. The iterator is advanced to
+ the next character. For stateful codecs, -1 may be returned if a state
+ change sequence was decoded but no character followed it. In case a
+ decoding error occurs, behavior depends on the error mode specified for
+ the decoder:
+
+ For THROW_ON_ERROR, an exception is thrown and the iterator is left at
+ the erroneous character.
+
+ For IGNORE_ERRORS, -1 is returned and the iterator is advanced.
+
+ For TRANSLITERATE, 0xFFFE is returned and the iterator is advanced.
+ */
+ virtual UnicodeChar decode_char(const std::string &str, std::string::const_iterator &i) =0;