当前位置: 首页>>代码示例>>C++>>正文


C++ ConfigFile类代码示例

本文整理汇总了C++中ConfigFile的典型用法代码示例。如果您正苦于以下问题:C++ ConfigFile类的具体用法?C++ ConfigFile怎么用?C++ ConfigFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ConfigFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Get

	void Get(ConfigFile& conf) {
		switch(type)
		{
			case CIT_BOOL:
			case CIT_BOOLONOFF:
				if(size	== 1) *(uint8 *)addr = (uint8) conf.GetBool(name, def!=0);
				if(size	== 2) *(uint16*)addr = (uint16)conf.GetBool(name, def!=0);
				if(size	== 4) *(uint32*)addr = (uint32)conf.GetBool(name, def!=0);
				if(size	== 8) *(uint64*)addr = (uint64)conf.GetBool(name, def!=0);
				break;
			case CIT_INT:
				if(size	== 1) *(uint8 *)addr = (uint8) conf.GetInt(name, reinterpret_cast<int32>(def));
				if(size	== 2) *(uint16*)addr = (uint16)conf.GetInt(name, reinterpret_cast<int32>(def));
				if(size	== 4) *(uint32*)addr = (uint32)conf.GetInt(name, reinterpret_cast<int32>(def));
				if(size	== 8) *(uint64*)addr = (uint64)conf.GetInt(name, reinterpret_cast<int32>(def));
				break;
			case CIT_UINT:
				if(size	== 1) *(uint8 *)addr = (uint8) conf.GetUInt(name, reinterpret_cast<uint32>(def));
				if(size	== 2) *(uint16*)addr = (uint16)conf.GetUInt(name, reinterpret_cast<uint32>(def));
				if(size	== 4) *(uint32*)addr = (uint32)conf.GetUInt(name, reinterpret_cast<uint32>(def));
				if(size	== 8) *(uint64*)addr = (uint64)conf.GetUInt(name, reinterpret_cast<uint32>(def));
				break;
			case CIT_STRING:
				lstrcpyn((TCHAR*)addr, _tFromChar(conf.GetString(name, reinterpret_cast<const char*>(def))), size-1);
				((TCHAR*)addr)[size-1] = TEXT('\0');
				break;
			case CIT_INVBOOL:
			case CIT_INVBOOLONOFF:
				if(size	== 1) *(uint8 *)addr = (uint8) !conf.GetBool(name, def!=0);
				if(size	== 2) *(uint16*)addr = (uint16)!conf.GetBool(name, def!=0);
				if(size	== 4) *(uint32*)addr = (uint32)!conf.GetBool(name, def!=0);
				if(size	== 8) *(uint64*)addr = (uint64)!conf.GetBool(name, def!=0);
				break;
			case CIT_VKEY:
				{
					uint16 keyNum = (uint16)conf.GetUInt(name, reinterpret_cast<uint32>(def));
					const char* keyStr = conf.GetString(name);
					if(keyStr)
					{
						for(int i=0;i<512;i++)
						{
							if(i<256) // keys
							{
								if(!strcasecmp(keyStr,keyToString[i]) ||
								(*keyToAlternateString[i] && !strcasecmp(keyStr,keyToAlternateString[i])))
								{
									keyNum = i;
									break;
								}
							}
							else // joystick:
							{
								char temp [128];
								extern void TranslateKey(WORD keyz,char *out);
								TranslateKey(0x8000|(i-256),temp);
								if(strlen(keyStr)>3 && !strcasecmp(keyStr+3,temp+3))
								{
									for(int j = 0 ; j < 16 ; j++)
									{
										if(keyStr[2]-'0' == j || keyStr[2]-'a' == j-10)
										{
											keyNum = 0x8000|(i-256)|(j<<8);
											i = 512;
											break;
										}
									}
								}
							}
						}
					}
					if(size	== 1) *(uint8 *)addr = (uint8) keyNum;
					if(size	== 2) *(uint16*)addr = (uint16)keyNum;
					if(size	== 4) *(uint32*)addr = (uint32)keyNum;
					if(size	== 8) *(uint64*)addr = (uint64)keyNum;
				}
				break;
			case CIT_VKEYMOD:
				{
					uint16 modNum = 0;
					const char* modStr = conf.GetString(name);
					if(modStr) {
						if(strstr(modStr, "ft") || strstr(modStr, "FT")) modNum |= CUSTKEY_SHIFT_MASK;
						if(strstr(modStr, "tr") || strstr(modStr, "TR")) modNum |= CUSTKEY_CTRL_MASK;
						if(strstr(modStr, "lt") || strstr(modStr, "LT")) modNum |= CUSTKEY_ALT_MASK;
					}
					if(!modNum && (!modStr || strcasecmp(modStr, "none")))
						modNum = conf.GetUInt(name, reinterpret_cast<uint32>(def));
					if(size	== 1) *(uint8 *)addr = (uint8) modNum;
					if(size	== 2) *(uint16*)addr = (uint16)modNum;
					if(size	== 4) *(uint32*)addr = (uint32)modNum;
					if(size	== 8) *(uint64*)addr = (uint64)modNum;
				}
				break;
		}

		// if it had a comment, override our own with it
		const char* newComment = conf.GetComment(name);
		if(newComment && *newComment)
			comment = newComment;
	}
开发者ID:ddugovic,项目名称:RASuite,代码行数:100,代码来源:wconfig.cpp

示例2: AddProfile

