// ********************************************************************** // // Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. // // This copy of Ice is licensed to you under the terms described in the // ICE_LICENSE file included in this distribution. // // ********************************************************************** #ifndef TEST_HELPER_H #define TEST_HELPER_H #include #include #include #include namespace Test { class MainHelper : public std::streambuf { public: MainHelper() { setp(&data[0], &data[sizeof(data) - 1]); } virtual void serverReady() = 0; virtual void shutdown() = 0; virtual void waitForCompleted() = 0; virtual bool redirect() = 0; virtual void print(const std::string& msg) = 0; virtual void flush() { } virtual void newLine() { print("\n"); } private: // // streambuf redirection implementation // int sync() { std::streamsize n = pptr() - pbase(); print(std::string(pbase(), static_cast(n))); pbump(-static_cast(pptr() - pbase())); return 0; } int overflow(int ch) { sync(); if(ch != EOF) { assert(pptr() != epptr()); sputc(ch); } return 0; } int sputc(char c) { if(c == '\n') { pubsync(); } return std::streambuf::sputc(c); } char data[1024]; }; } #endif