Example #1
0
int main(int argc, char** argv)
{
	try
	{
		// store required reports in vector
		std::vector<Report*> reports;

		// put build array out of command line args and process
		{
			std::vector<std::string> argVector(argv+1, argv + argc);
			if (argVector.empty())
			{
				throw std::runtime_error("invalide number of arguements (" + boost::lexical_cast<std::string>(argVector.size()) + ")\n");
			}
			CommandLine::ParseCommandLineInstructions(argVector, reports);
		}

		// read data file into store
		ReadInputFile(inputDataFile);

		// run reports
		std::string output;
		for (auto report : reports)
		{
			output += report->Generate() + "\n";
		}
		// output to standard out and file
		std::cout << output; 
		std::ofstream output_file(outputDataFile);
		std::ostream_iterator<char> output_iterator(output_file);
		std::copy(output.begin(), output.end(), output_iterator);
		output_file.close();	
    }
	catch (std::logic_error& ex)
	{
		std::cerr << "A systematic error has occured: " << ex.what() << "\nExiting...\n" << std::endl;
	}
	catch (std::runtime_error& ex)
	{
		std::cerr << "A runtime error has occured: " << ex.what() << "\nExiting...\n" << std::endl;
	}
	catch (std::exception& ex)
	{
		std::cerr << "A unexpected error has occured: " << ex.what() << "\nExiting...\n" << std::endl;
	}
	catch (...)
	{
		std::cerr << "An unexpected error occured: Exiting...\n" << std::endl;
	}

	return 0;
}
Example #2
0
void CRegameDLLRuntimeConfig::parseFromConfigFile()
{
#ifdef _WIN32

    if (strlen(testConfigFileName) <= 0)
        return;

    std::string str;
    std::string path( bIsZero ? "./czero/server.cfg" : "./cstrike/server.cfg" );
    std::string pattern = "exec tests/";

    std::ifstream intput_file( path );
    std::vector< std::string > out;

    bool bFound = false;
    while (std::getline(intput_file, str))
    {
        if (str.find( pattern ) != -1)
        {
            bFound = true;

            std::ostringstream stringStream;
            stringStream << pattern << testConfigFileName;
            str = stringStream.str();
        }

        out.push_back( str.c_str() );
    }

    if (!bFound)
    {
        std::ostringstream stringStream;
        stringStream << "\n" << pattern << testConfigFileName;

        out.push_back( stringStream.str() );
    }

    intput_file.close();

    std::ofstream output_file( path );
    std::ostream_iterator< std::string > output_iterator(output_file, "\n");
    std::copy(out.begin(), out.end(), output_iterator);

    out.clear();
    output_file.close();

#endif // _WIN32
}