arabica/include/convert/rot13codecvt.hpp

72 lines
2 KiB
C++
Raw Normal View History

2003-08-29 15:37:59 +02:00
#ifndef ARABICA_ROT13_CODECVT_H
#define ARABICA_ROT13_CODECVT_H
2003-08-28 22:26:26 +02:00
///////////////////////////////////////////
//
// $Id$
//
///////////////////////////////////////////
#include <locale>
2007-09-05 00:55:47 +02:00
#include <SAX/ArabicaConfig.hpp>
2003-09-10 17:15:55 +02:00
#ifdef ARABICA_VS6_WORKAROUND
2007-09-05 00:55:47 +02:00
#include <Utils/impl/VS6Workaround.hpp>
2003-09-10 17:15:55 +02:00
#endif
2003-08-28 22:26:26 +02:00
2003-09-11 16:05:18 +02:00
namespace Arabica
{
namespace convert
{
2003-08-28 22:26:26 +02:00
2003-09-10 17:15:55 +02:00
class rot13codecvt : public std::codecvt<char, char, std::mbstate_t>
{
2003-08-28 22:26:26 +02:00
protected:
2003-08-29 15:37:59 +02:00
virtual ~rot13codecvt() { }
2003-08-28 22:26:26 +02:00
2003-09-10 17:15:55 +02:00
virtual result do_out(std::mbstate_t& state,
2003-08-28 22:26:26 +02:00
const char* from,
const char* from_end,
const char*& from_next,
char* to,
char* to_limit,
char*& to_next) const
{ return rot13(from, from_end, from_next, to, to_limit, to_next); }
2003-09-10 17:15:55 +02:00
virtual result do_in(std::mbstate_t& state,
2003-08-28 22:26:26 +02:00
const char* from,
const char* from_end,
const char*& from_next,
char* to,
char* to_limit,
char*& to_next) const
{ return rot13(from, from_end, from_next, to, to_limit, to_next); }
2003-09-10 17:15:55 +02:00
virtual result do_unshift(std::mbstate_t& state,
2003-08-28 22:26:26 +02:00
char* to,
char* to_limit,
char*& to_next) const;
2003-08-29 15:37:59 +02:00
virtual int do_encoding() const throw() { return 1; }
2003-08-28 22:26:26 +02:00
2003-08-29 15:37:59 +02:00
virtual bool do_always_noconv() const throw() { return false; }
2003-08-28 22:26:26 +02:00
2003-09-10 17:15:55 +02:00
virtual int do_length(const std::mbstate_t&,
2003-08-28 22:26:26 +02:00
const char* from,
const char* end,
size_t max) const;
2003-08-29 15:37:59 +02:00
virtual int do_max_length() const throw() { return 1; }
2003-08-28 22:26:26 +02:00
private:
result rot13(const char* from,
const char* from_end,
const char*& from_next,
char* to,
char* to_limit,
char*& to_next) const;
2003-08-29 15:37:59 +02:00
}; // class rot13codecvt
2003-08-28 22:26:26 +02:00
2003-09-11 16:05:18 +02:00
} // namespace convert
} // namespace Arabica
2003-08-28 22:26:26 +02:00
#endif