bool OBSBasic::AddProfile(bool create_new, const char *title, const char *text,
		const char *init_text)
{
	std::string newName;
	std::string newDir;
	ConfigFile config;

	if (!GetProfileName(this, newName, newDir, title, text, init_text))
		return false;

	std::string curDir = config_get_string(App()->GlobalConfig(),
			"Basic", "ProfileDir");

	char newPath[512];
	int ret = GetConfigPath(newPath, 512, "obs-studio/basic/profiles/");
	if (ret <= 0) {
		blog(LOG_WARNING, "Failed to get profiles config path");
		return false;
	}

	strcat(newPath, newDir.c_str());

	if (os_mkdir(newPath) < 0) {
		blog(LOG_WARNING, "Failed to create profile directory '%s'",
				newDir.c_str());
		return false;
	}

	if (!create_new)
		CopyProfile(curDir.c_str(), newPath);

	strcat(newPath, "/basic.ini");

	if (config.Open(newPath, CONFIG_OPEN_ALWAYS) != 0) {
		blog(LOG_ERROR, "Failed to open new config file '%s'",
				newDir.c_str());
		return false;
	}

	config_set_string(App()->GlobalConfig(), "Basic", "Profile",
			newName.c_str());
	config_set_string(App()->GlobalConfig(), "Basic", "ProfileDir",
			newDir.c_str());

	config_set_string(config, "General", "Name", newName.c_str());
	config.SaveSafe("tmp");
	config.Swap(basicConfig);
	InitBasicConfigDefaults();
	RefreshProfiles();

	if (create_new)
		ResetProfileData();

	blog(LOG_INFO, "Created profile '%s' (%s, %s)", newName.c_str(),
			create_new ? "clean" : "duplicate", newDir.c_str());
	blog(LOG_INFO, "------------------------------------------------");

	config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
	UpdateTitleBar();
	return true;
}
开发者ID:AhmedAbdulSalam5,项目名称:obs-studio,代码行数:61,代码来源:window-basic-main-profiles.cpp

示例3: S9xLoadConfigFiles

