00001 /************************************************************************** 00002 * Version: Simplified BSD License 00003 * URL: http://www.opensource.org/licenses/bsd-license.php 00004 * 00005 * Copyright (c) 2010, Joseph LaFata 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions are met: 00010 * 00011 * - Redistributions of source code must retain the above copyright notice, 00012 * this list of conditions and the following disclaimer. 00013 * - Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in the 00015 * documentation and/or other materials provided with the distribution. 00016 * - Neither the name of cppbench nor the names of its contributors 00017 * may be used to endorse or promote products derived from this software 00018 * without specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00021 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00022 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00023 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00024 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00025 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00026 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00029 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00030 * POSSIBILITY OF SUCH DAMAGE. 00031 ***************************************************************************/ 00032 00033 #ifndef CONSOLEFORMATTER_HPP_ 00034 #define CONSOLEFORMATTER_HPP_ 00035 00036 #include "DllExport.h" 00037 #include "BenchFormatter.h" 00038 00039 #include <algorithm> 00040 #include <iostream> 00041 00042 class CPPBENCH_API ConsoleFormatter: public BenchFormatter 00043 { 00044 public: 00045 ConsoleFormatter() {}; 00046 virtual ~ConsoleFormatter() {}; 00047 00048 virtual void writeTitle(const std::vector<std::string>& titles, 00049 const std::vector<std::string>& values); 00050 00051 virtual void writeResult(const std::string& val, std::vector<BenchResult> results); 00052 00053 private: 00054 unsigned mFirstColumn; 00055 00056 #ifdef WIN32 00057 #pragma warning( push ) 00058 #pragma warning( disable : 4251 ) 00059 #endif 00060 00061 std::vector<unsigned> mColSize; 00062 00063 #ifdef WIN32 00064 #pragma warning( pop ) 00065 #endif 00066 }; 00067 00068 #endif /* CONSOLEFORMATTER_HPP_ */