struct settings_t ConfigReader::read_settings() {
	std::ifstream settings_file( "./config/config.ini" );

	if (!settings_file.is_open()) {
		throw GenericException("Cannot open config file");
	}

	po::options_description desc("Options");
	desc.add_options()
			("data.v_data_file", po::value<std::string>(), "V data file")
			("data.d_data_file", po::value<std::string>(), "D data file")
			("data.j_data_file", po::value<std::string>(), "J data file")
			("data.output_file", po::value<std::string>(), "output file");
	po::variables_map vm;
	po::store(po::parse_config_file(settings_file, desc, true), vm);
	settings_file.close();
	po::notify(vm);

	struct settings_t settings;
	settings.v_data_file = vm["data.v_data_file"].as<std::string>();
	settings.d_data_file = vm["data.d_data_file"].as<std::string>();
	settings.j_data_file = vm["data.j_data_file"].as<std::string>();
	settings.output_file = vm["data.output_file"].as<std::string>();

	return settings;
}
void read_settings(po::options_description& desc,
                   po::variables_map& vm)
{
  std::ifstream settings_file("settings.ini");

  // Clear the map.
  vm = po::variables_map();

  po::store(po::parse_config_file(settings_file , desc), vm);
  po::notify(vm);    
}
Exemple #3
0
void FileWriter::saveParameters(AbstractBenchmark *benchmark)
{
    std::ofstream file;
    std::vector<Parameter>::iterator p;


    file.open (benchmark->getDirectoryManager()->getFilename(benchmark->getName(), ".parameter.txt").c_str());
    
    file << benchmark->getCurrentVersion() << std::endl;
    file << std::endl << benchmark->getName() << std::endl;
    file << "################################" << std::endl;

    for (p = benchmark->getParameters()->begin(); p != benchmark->getParameters()->end(); p++)
    {

        if (p->getValues().size() == 1)
        {
            file << p->getName() << ": " << p->getValues().at(0) << std::endl;
        }
        else if (p->getValues().size() > 1)
        {
            file << p->getName() << ": from " << p->getValues().front() << " to " << p->getValues().back() << " in " << p->getValues().size() << " steps." << std::endl;
        }
    }
    
    char hostname[512];
    gethostname(hostname, 512);
    
    file << "Computer: " << hostname << std::endl;
    //file << "Executable: " << global_program_invocation_name << std::endl;  //ersetzten?
    
    // copy setting.conf
    file << "Settings: ";
    std::ifstream settings_file(STR(BENCHO_DIR)"/settings.conf");
    if (settings_file.is_open())
    {
        string settings_line;
        string settings_line_after;
        getline(settings_file, settings_line);
        while (settings_file.good())
        {
            getline(settings_file, settings_line_after);
            file << settings_line;
            if (!settings_line_after.empty()) file << ", ";
            settings_line = settings_line_after;
        }
        settings_file.close();
    }
    
    file << std::endl;
    file.close();

    std::cout << "Parameters written to " << benchmark->getDirectoryManager()->getFilename(benchmark->getName(), ".parameter.txt") << std::endl;
}
void write_settings(const char* value)
{
  std::ofstream settings_file("settings.ini");
  settings_file << "name = " << value;
}
Exemple #5
0
int main(int argc, char* argv[])
{
    try
    {
        if(argc == 1)
            throw ProcessCommandLineException("No arguments found. Use --help");

        if(!strcmp(argv[1], "--help"))
        {
            std::cout <<
                "usage: unilint <filename> "
                "[-s=<path_to_settings_file>] "
                "[-r=<path_to_results_file>] "
                "[-l=<language>]\n\n"
                "If -s and -r are not specified, "
                "default_settings.ini and results.txt are used.\n"
                "If -l is not specified, unilint tries to "
                "determine language by file extension.\n";
        }
        else
        {
            std::string file_to_process(argv[1]);
            std::string settings_file(DEFAULT_SETTINGS_FILE);
            std::string results_file(DEFAULT_RESULTS_FILE);
            std::string language("");
            for(int i = 2; argc > 2; --argc, ++i)
            {
                std::string argument(argv[i]);
                if(argument[0] != '-' || argument.size() <= 1)
                    throw ProcessCommandLineException("Unrecognized argument: " + argument);

                if(argument.size() <= 3 || argument[2] != '=')
                    throw ProcessCommandLineException("=<value> expected after " + argument.substr(0, 2));

                switch(argument[1])
                {
                    case 's':
                        settings_file = argument.substr(3);
                        break;
                    case 'r':
                        results_file = argument.substr(3);
                        break;
                    case 'l':
                        language = argument.substr(3);
                        break;
                    default:
                        throw ProcessCommandLineException("Unrecognized argument: " + argument.substr(0, 2));
                }
            }
            Checker checker(file_to_process, language, settings_file);
            checker.process_file();
            checker.output_results_to_file(results_file);
        }
    }
    catch(std::exception& e)
    {
        std::cerr << e.what() << std::endl;
    }

	return 0;
}
Exemple #6
0
 void saveSettings( std::string file )
 {
     scoped_lock< mutex > slock( settings_mutex );
     
     std::fstream settings_file( file.c_str(), std::fstream::out | std::fstream::trunc );
     
     if( !settings_file.is_open() )
     {
         exception e;
         ff::write( *e,
                    "saveSettings(): Could not open file \"",
                    file,
                    "\"" );
         throw e;
     }
     
     ff::write( bqt_out,
                "Saving settings to \"",
                file,
                "\"\n" );
     
     std::map< std::string, std::pair< double     , bool > >::iterator num_iter = settings_num.begin();
     std::map< std::string, std::pair< std::string, bool > >::iterator str_iter = settings_str.begin();
     std::map< std::string, std::pair< bool       , bool > >::iterator bln_iter = settings_bln.begin();
     
     for( int i = settings_num.size() + settings_str.size() + settings_bln.size();
          i > 0;
          --i )
     {                                                                       // We ensure we never have duplicate keys across the three containers, so
                                                                             // checking each key individually (instead of in a tree) should be safe.
         if( num_iter != settings_num.end()
             && num_iter -> first < str_iter -> first
             && num_iter -> first < bln_iter -> first )
         {
             if( num_iter -> second.second )
             {
                 settings_file << num_iter -> first
                               << ' '
                               << num_iter -> second.first
                               << '\n';
             }
             
             ++num_iter;
             
             continue;
         }
         
         if( str_iter != settings_str.end()
             && str_iter -> first < num_iter -> first
             && str_iter -> first < bln_iter -> first )
         {
             if( str_iter -> second.second )
             {
                 std::string& strval( str_iter -> second.first );
                 
                 settings_file << " \"";
                 
                 for( int i = 0; i < strval.size(); ++i )
                 {
                     if( strval[ i ] == '\\' )
                         settings_file << "\\\\";
                     else
                         settings_file << strval[ i ];
                 }
                 
                 settings_file << "\"\n";
             }
             
             ++str_iter;
             
             continue;
         }
         
         if( bln_iter != settings_bln.end()
             && bln_iter -> first < str_iter -> first
             && bln_iter -> first < num_iter -> first )
         {
             if( bln_iter -> second.second )
             {
                 settings_file << bln_iter -> first
                               << ' '
                               << bln_iter -> second.first
                               << '\n';
             }
             
             ++bln_iter;
             
             continue;
         }
         
         exception e;
         ff::write( *e,
                    "saveSettings(): Failed to save a setting to file \"",
                    file,
                    "\"" );
         throw e;                                                            // Skipped if one of the above conditions passes
     }
 }