void S9xLoadConfigFiles (char **argv, int argc)
{
	static ConfigFile	conf; // static because some of its functions return pointers
	conf.Clear();

	bool	skip = false;
	for (int i = 0; i < argc; i++)
	{
		if (!strcasecmp(argv[i], "-nostdconf"))
		{
			skip = true;
			break;
		}
	}

	if (!skip)
	{
	#ifdef SYS_CONFIG_FILE
		try_load_config_file(SYS_CONFIG_FILE, conf);
		S9xParsePortConfig(conf, 0);
	#endif

		std::string	fname;

		fname = S9xGetDirectory(DEFAULT_DIR);
		fname += SLASH_STR S9X_CONF_FILE_NAME;
		try_load_config_file(fname.c_str(), conf);
	}
	else
		fprintf(stderr, "Skipping standard config files.\n");

	for (int i = 0; i < argc - 1; i++)
		if (!strcasecmp(argv[i], "-conf"))
			try_load_config_file(argv[++i], conf);

	// Parse config file here

	// ROM

	Settings.ForceInterleaved2          =  conf.GetBool("ROM::Interleaved2",                   false);
	Settings.ForceInterleaveGD24        =  conf.GetBool("ROM::InterleaveGD24",                 false);
	Settings.ApplyCheats                =  conf.GetBool("ROM::Cheat",                          false);
	Settings.NoPatch                    = !conf.GetBool("ROM::Patch",                          true);

	Settings.ForceLoROM = conf.GetBool("ROM::LoROM", false);
	Settings.ForceHiROM = conf.GetBool("ROM::HiROM", false);
	if (Settings.ForceLoROM)
		Settings.ForceHiROM = false;

	Settings.ForcePAL   = conf.GetBool("ROM::PAL",  false);
	Settings.ForceNTSC  = conf.GetBool("ROM::NTSC", false);
	if (Settings.ForcePAL)
		Settings.ForceNTSC = false;

	if (conf.Exists("ROM::Header"))
	{
		Settings.ForceHeader = conf.GetBool("ROM::Header", false);
		Settings.ForceNoHeader = !Settings.ForceHeader;
	}

	if (conf.Exists("ROM::Interleaved"))
	{
		Settings.ForceInterleaved = conf.GetBool("ROM::Interleaved", false);
		Settings.ForceNotInterleaved = !Settings.ForceInterleaved;
	}

	rom_filename = conf.GetStringDup("ROM::Filename", NULL);

	// Sound

	Settings.SoundSync                  =  conf.GetBool("Sound::Sync",                         true);
	Settings.SixteenBitSound            =  conf.GetBool("Sound::16BitSound",                   true);
	Settings.Stereo                     =  conf.GetBool("Sound::Stereo",                       true);
	Settings.ReverseStereo              =  conf.GetBool("Sound::ReverseStereo",                false);
	Settings.SoundPlaybackRate          =  conf.GetUInt("Sound::Rate",                         32000);
	Settings.SoundInputRate             =  conf.GetUInt("Sound::InputRate",                    32000);
	Settings.Mute                       =  conf.GetBool("Sound::Mute",                         false);

	// Display

	Settings.SupportHiRes               =  conf.GetBool("Display::HiRes",                      true);
	Settings.Transparency               =  conf.GetBool("Display::Transparency",               true);
	Settings.DisableGraphicWindows      = !conf.GetBool("Display::GraphicWindows",             true);
	Settings.DisplayFrameRate           =  conf.GetBool("Display::DisplayFrameRate",           false);
	Settings.DisplayWatchedAddresses    =  conf.GetBool("Display::DisplayWatchedAddresses",    false);
	Settings.DisplayPressedKeys         =  conf.GetBool("Display::DisplayInput",               false);
	Settings.DisplayMovieFrame          =  conf.GetBool("Display::DisplayFrameCount",          false);
	Settings.AutoDisplayMessages        =  conf.GetBool("Display::MessagesInImage",            true);
	Settings.InitialInfoStringTimeout   =  conf.GetInt ("Display::MessageDisplayTime",         120);

	// Settings

	Settings.BSXBootup                  =  conf.GetBool("Settings::BSXBootup",                 false);
	Settings.TurboMode                  =  conf.GetBool("Settings::TurboMode",                 false);
	Settings.TurboSkipFrames            =  conf.GetUInt("Settings::TurboFrameSkip",            15);
	Settings.MovieTruncate              =  conf.GetBool("Settings::MovieTruncateAtEnd",        false);
	Settings.MovieNotifyIgnored         =  conf.GetBool("Settings::MovieNotifyIgnored",        false);
	Settings.WrongMovieStateProtection  =  conf.GetBool("Settings::WrongMovieStateProtection", true);
	Settings.StretchScreenshots         =  conf.GetInt ("Settings::StretchScreenshots",        1);
	Settings.SnapshotScreenshots        =  conf.GetBool("Settings::SnapshotScreenshots",       true);
//.........这里部分代码省略.........
开发者ID:7sevenx7,项目名称:snes9x,代码行数:101,代码来源:snes9x.cpp

示例4: clearKeyMapping

void EventReceiver::loadKeyMapping()
{
    // Load resource paths from config file
    clearKeyMapping();

    ConfigFile cf;
    cf.load(keyMappingFilename);

    dprintf(MY_DEBUG_NOTE, "Read keymapping file:\n");
    // Go through all sections & settings in the file
    ConfigFile::SectionIterator seci = cf.getSectionIterator();

    std::string secName, keyName, valueName;
    while (seci.hasMoreElements())
    {
        bool primary = false;
        bool secondary = false;
        unsigned int p_type = 0;
        unsigned int p_key = (unsigned int)-1;
        unsigned int p_key2 = (unsigned int)-1;
        int p_from = 0;
        int p_to = 0;
        unsigned int s_type = 0;
        unsigned int s_key = (unsigned int)-1;
        unsigned int s_key2 = (unsigned int)-1;
        int s_from = 0;
        int s_to = 0;

        secName = seci.peekNextKey();
        dprintf(MY_DEBUG_NOTE, "\tKey: %s\n", secName.c_str());
        ConfigFile::SettingsMultiMap *settings = seci.getNext();
        for (ConfigFile::SettingsMultiMap::iterator i = settings->begin(); i != settings->end(); ++i)
        {
            keyName = i->first;
            valueName = i->second;

            if (keyName == "primary_type")
            {
                primary = true;
                p_type = StringConverter::parseUnsignedInt(valueName, 0);
            } else
            if (keyName == "secondary_type")
            {
                secondary = true;
                s_type = StringConverter::parseUnsignedInt(valueName, 0);
            } else
            if (keyName == "primary_key")
            {
                primary = true;
                p_key = StringConverter::parseUnsignedInt(valueName, (unsigned int)-1);
            } else
            if (keyName == "secondary_key")
            {
                secondary = true;
                s_key = StringConverter::parseUnsignedInt(valueName, (unsigned int)-1);
            } else
            if (keyName == "primary_key2")
            {
                primary = true;
                p_key2 = StringConverter::parseUnsignedInt(valueName, (unsigned int)-1);
            } else
            if (keyName == "secondary_key2")
            {
                secondary = true;
                s_key2 = StringConverter::parseUnsignedInt(valueName, (unsigned int)-1);
            } else
            if (keyName == "primary_from")
            {
                primary = true;
                p_from = StringConverter::parseInt(valueName, 0);
            } else
            if (keyName == "secondary_from")
            {
                secondary = true;
                s_from = StringConverter::parseInt(valueName, 0);
            } else
            if (keyName == "primary_to")
            {
                primary = true;
                p_to = StringConverter::parseInt(valueName, 0);
            } else
            if (keyName == "secondary_to")
            {
                secondary = true;
                s_to = StringConverter::parseInt(valueName, 0);
            }
        }
        keyNameMap_t::iterator kit = keyNameMap.find(secName);
        if (kit != keyNameMap.end())
        {
            KeyName kn = kit->second;
            assert(kn < NUMBER_OF_KEYNAMES);
            if (primary)
            {
                keyMap[kn].primaryKeyConfig = KeyConfig::getKeyConfig((KeyConfig::type_t)p_type, p_key, p_key2, p_from, p_to, keyMap[kn].continous);
            }
            if (secondary)
            {
                keyMap[kn].secondaryKeyConfig = KeyConfig::getKeyConfig((KeyConfig::type_t)s_type, s_key, s_key2, s_from, s_to, keyMap[kn].continous);
            }
//.........这里部分代码省略.........
开发者ID:Berkananna,项目名称:rallyraid,代码行数:101,代码来源:EventReceiver.cpp

示例5: main

int main(int argc, char **argv) try
{
    ConfigFile params;
    if (BasicSetup(argc,argv,params,"findstars")) return EXIT_FAILURE;

    // Setup Log
    std::string logFile = ""; // Default is to stdout
    if (params.keyExists("log_file") || params.keyExists("log_ext"))
        logFile = MakeName(params,"log",false,false);
    std::string starsFile=MakeName(params,"stars",false,false);
    std::auto_ptr<FindStarsLog> log(
        new FindStarsLog(params,logFile,starsFile));

    try {
        bool timing = params.read("timing",false);
        timeval tp;
        double t1=0.,t2=0.;

        if (timing) {
            gettimeofday(&tp,0);
            t1 = tp.tv_sec + tp.tv_usec/1.e6;
        }

        // Read image, transformation
        std::auto_ptr<Image<double> > weight_image;
        Image<double> im(params,weight_image);

        if (timing) {
            gettimeofday(&tp,0);
            t2 = tp.tv_sec + tp.tv_usec/1.e6;
            std::cout<<"Time: Open imgae = "<<t2-t1<<std::endl;
            t1 = t2;
        }

        // Read distortion function
        Transformation trans(params);

        if (timing) {
            gettimeofday(&tp,0);
            t2 = tp.tv_sec + tp.tv_usec/1.e6;
            std::cout<<"Time: Read Transformation = "<<t2-t1<<std::endl;
            t1 = t2;
        }

        // Read input catalog
        InputCatalog incat(params,&im);
        incat.read();

        if (timing) {
            gettimeofday(&tp,0);
            t2 = tp.tv_sec + tp.tv_usec/1.e6;
            std::cout<<"Time: Read InputCatalog = "<<t2-t1<<std::endl;
            t1 = t2;
        }

        std::auto_ptr<StarCatalog> starcat;
        DoFindStars(params,*log,im,weight_image.get(),trans,incat,starcat);
    }
#if 0
    // Change to 1 to let gdb see where the program bombed out.
    catch(int) {}
#else
    CATCHALL;
#endif

    if (dbgout && dbgout != &std::cout) {
        delete dbgout;
        dbgout=0;
    }
    return EXIT_SUCCESS;
} catch (std::exception& e) {
    std::cerr<<"Fatal error: Caught \n"<<e.what()<<std::endl;
    std::cout<<"STATUS5BEG Fatal error: "<<e.what()<<" STATUS5END\n";
    return EXIT_FAILURE;
} catch (...) {
    std::cerr<<"Fatal error: Cought an exception.\n";
    std::cout<<"STATUS5BEG Fatal error: unknown exception STATUS5END\n";
    return EXIT_FAILURE;
}
开发者ID:rmjarvis,项目名称:deswl_shapelets,代码行数:79,代码来源:FindStars.cpp

示例6: s2e

bool Annotation::initSection(const std::string &entry, const std::string &cfgname)
{
    AnnotationCfgEntry e, *ne;

    ConfigFile *cfg = s2e()->getConfig();
    llvm::raw_ostream &os  = s2e()->getWarningsStream();
    std::vector<std::string> cfgkeys = s2e()->getConfig()->getListKeys(entry);

    e.cfgname = cfgname;

    bool ok;


    e.isActive = cfg->getBool(entry + ".active", false, &ok);
    if (!ok) {
        os << "You must specify whether the entry is active in " << entry << ".active!" << '\n';
        return false;
    }

    e.module = cfg->getString(entry + ".module", "", &ok);
    if (!ok) {
        os << "You must specify a valid module for " << entry << ".module!" << '\n';
        return false;
    }else {
        if (!m_moduleExecutionDetector->isModuleConfigured(e.module)) {
            os << "The module " << e.module << " is not configured in ModuleExecutionDetector!" << '\n';
            return false;
        }
    }


    e.address = cfg->getInt(entry + ".address", 0, &ok);
    if (!ok) {
        os << "You must specify a valid address for " << entry << ".address!" << '\n';
        return false;
    }

    if (!m_functionMonitor || !m_moduleExecutionDetector || !m_osMonitor) {
        os << "You must enable FunctionMonitor, ModuleExecutionDetector, and an OS monitor plugin\n";
        return false;
    }

    // Check if this is a call or an instruction annotation
    e.annotation = "";
    if (std::find(cfgkeys.begin(), cfgkeys.end(), "callAnnotation") != cfgkeys.end())	{
        e.annotation = cfg->getString(entry + ".callAnnotation", e.annotation, &ok);
        e.isCallAnnotation = true;
    } else if (std::find(cfgkeys.begin(), cfgkeys.end(), "instructionAnnotation") != cfgkeys.end())	{
        e.annotation = cfg->getString(entry + ".instructionAnnotation", e.annotation, &ok);
        e.isCallAnnotation = false;
    }

    // Assert that this is a properly attached annotation
    if (!ok || e.annotation=="") {
        os << "You must specify either " << entry << ".callAnnotation or .instructionAnnotation!" << '\n';
        return false;
    }

    // Get additional annotation-specific options
    e.paramCount = 0;
    e.beforeInstruction = false;
    e.switchInstructionToSymbolic = false;
    if (e.isCallAnnotation) {
        // Get the number of arguments of the annotated subroutine
        e.paramCount = cfg->getInt(entry + ".paramcount", e.paramCount, &ok);
        if (!ok) {
            os << "You must specify a valid number of function parameters for " << entry << ".paramcount!" << '\n';
            return false;
        }
    } else {
        // Whether to call the annotation before or after the instruction
        e.beforeInstruction = cfg->getBool(entry + ".beforeInstruction", e.beforeInstruction, &ok);
        e.switchInstructionToSymbolic = cfg->getBool(entry + ".switchInstructionToSymbolic", e.switchInstructionToSymbolic, &ok);
    }

    ne = new AnnotationCfgEntry(e);
    m_entries.insert(ne);

    return true;
}
开发者ID:0bliv10n,项目名称:s2e,代码行数:80,代码来源:Annotation.cpp

示例7: DoMeasurePsf

void DoMeasurePsf(
    ConfigFile& params, PsfLog& log,
    const Image<double>& im, const Image<double>* weight_image,
    const Transformation& trans, 
    const StarCatalog& starcat,
    std::auto_ptr<PsfCatalog>& psfcat, std::auto_ptr<FittedPsf>& fitpsf,
    double& sigma_p)
{
    dbg<<"Starting MeasurePsf script\n";

    bool isTiming = params.read("timing",false);
    timeval tp;
    double t1=0.,t2=0.;

    if (isTiming) {
        gettimeofday(&tp,0);
        t1 = tp.tv_sec + tp.tv_usec/1.e6;
    }

    if (params.read("psf_skip_measurements",false)) {
        // Option to read existing PsfCatalog rather than remeasure.
        // (Useful if you only want to redo the fitting step.)
        psfcat.reset(new PsfCatalog(params));
        psfcat->read();

        if (isTiming) {
            gettimeofday(&tp,0);
            t2 = tp.tv_sec + tp.tv_usec/1.e6;
            std::cout<<"Time: Read PSFCatalog = "<<t2-t1<<std::endl;
            t1 = t2;
        }
    } else {
        // Create PsfCatalog from StarCatalog
        psfcat.reset(new PsfCatalog(starcat,params));

        if (isTiming) {
            gettimeofday(&tp,0);
            t2 = tp.tv_sec + tp.tv_usec/1.e6;
            std::cout<<"Time: Create PSFCatalog = "<<t2-t1<<std::endl;
            t1 = t2;
        }

        // Estimate the scale size to use for shapelet decompositions
        if (sigma_p == 0.)
            sigma_p = psfcat->estimateSigma(im,weight_image,trans);

        if (isTiming) {
            gettimeofday(&tp,0);
            t2 = tp.tv_sec + tp.tv_usec/1.e6;
            std::cout<<"Time: Estimate Sigma = "<<t2-t1<<std::endl;
            t1 = t2;
        }

        // Do the actual PSF measurements
        int npsf = psfcat->measurePsf(im,weight_image,trans,sigma_p,log);

        if (isTiming) {
            gettimeofday(&tp,0);
            t2 = tp.tv_sec + tp.tv_usec/1.e6;
            std::cout<<"Time: Measure PSF = "<<t2-t1<<std::endl;
            t1 = t2;
        }

        // Write PSF catalog to file
        psfcat->write();

        if (isTiming) {
            gettimeofday(&tp,0);
            t2 = tp.tv_sec + tp.tv_usec/1.e6;
            std::cout<<"Time: Write PSFCatalog = "<<t2-t1<<std::endl;
            t1 = t2;
        }

        if (npsf == 0) {
            throw ProcessingException(
                "No successful PSF measurements");
        }
    }


    // Fit the PSF with a polynomial:
    fitpsf.reset(new FittedPsf(*psfcat,params,log));

    if (isTiming) {
        gettimeofday(&tp,0);
        t2 = tp.tv_sec + tp.tv_usec/1.e6;
        std::cout<<"Time: Fit PSF = "<<t2-t1<<std::endl;
        t1 = t2;
    }

    // Write fitted psf to file
    fitpsf->write();

    // Re-write the PSF catalog, since the interpolation may have changed
    // the flags.
    // TODO: It may be worth having a new routine that just updates the 
    // flags.  More efficient, since don't need to re-write everything.
    psfcat->write();

    if (isTiming) {
//.........这里部分代码省略.........
开发者ID:rmjarvis,项目名称:deswl_shapelets,代码行数:101,代码来源:Scripts.cpp

示例8: log

ObeyGameManager::ObeyGameManager(ConfigFile & configFile, Log & _log)
  : INITIAL_CHEST_COLOR  (configFile.getInt("rules/initialChestColor",   0x000000)),
    READY_CHEST_COLOR    (configFile.getInt("rules/readyChestColor",     0x0000FF)),
    SET_CHEST_COLOR      (configFile.getInt("rules/setChestColor",       0xFFFF00)),
    PLAYING_CHEST_COLOR  (configFile.getInt("rules/playingChestColor",   0x00FF00)),
    FINISHED_CHEST_COLOR (configFile.getInt("rules/finishedChestColor",  0x000000)),
    PENALIZED_CHEST_COLOR(configFile.getInt("rules/penalisedChestColor", 0xFF0000)),
    BLUE_TEAM_FOOT_COLOR (configFile.getInt("rules/blueTeamFootColor",   0x0000FF)),
    RED_TEAM_FOOT_COLOR  (configFile.getInt("rules/redTeamFootColor",    0xFF0000)),
    KICKOFF_FOOT_COLOR   (configFile.getInt("rules/kickoffFootColor",    0xFFFFFF)),
    NO_KICKOFF_FOOT_COLOR(configFile.getInt("rules/noKickoffFootColor",  0x000000)),
    READY_SPEECH            (configFile.getString("behaviors/2010/tactics/obeyGameManager/readySpeech",           "I will get ready for the game.")),
    SET_SPEECH              (configFile.getString("behaviors/2010/tactics/obeyGameManager/setSpeech",             "I am all set!")),
    PLAYING_SPEECH          (configFile.getString("behaviors/2010/tactics/obeyGameManager/playingSpeech",         "It's time to play.")),
    PENALIZED_SPEECH        (configFile.getString("behaviors/2010/tactics/obeyGameManager/penalizedSpeech",       "Please don't penalize me!")),
    BACK_FROM_PENALTY_SPEECH(configFile.getString("behaviors/2010/tactics/obeyGameManager/backFromPenaltySpeech", "The taste of freedom is sweet.")),
    BLUE_TEAM_SPEECH        (configFile.getString("behaviors/2010/tactics/obeyGameManager/blueTeamSpeech",        "I am now on the blue team.")),
    RED_TEAM_SPEECH         (configFile.getString("behaviors/2010/tactics/obeyGameManager/redTeamSpeech",         "I am now on the red team.")),
    KICKOFF_SPEECH          (configFile.getString("behaviors/2010/tactics/obeyGameManager/kickoffSpeech",         "We have kickoff.")),
    NO_KICKOFF_SPEECH       (configFile.getString("behaviors/2010/tactics/obeyGameManager/noKickoffSpeech",       "We don't have kickoff.")),
    PLAYER_NUMBER(configFile.getInt("team/playerNumber", 2)),
    HEAD_SPEED(configFile.getFloat("motion/defaultHeadSpeed", 0.8f)),
    log(_log),
    fsm(_log),
    previousState(Uninitialized),
    currentState(Uninitialized),
    wasIBlue(false),
    wasOurKickoff(false),
    wasIPenalized(false) {
  init(_log.getTimestamp());
}
开发者ID:rcahoon,项目名称:2010CMRoboBitsGroup3,代码行数:31,代码来源:ObeyGameManager.cpp

示例9: DBG_LOG

bool AtlasResourceCompiler::Compile()
{
	Platform* platform = Platform::Get();

	// Load configuration if we haven't already.
	if (m_config_file == NULL)
	{
		if (!Load_Config())
		{
			return false;
		}
	}

	// Compile time.
	DBG_LOG("Compiling atlas resource '%s'.", m_input_path.c_str());

	// Create new atlas, and start adding rectangles.
	Atlas* atlas = new Atlas(m_config_file);
	atlas->Lock_Textures();

	// Add each of the source-images.
	std::vector<ConfigFileNode> images = m_config_file->Get<std::vector<ConfigFileNode>>("images/image");
	for (std::vector<ConfigFileNode>::iterator iter = images.begin(); iter != images.end(); iter++)
	{
		ConfigFileNode node = *iter;		

		const char* type = m_config_file->Get<const char*>("type", node, true);
		const char* file = m_config_file->Get<const char*>("file", node, true);

		Point origin = Point(0, 0);

		if (m_config_file->Contains("origin", node, true))
		{
			origin = m_config_file->Get<Point>("origin", node, true);
		}

		if (stricmp(type, "single") == 0)
		{
			const char* name = m_config_file->Get<const char*>("name", node, true);

			Texture* texture = TextureFactory::Load_Without_Handle(file, TextureFlags::None);
			DBG_ASSERT_STR(texture != NULL, "Could not load dependent texture '%s'.", file);
			
			atlas->Add_Frame(name, texture, Rect(0, 0, texture->Get_Width(), texture->Get_Height()), origin);
		}		
		else if (stricmp(type, "multiple") == 0)
		{
			const char* name = m_config_file->Get<const char*>("name", node, true);

			// Grab all the file paths.
			std::string name_str = name;
			std::vector<std::string> files;
			Expand_Multiple_Path(file, files);

			// Grab hash mark.
			int hash_mark = name_str.find('#');
			DBG_ASSERT_STR(hash_mark != std::string::npos, "Image marked as type 'multiple' does not contain replacement hash mark.");
			std::string split_left  = name_str.substr(0, hash_mark);
			std::string split_right = name_str.substr(hash_mark + 1);

			// Add each file.
			int counter = 0;
			for (std::vector<std::string>::iterator subiter = files.begin(); subiter != files.end(); subiter++)
			{
				std::string sub_path = *subiter;
				std::string sub_name = split_left + StringHelper::To_String(counter++) + split_right;
				
				Texture* texture = TextureFactory::Load_Without_Handle(sub_path.c_str(), TextureFlags::None);
				DBG_ASSERT_STR(texture != NULL, "Could not load dependent texture '%s'.", sub_path);

				atlas->Add_Frame(sub_name.c_str(), texture, Rect(0, 0, texture->Get_Width(), texture->Get_Height()), origin);
			}
		}
		else if (stricmp(type, "grid") == 0)
		{
			const char* name = m_config_file->Get<const char*>("name", node, true);

			Texture* texture = TextureFactory::Load_Without_Handle(file, TextureFlags::None);
			DBG_ASSERT_STR(texture != NULL, "Could not load dependent texture '%s'.", file);
		
			// Grab hash mark.
			std::string name_str = name;
			int hash_mark = name_str.find('#');
			DBG_ASSERT_STR(hash_mark != std::string::npos, "Image marked as type 'grid' does not contain replacement hash mark.");
			std::string split_left  = name_str.substr(0, hash_mark);
			std::string split_right = name_str.substr(hash_mark + 1);

			// Iterate over each sub-image.			
			int   frame_width		= m_config_file->Get<int>("width", node, true);
			int   frame_height		= m_config_file->Get<int>("height", node, true);
			int   frame_hspace		= m_config_file->Get<int>("hspace", node, true);
			int   frame_vspace		= m_config_file->Get<int>("vspace", node, true);			
			float texture_width		= (float)texture->Get_Width();
			float texture_height	= (float)texture->Get_Height();
			int	  cell_count_u		= texture_width  / (frame_width + frame_hspace);
			int	  cell_count_v		= texture_height / (frame_height + frame_vspace);
			int	  cell_count		= cell_count_u * cell_count_v;

			for (int i = 0; i < cell_count; i++)
			{
//.........这里部分代码省略.........
开发者ID:HampsterEater,项目名称:VoxelEngine,代码行数:101,代码来源:AtlasResourceCompiler.cpp

示例10: DoFindStars

void DoFindStars(
    ConfigFile& params, FindStarsLog& log,
    const Image<double>& im, const Image<double>* weight_image,
    const Transformation& trans, 
    const InputCatalog& incat,
    std::auto_ptr<StarCatalog>& starcat)
{
    dbg<<"Starting FindStars script\n";

    bool isTiming = params.read("timing",false);
    timeval tp;
    double t1=0.,t2=0.;

    if (isTiming) {
        gettimeofday(&tp,0);
        t1 = tp.tv_sec + tp.tv_usec/1.e6;
    }

    // Create StarCatalog from InputCatalog
    starcat.reset(new StarCatalog(incat,params));

    if (isTiming) {
        gettimeofday(&tp,0);
        t2 = tp.tv_sec + tp.tv_usec/1.e6;
        std::cout<<"Time: Make StarCatalog = "<<t2-t1<<std::endl;
        t1 = t2;
    }

    // Update the sizes to more robust values
    starcat->calculateSizes(im,weight_image,trans);

    if (isTiming) {
        gettimeofday(&tp,0);
        t2 = tp.tv_sec + tp.tv_usec/1.e6;
        std::cout<<"Time: CalcSizes = "<<t2-t1<<std::endl;
        t1 = t2;
    }

    try {
        starcat->findStars(log);
    } catch(StarFinderException& e) {
        // Need to catch this here, so we can write the output file
        // with the sizes, even though we haven't figured out which 
        // objects are stars.
        dbg<<"Caught StarFinderException: "<<e.what()<<std::endl;  
        starcat->write();
        throw;
    } catch (...) {
        dbg<<"Caught unknown exception\n";
        starcat->write();
        throw;
    }
    dbg<<"After RunFindStars\n";

    if (isTiming) {
        gettimeofday(&tp,0);
        t2 = tp.tv_sec + tp.tv_usec/1.e6;
        std::cout<<"Time: FindStars = "<<t2-t1<<std::endl;
        t1 = t2;
    }

    // Write star catalog to file
    starcat->write();

    if (isTiming) {
        gettimeofday(&tp,0);
        t2 = tp.tv_sec + tp.tv_usec/1.e6;
        std::cout<<"Time: Write StarCatalog = "<<t2-t1<<std::endl;
        t1 = t2;
    }

    xdbg<<"FindStars Log: \n"<<log<<std::endl;
}
开发者ID:rmjarvis,项目名称:deswl_shapelets,代码行数:73,代码来源:Scripts.cpp

示例11: settings

ShibbolethWebView::~ShibbolethWebView()
{
    ConfigFile config;
    QSettings settings(config.configFile());
    settings.setValue(ShibbolethWebViewGeometryC, saveGeometry());
}
开发者ID:Rossojo,项目名称:client,代码行数:6,代码来源:shibbolethwebview.cpp

示例12:

//Constructor
Parameters::Parameters(ConfigFile config)
{
    config.readInto(outflow_model_on, "outflowModelOn");
    config.readInto(lambda, "lambda");
    config.readInto(single_mode, "Mode");
    config.readInto(range_number, "numberOfSpeedValues");
    config.readInto(elements_in_l, "elementsInL");
    config.readInto(adotc0, "aDotc0");

    config.readInto(pipeid, "pipeID");
    config.readInto(diameter, "diameter");
    config.readInto(sdr, "sdr");
    config.readInto(notch_depth, "notchDepth");
    config.readInto(diameter_creep_ratio, "diameterCreepRatio");

    config.readInto(matid, "matID" );
    config.readInto(density, "density" );
    config.readInto(edyn0degc, "eDyn0degC" );
    config.readInto(dedyndt, "dEdyndT" );
    config.readInto(creep_modulus, "creepModulus" );
    config.readInto(poisson, "poisson" );

    config.readInto(fullscale, "fullScale");
    config.readInto(tempdegc, "tempDegC");
    config.readInto(p0bar, "p0bar");
    config.readInto(is_backfilled, "isBackfilled");
    config.readInto(backfill_depth, "backfillDepth");
    config.readInto(backfill_density, "backfillDensity");
    config.readInto(solid_inside_pipe, "solidInsidePipe");
    config.readInto(water_inside_pipe, "waterInsidePipe");
}
开发者ID:FraserEdwards,项目名称:aRCPlanQt,代码行数:32,代码来源:Parameters.cpp

示例13: Set

	void Set(ConfigFile& conf) {
		switch(type)
		{
			case CIT_BOOL:
				if(size	== 1) conf.SetBool(name, 0!=(*(uint8 *)addr), "TRUE","FALSE", comment);
				if(size	== 2) conf.SetBool(name, 0!=(*(uint16*)addr), "TRUE","FALSE", comment);
				if(size	== 4) conf.SetBool(name, 0!=(*(uint32*)addr), "TRUE","FALSE", comment);
				if(size	== 8) conf.SetBool(name, 0!=(*(uint64*)addr), "TRUE","FALSE", comment);
				break;
			case CIT_BOOLONOFF:
				if(size	== 1) conf.SetBool(name, 0!=(*(uint8 *)addr), "ON","OFF", comment);
				if(size	== 2) conf.SetBool(name, 0!=(*(uint16*)addr), "ON","OFF", comment);
				if(size	== 4) conf.SetBool(name, 0!=(*(uint32*)addr), "ON","OFF", comment);
				if(size	== 8) conf.SetBool(name, 0!=(*(uint64*)addr), "ON","OFF", comment);
				break;
			case CIT_INT:
				if(size	== 1) conf.SetInt(name,	(int32)(*(uint8	*)addr), comment);
				if(size	== 2) conf.SetInt(name,	(int32)(*(uint16*)addr), comment);
				if(size	== 4) conf.SetInt(name,	(int32)(*(uint32*)addr), comment);
				if(size	== 8) conf.SetInt(name,	(int32)(*(uint64*)addr), comment);
				break;
			case CIT_UINT:
				if(size	== 1) conf.SetUInt(name, (uint32)(*(uint8 *)addr), 10, comment);
				if(size	== 2) conf.SetUInt(name, (uint32)(*(uint16*)addr), 10, comment);
				if(size	== 4) conf.SetUInt(name, (uint32)(*(uint32*)addr), 10, comment);
				if(size	== 8) conf.SetUInt(name, (uint32)(*(uint64*)addr), 10, comment);
				break;
			case CIT_STRING:
				if((TCHAR*)addr)
					conf.SetString(name, std::string(_tToChar((TCHAR*)addr)), comment);
				break;
			case CIT_INVBOOL:
				if(size	== 1) conf.SetBool(name, 0==(*(uint8 *)addr), "TRUE","FALSE", comment);
				if(size	== 2) conf.SetBool(name, 0==(*(uint16*)addr), "TRUE","FALSE", comment);
				if(size	== 4) conf.SetBool(name, 0==(*(uint32*)addr), "TRUE","FALSE", comment);
				if(size	== 8) conf.SetBool(name, 0==(*(uint64*)addr), "TRUE","FALSE", comment);
				break;
			case CIT_INVBOOLONOFF:
				if(size	== 1) conf.SetBool(name, 0==(*(uint8 *)addr), "ON","OFF", comment);
				if(size	== 2) conf.SetBool(name, 0==(*(uint16*)addr), "ON","OFF", comment);
				if(size	== 4) conf.SetBool(name, 0==(*(uint32*)addr), "ON","OFF", comment);
				if(size	== 8) conf.SetBool(name, 0==(*(uint64*)addr), "ON","OFF", comment);
				break;
			case CIT_VKEY:
				{
					uint16 keyNum = 0;
					if(size	== 1) keyNum = (uint8)(*(uint8 *)addr);
					if(size	== 2) keyNum = (uint16)(*(uint16*)addr);
					if(size	== 4) keyNum = (uint16)(*(uint32*)addr);
					if(size	== 8) keyNum = (uint16)(*(uint64*)addr);
					if(keyNum < 256) conf.SetString(name, keyToString[keyNum], comment);
					else if(keyNum & 0x8000) {
						char temp [128];
						extern void TranslateKey(WORD keyz,char *out);
						TranslateKey(keyNum,temp);
						conf.SetString(name, temp, comment);
					}
					else conf.SetUInt(name, keyNum, 16, comment);
				}
				break;
			case CIT_VKEYMOD:
				{
					uint16 modNum = 0;
					if(size	== 1) modNum = (uint8)(*(uint8 *)addr);
					if(size	== 2) modNum = (uint16)(*(uint16*)addr);
					if(size	== 4) modNum = (uint16)(*(uint32*)addr);
					if(size	== 8) modNum = (uint16)(*(uint64*)addr);
					std::string modStr;
					if(modNum & CUSTKEY_CTRL_MASK) modStr += "Ctrl ";
					if(modNum & CUSTKEY_ALT_MASK) modStr += "Alt ";
					if(modNum & CUSTKEY_SHIFT_MASK) modStr += "Shift ";
					if(!(modNum & (CUSTKEY_CTRL_MASK|CUSTKEY_ALT_MASK|CUSTKEY_SHIFT_MASK))) modStr = "none";
					else modStr.erase(modStr.length()-1);
					conf.SetString(name, modStr, comment);
				}
				break;
		}
	}
开发者ID:ddugovic,项目名称:RASuite,代码行数:78,代码来源:wconfig.cpp

示例14: LoadShader

bool CCGShader::LoadShader(const char *path)
{
	ConfigFile conf;
	int shaderCount;
	char keyName[100];

	shaderPasses.clear();
	lookupTextures.clear();

	if(strlen(path)<4 || strcasecmp(&path[strlen(path)-4],".cgp")) {
		shaderPass pass;
		pass.scaleParams.scaleTypeX = CG_SCALE_NONE;
		pass.scaleParams.scaleTypeY = CG_SCALE_NONE;
		pass.linearFilter = false;
		pass.filterSet = false;
		strcpy(pass.cgShaderFile,path);
		shaderPasses.push_back(pass);
		return true;
	} else {
		conf.LoadFile(path);
	}	

	shaderCount = conf.GetInt("::shaders",0);

	if(shaderCount<1)
		return false;

	for(int i=0;i<shaderCount;i++) {
		shaderPass pass;
		sprintf(keyName,"::filter_linear%u",i);
		pass.linearFilter = conf.GetBool(keyName);
		pass.filterSet = conf.Exists(keyName);

		sprintf(keyName,"::scale_type%u",i);
		const char *scaleType = conf.GetString(keyName,"");
		if(!strcasecmp(scaleType,"")) {
			sprintf(keyName,"::scale_type_x%u",i);
			const char *scaleTypeX = conf.GetString(keyName,"");
			if(*scaleTypeX=='\0' && (i!=(shaderCount-1)))
				scaleTypeX = "source";
			pass.scaleParams.scaleTypeX = scaleStringToEnum(scaleTypeX);
			sprintf(keyName,"::scale_type_y%u",i);
			const char *scaleTypeY = conf.GetString(keyName,"");
			if(*scaleTypeY=='\0' && (i!=(shaderCount-1)))
				scaleTypeY = "source";
			pass.scaleParams.scaleTypeY = scaleStringToEnum(scaleTypeY);
		} else {
			cgScaleType sType = scaleStringToEnum(scaleType);
			pass.scaleParams.scaleTypeX = sType;
			pass.scaleParams.scaleTypeY = sType;
		}

		sprintf(keyName,"::scale%u",i);
		const char *scaleFloat = conf.GetString(keyName,"");
		int scaleInt = conf.GetInt(keyName,0);
		if(!strcasecmp(scaleFloat,"")) {
			sprintf(keyName,"::scalex%u",i);
			const char *scaleFloatX = conf.GetString(keyName,"1.0");
			pass.scaleParams.scaleX = atof(scaleFloatX);
			pass.scaleParams.absX = conf.GetInt(keyName,1);
			sprintf(keyName,"::scaley%u",i);
			const char *scaleFloatY = conf.GetString(keyName,"1.0");
			pass.scaleParams.scaleY = atof(scaleFloatY);
			pass.scaleParams.absY = conf.GetInt(keyName,1);

		} else {
			float floatval = atof(scaleFloat);
			pass.scaleParams.scaleX = floatval;
			pass.scaleParams.absX = scaleInt;
			pass.scaleParams.scaleY = floatval;
			pass.scaleParams.absY = scaleInt;
		}

		sprintf(keyName,"::shader%u",i);
		strcpy(pass.cgShaderFile,conf.GetString(keyName,""));
		shaderPasses.push_back(pass);
	}

	char *shaderIds = conf.GetStringDup("::textures","");

	char *id = strtok(shaderIds,";");
	while(id!=NULL) {
		lookupTexture tex;
		sprintf(keyName,"::%s",id);
		strcpy(tex.id,id);
		strcpy(tex.texturePath,conf.GetString(keyName,""));
		sprintf(keyName,"::%s_linear",id);
		tex.linearfilter = conf.GetBool(keyName,true);
		lookupTextures.push_back(tex);
		id = strtok(NULL,";");
	}

	free(shaderIds);

	return true;
}
开发者ID:GeoffreyPlitt,项目名称:snes9x-sdl,代码行数:96,代码来源:CCGShader.cpp

示例15: slotToggleOptionalDesktopNotifications

void GeneralSettings::slotToggleOptionalDesktopNotifications(bool enable)
{
    ConfigFile cfgFile;
    cfgFile.setOptionalDesktopNotifications(enable);
}
开发者ID:SnakeSolidNL,项目名称:client,代码行数:5,代码来源:generalsettings.cpp


注:本文中的ConfigFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。