Mercurial > archived > louis > epitech > zia-api
view examples/rot13/Rot13Handler.cpp @ 41:7c8cd74023ce
Rework file layout, fix build, add README and SUPPORT
author | Louis Opter <kalessin@kalessin.fr> |
---|---|
date | Mon, 22 Mar 2010 02:08:24 +0100 |
parents | src/examples/rot13/Rot13Handler.cpp@aa427c18ffe2 |
children |
line wrap: on
line source
#include "Rot13Handler.hpp" namespace { /** * @brief Convert a char to its rot13 value. * * @param [in] c The char to encode. * * @return The encoded char. */ char Rot13Char(char c) { if ((c >= ('a' + 13) && c <= 'z') || (c >= ('A' + 13) && c <= 'Z' )) c -= 13; else if ((c >= 'a' && c < 'a' + 13) || (c >= 'A' && c < 'A' + 13)) c += 13; return (c); } }; zia::api::handler::EHook Rot13Handler::getHook(void) const { return (zia::api::handler::ResponseBodyModifier); } zia::api::handler::ECode Rot13Handler::operator()(zia::api::http::ITransaction &, std::istream &, std::ostream &) { return (zia::api::handler::Ok); } zia::api::handler::ECode Rot13Handler::operator()(std::istream & is, std::ostream & os) { while (!is.eof()) { char c; is.get(c); os << Rot13Char(c); } return (zia::api::handler::Ok); }