void SetSettings(const s9x_settings &settings)
{
	BPath path;
	BMessage snes9x;
	if(find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK)
		path.SetTo(S9x_SETTINGSPATH);

	path.Append(S9x_SETTINGSFILENAME);
	
	BFile settings_file(path.Path(), B_READ_WRITE | B_CREATE_FILE);
	snes9x.Unflatten(&settings_file);
	
	// Sound
	SaveInt8(snes9x, "s9x_stereo", settings.sound.s9x_stereo);
	SaveInt8(snes9x, "s9x_mute", settings.sound.s9x_mute);	
	SaveInt8(snes9x, "s9x_SixteenBitSound", settings.sound.s9x_SixteenBitSound);
	SaveInt8(snes9x, "s9x_InterpolatedSound", settings.sound.s9x_InterpolatedSound);
	SaveInt8(snes9x, "s9x_SoundEnvelopeHeightReading", settings.sound.s9x_SoundEnvelopeHeightReading);
	SaveInt8(snes9x, "s9x_DisableSoundEcho", settings.sound.s9x_DisableSoundEcho);
	SaveInt8(snes9x, "s9x_DisableSampleCaching", settings.sound.s9x_DisableSampleCaching);
	SaveInt8(snes9x, "s9x_DisableMasterVolume", settings.sound.s9x_DisableMasterVolume);
	SaveInt8(snes9x, "s9x_ThreadSound", settings.sound.s9x_ThreadSound);
	SaveInt8(snes9x, "s9x_NextAPUEnabled", settings.sound.s9x_NextAPUEnabled);

	SaveInt8(snes9x, "s9x_ReverseStereo", settings.sound.s9x_ReverseStereo);
	SaveInt8(snes9x, "s9x_TraceSoundDSP", settings.sound.s9x_TraceSoundDSP);
	SaveInt8(snes9x, "s9x_SoundSync", settings.sound.s9x_SoundSync);
	SaveInt8(snes9x, "s9x_AltSampleDecode", settings.sound.s9x_AltSampleDecode);
	SaveInt8(snes9x, "s9x_FixFrequency", settings.sound.s9x_FixFrequency);				
	
	//s9x_ROM_image
	SaveInt8(snes9x, "s9x_ForceLoROM", settings.ROMImage.s9x_ForceLoROM);
    SaveInt8(snes9x, "s9x_ForceHiROM", settings.ROMImage.s9x_ForceHiROM);
    SaveInt8(snes9x, "s9x_ForceHeader", settings.ROMImage.s9x_ForceHeader);
    SaveInt8(snes9x, "s9x_ForceNoHeader", settings.ROMImage.s9x_ForceNoHeader);
    SaveInt8(snes9x, "s9x_ForceInterleaved", settings.ROMImage.s9x_ForceInterleaved);
    SaveInt8(snes9x, "s9x_ForceInterleaved2", settings.ROMImage.s9x_ForceInterleaved2);
    SaveInt8(snes9x, "s9x_ForceLoROM", settings.ROMImage.s9x_ForceNotInterleaved);

	//peripherial
	SaveInt8(snes9x, "s9x_ForceSuperFX", settings.peripherial.s9x_ForceSuperFX);
	SaveInt8(snes9x, "s9x_ForceNoSuperFX", settings.peripherial.s9x_ForceNoSuperFX);
	SaveInt8(snes9x, "s9x_ForceDSP1", settings.peripherial.s9x_ForceDSP1);
	SaveInt8(snes9x, "s9x_ForceNoDSP1", settings.peripherial.s9x_ForceNoDSP1);
	SaveInt8(snes9x, "s9x_ForceSA1", settings.peripherial.s9x_ForceSA1);
	SaveInt8(snes9x, "s9x_ForceNoSA1", settings.peripherial.s9x_ForceNoSA1);
	SaveInt8(snes9x, "s9x_ForceC4", settings.peripherial.s9x_ForceC4);
	SaveInt8(snes9x, "s9x_ForceNoC4", settings.peripherial.s9x_ForceNoC4);
	SaveInt8(snes9x, "s9x_ForceSDD1", settings.peripherial.s9x_ForceSDD1);
	SaveInt8(snes9x, "s9x_ForceNoSDD1", settings.peripherial.s9x_ForceNoSDD1);
	SaveInt8(snes9x, "s9x_MultiPlayer5", settings.peripherial.s9x_MultiPlayer5);
	SaveInt8(snes9x, "s9x_Mouse", settings.peripherial.s9x_Mouse);
	SaveInt8(snes9x, "s9x_SuperScope", settings.peripherial.s9x_SuperScope);
	SaveInt8(snes9x, "s9x_SRTC", settings.peripherial.s9x_ForceSuperFX);
	SaveInt8(snes9x, "s9x_ShutdownMaster", settings.peripherial.s9x_ShutdownMaster);
	SaveInt8(snes9x, "s9x_MultiPlayer5Master", settings.peripherial.s9x_MultiPlayer5Master);
	SaveInt8(snes9x, "s9x_SuperScopeMaster", settings.peripherial.s9x_SuperScopeMaster);
	SaveInt8(snes9x, "s9x_MouseMaster", settings.peripherial.s9x_MouseMaster);
	SaveInt8(snes9x, "s9x_SuperFX", settings.peripherial.s9x_SuperFX);
	SaveInt8(snes9x, "s9x_DSP1Master", settings.peripherial.s9x_DSP1Master);
	SaveInt8(snes9x, "s9x_SA1", settings.peripherial.s9x_SA1);
	SaveInt8(snes9x, "s9x_C4", settings.peripherial.s9x_C4);
	SaveInt8(snes9x, "s9x_SDD1", settings.peripherial.s9x_SDD1);
	SaveInt8(snes9x, "s9x_SPC7110", settings.peripherial.s9x_SPC7110);
	SaveInt8(snes9x, "s9x_SPC7110RTC", settings.peripherial.s9x_SPC7110RTC);
	SaveInt8(snes9x, "s9x_OBC1", settings.peripherial.s9x_OBC1);	
    SaveInt32(snes9x, "s9x_ControllerOption", settings.peripherial.s9x_ControllerOption);
	
	//s9x_Graphics
	SaveInt8(snes9x, "s9x_SixteenBit", settings.graphics.s9x_SixteenBit);
	SaveInt8(snes9x, "s9x_Transparency", settings.graphics.s9x_Transparency);
	SaveInt8(snes9x, "s9x_SupportHiRes", settings.graphics.s9x_SupportHiRes);
	SaveInt8(snes9x, "s9x_Mode7Interpolate", settings.graphics.s9x_SixteenBit);
	SaveInt8(snes9x, "s9x_BGLayering", settings.graphics.s9x_Mode7Interpolate);
	SaveInt8(snes9x, "s9x_DisableGraphicWindows", settings.graphics.s9x_DisableGraphicWindows);
	SaveInt8(snes9x, "s9x_ForceTransparency", settings.graphics.s9x_ForceTransparency);
	SaveInt8(snes9x, "s9x_ForceNoTransparency", settings.graphics.s9x_ForceNoTransparency);
	SaveInt8(snes9x, "s9x_DisableHDMA", settings.graphics.s9x_DisableHDMA);
	SaveInt8(snes9x, "s9x_DisplayFrameRate", settings.graphics.s9x_DisplayFrameRate);
	SaveInt8(snes9x, "s9x_DisableRangeTimeOver", settings.graphics.s9x_DisableRangeTimeOver);
		
	//s9x_Network
	SaveInt8(snes9x, "s9x_NetPlay", settings.network.s9x_NetPlay);
	SaveInt8(snes9x, "s9x_NetPlayServer", settings.network.s9x_NetPlayServer);
//	SaveString(snes9x, "s9x_ServerName", settings.network.s9x_ServerName);
	SaveInt32(snes9x, "s9x_Port", settings.network.s9x_Port);

	//s9x_Misc
	SaveInt8(snes9x, "s9x_GlideEnable", settings.misc.s9x_GlideEnable);
	SaveInt8(snes9x, "s9x_OpenGLEnable", settings.misc.s9x_OpenGLEnable);
	SaveInt8(snes9x, "s9x_ApplyCheats", settings.misc.s9x_ApplyCheats);
	SaveInt8(snes9x, "s9x_TurboMode", settings.misc.s9x_TurboMode);
	SaveInt32(snes9x, "s9x_TurboSkipFrames", settings.misc.s9x_TurboSkipFrames);
	SaveInt32(snes9x, "s9x_AutoMaxSkipFrames", settings.misc.s9x_AutoMaxSkipFrames);
	SaveInt8(snes9x, "s9x_AutoSaveDelay", settings.misc.s9x_AutoSaveDelay);
	
	//RecentRoms
//	SaveString(snes9x, "recentRom1", settings.recentroms.recentRom1);
//	SaveString(snes9x, "recentRom2", settings.recentroms.recentRom2);
//	SaveString(snes9x, "recentRom3", settings.recentroms.recentRom3);
//	SaveString(snes9x, "recentRom4", settings.recentroms.recentRom4);
//	SaveString(snes9x, "recentRom5", settings.recentroms.recentRom5);
	
	// Ui
	SaveInt8(snes9x, "s9x_mode", settings.ui.s9x_mode);
	SaveInt8(snes9x, "s9x_snooze", settings.ui.s9x_snooze);
	SaveInt8(snes9x, "s9x_inactive", settings.ui.s9x_inactive);
	SaveInt8(snes9x, "s9x_allow", settings.ui.s9x_allow);
	SaveInt8(snes9x, "s9x_menuactive", settings.ui.s9x_menuactive);
	SaveInt8(snes9x, "s9x_vsync", settings.ui.s9x_vsync);
	SaveInt8(snes9x, "s9x_extended", settings.ui.s9x_extended);
	SaveInt8(snes9x, "s9x_drawmode", settings.ui.s9x_drawmode);
	
	// Controller
	SaveInt8(snes9x, "s9x_SwapJoypads", settings.controll.s9x_SwapJoypads);
	SaveInt8(snes9x, "s9x_JoystickEnabled", settings.controll.s9x_JoystickEnabled);
	
	// Controller 1
	SaveInt32(snes9x, "k_up0", settings.controll.s9x_controller1.k_up);
	SaveInt32(snes9x, "k_down0", settings.controll.s9x_controller1.k_down);
	SaveInt32(snes9x, "k_left0", settings.controll.s9x_controller1.k_left);
	SaveInt32(snes9x, "k_right0", settings.controll.s9x_controller1.k_right);
	SaveInt32(snes9x, "k_a0", settings.controll.s9x_controller1.k_a);
	SaveInt32(snes9x, "k_b0", settings.controll.s9x_controller1.k_b);
	SaveInt32(snes9x, "k_x0", settings.controll.s9x_controller1.k_x);
	SaveInt32(snes9x, "k_y0", settings.controll.s9x_controller1.k_y);
	SaveInt32(snes9x, "k_l0", settings.controll.s9x_controller1.k_l);
	SaveInt32(snes9x, "k_r0", settings.controll.s9x_controller1.k_r);
	SaveInt32(snes9x, "k_start0", settings.controll.s9x_controller1.k_start);
	SaveInt32(snes9x, "k_select0", settings.controll.s9x_controller1.k_select);
	
	// Controller 2
	SaveInt32(snes9x, "k_up1", settings.controll.s9x_controller2.k_up);
	SaveInt32(snes9x, "k_down1", settings.controll.s9x_controller2.k_down);
	SaveInt32(snes9x, "k_left1", settings.controll.s9x_controller2.k_left);
	SaveInt32(snes9x, "k_right1", settings.controll.s9x_controller2.k_right);
	SaveInt32(snes9x, "k_a1", settings.controll.s9x_controller2.k_a);
	SaveInt32(snes9x, "k_b1", settings.controll.s9x_controller2.k_b);
	SaveInt32(snes9x, "k_x1", settings.controll.s9x_controller2.k_x);
	SaveInt32(snes9x, "k_y1", settings.controll.s9x_controller2.k_y);
	SaveInt32(snes9x, "k_l1", settings.controll.s9x_controller2.k_l);
	SaveInt32(snes9x, "k_r1", settings.controll.s9x_controller2.k_r);
	SaveInt32(snes9x, "k_start1", settings.controll.s9x_controller2.k_start);
	SaveInt32(snes9x, "k_select1", settings.controll.s9x_controller2.k_select);
	
	// Controller 3
	SaveInt32(snes9x, "k_up2", settings.controll.s9x_controller3.k_up);
	SaveInt32(snes9x, "k_down2", settings.controll.s9x_controller3.k_down);
	SaveInt32(snes9x, "k_left2", settings.controll.s9x_controller3.k_left);
	SaveInt32(snes9x, "k_right2", settings.controll.s9x_controller3.k_right);
	SaveInt32(snes9x, "k_a2", settings.controll.s9x_controller3.k_a);
	SaveInt32(snes9x, "k_b2", settings.controll.s9x_controller3.k_b);
	SaveInt32(snes9x, "k_x2", settings.controll.s9x_controller3.k_x);
	SaveInt32(snes9x, "k_y2", settings.controll.s9x_controller3.k_y);
	SaveInt32(snes9x, "k_l2", settings.controll.s9x_controller3.k_l);
	SaveInt32(snes9x, "k_r2", settings.controll.s9x_controller3.k_r);
	SaveInt32(snes9x, "k_start2", settings.controll.s9x_controller3.k_start);
	SaveInt32(snes9x, "k_select2", settings.controll.s9x_controller3.k_select);
	
	// Controller 4
	SaveInt32(snes9x, "k_up3", settings.controll.s9x_controller4.k_up);
	SaveInt32(snes9x, "k_down3", settings.controll.s9x_controller4.k_down);
	SaveInt32(snes9x, "k_left3", settings.controll.s9x_controller4.k_left);
	SaveInt32(snes9x, "k_right3", settings.controll.s9x_controller4.k_right);
	SaveInt32(snes9x, "k_a3", settings.controll.s9x_controller4.k_a);
	SaveInt32(snes9x, "k_b3", settings.controll.s9x_controller4.k_b);
	SaveInt32(snes9x, "k_x3", settings.controll.s9x_controller4.k_x);
	SaveInt32(snes9x, "k_y3", settings.controll.s9x_controller4.k_y);
	SaveInt32(snes9x, "k_l3", settings.controll.s9x_controller4.k_l);
	SaveInt32(snes9x, "k_r3", settings.controll.s9x_controller4.k_r);
	SaveInt32(snes9x, "k_start3", settings.controll.s9x_controller4.k_start);
	SaveInt32(snes9x, "k_select3", settings.controll.s9x_controller4.k_select);
	
	// Controller 5
	SaveInt32(snes9x, "k_up4", settings.controll.s9x_controller5.k_up);
	SaveInt32(snes9x, "k_down4", settings.controll.s9x_controller5.k_down);
	SaveInt32(snes9x, "k_left4", settings.controll.s9x_controller5.k_left);
	SaveInt32(snes9x, "k_right4", settings.controll.s9x_controller5.k_right);
	SaveInt32(snes9x, "k_a4", settings.controll.s9x_controller5.k_a);
	SaveInt32(snes9x, "k_b4", settings.controll.s9x_controller5.k_b);
	SaveInt32(snes9x, "k_x4", settings.controll.s9x_controller5.k_x);
	SaveInt32(snes9x, "k_y4", settings.controll.s9x_controller5.k_y);
	SaveInt32(snes9x, "k_l4", settings.controll.s9x_controller5.k_l);
	SaveInt32(snes9x, "k_r4", settings.controll.s9x_controller5.k_r);
	SaveInt32(snes9x, "k_start4", settings.controll.s9x_controller5.k_start);
	SaveInt32(snes9x, "k_select4", settings.controll.s9x_controller5.k_select);
	
	settings_file.SetSize(0);
	settings_file.Seek(0, SEEK_SET);
	snes9x.Flatten(&settings_file);
}
Exemple #8
0
//Writes the settings to file
void menu::write_settings(){
  std::ofstream settings_file("data/settings.dat");
  for (int i = 0; i < 7; i++)
    settings_file << settings[i] << " ";
  settings_file.close();
}