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 CSVFORMATTER_H_ 00034 #define CSVFORMATTER_H_ 00035 00036 #include "DllExport.h" 00037 #include "BenchFormatter.h" 00038 00039 #include <fstream> 00040 #include <vector> 00041 #include <string> 00042 00043 class CPPBENCH_API CsvFormatter: public BenchFormatter 00044 { 00045 public: 00046 CsvFormatter(std::string out = "stats.csv") : 00047 mOutfile(out.c_str()) { }; 00048 virtual ~CsvFormatter() {}; 00049 00050 virtual void writeTitle(const std::vector<std::string>& titles, 00051 const std::vector<std::string>& values); 00052 00053 virtual void writeResult(const std::string& val, std::vector<BenchResult> results); 00054 00055 virtual void finish(); 00056 00057 private: 00058 00059 #ifdef WIN32 00060 #pragma warning( push ) 00061 #pragma warning( disable : 4251 ) 00062 #endif 00063 00064 std::ofstream mOutfile; 00065 00066 #ifdef WIN32 00067 #pragma warning( pop ) 00068 #endif 00069 }; 00070 00071 #endif