Mercurial > archived > louis > epitech > zia-api
changeset 7:0c2a143b5076
[rot13] The example was modfifier so it now works on stringbuf.
The streambuf implementation was moved to a separate folder
author | Zoltan K |
---|---|
date | Sat, 20 Mar 2010 00:36:10 +0100 |
parents | e39c4397764c |
children | ae71dacad48e |
files | src/examples/Buffer/Buffer.cpp src/examples/Buffer/Buffer.hpp src/examples/rot13/CMakeLists.txt src/examples/rot13/main.cpp |
diffstat | 4 files changed, 60 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/examples/Buffer/Buffer.cpp Sat Mar 20 00:36:10 2010 +0100 @@ -0,0 +1,26 @@ +#include <iostream> + +#include "Buffer.hpp" + +Buffer::Buffer(void) + : _rawBuffer() +{ + char *s; + std::streamsize n = 1024; + + this->_rawBuffer.resize(n, 0); + s = &_rawBuffer[0]; + this->setg(s, s, s + n); + this->setp(s, s + n); +} + +int Buffer::sync(void) +{ + std::cout << "Buffer is being sync." << std::endl; + return (0); +} + +int Buffer::underflow(void) +{ + return (EOF); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/examples/Buffer/Buffer.hpp Sat Mar 20 00:36:10 2010 +0100 @@ -0,0 +1,29 @@ +#ifndef _BUFFER_HPP_ +# define _BUFFER_HPP_ + +#include <streambuf> +#include <vector> + +class Buffer : public std::streambuf +{ + +public: + + Buffer(void); + virtual ~Buffer(void) { } + +protected: + + virtual int sync(void); + virtual int underflow(void); + +private: + Buffer(const Buffer & cpy); + +private: + + std::vector<char> _rawBuffer; + +}; + +#endif // ! _BUFFER_HPP_
--- a/src/examples/rot13/CMakeLists.txt Sat Mar 20 00:29:12 2010 +0100 +++ b/src/examples/rot13/CMakeLists.txt Sat Mar 20 00:36:10 2010 +0100 @@ -1,6 +1,5 @@ SET(ROT13_SRC main.cpp - Buffer.cpp Rot13Module.cpp Rot13Handler.cpp )
--- a/src/examples/rot13/main.cpp Sat Mar 20 00:29:12 2010 +0100 +++ b/src/examples/rot13/main.cpp Sat Mar 20 00:36:10 2010 +0100 @@ -1,9 +1,9 @@ +#include <sstream> #include <iostream> #include <vector> #include "Rot13Module.hpp" #include "Rot13Handler.hpp" -#include "Buffer.hpp" /** ** @brief Function that "emulates" the behavior of a server by instanciating a IModule @@ -49,8 +49,10 @@ int main(void) { - Buffer buffer1; - Buffer buffer2; + // Buffer buffer1; + // Buffer buffer2; + std::stringbuf buffer1; + std::stringbuf buffer2; std::ostream os(NULL); std::istream is(NULL);