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


C++ CfgList类代码示例

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


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

示例1: Load

bool ReconConfig::Load (CfgList *rootcfg)
{
	CfgList *rinfo = dynamic_cast<CfgList*> (rootcfg->GetValue ("reconinfo"));

	if (rinfo)
	{
		scouts = dynamic_cast<CfgBuildOptions*> (rinfo->GetValue ("scouts"));
		if (scouts)
		{
			if (!scouts->InitIDs ())
				return false;
		}

		updateInterval = rinfo->GetInt ("updateinterval", 4);
		maxForce = rinfo->GetInt ("maxforce", 5);

		CfgList* hcfg = dynamic_cast<CfgList*> (rinfo->GetValue ("SearchHeuristic"));
		if (hcfg)
		{
			searchHeuristic.DistanceFactor = hcfg->GetNumeric ("DistanceFactor");
			searchHeuristic.ThreatFactor = hcfg->GetNumeric ("ThreatFactor");
			searchHeuristic.TimeFactor = hcfg->GetNumeric ("TimeFactor");
			searchHeuristic.SpreadFactor = hcfg->GetNumeric ("SpreadFactor");
		}
		else {
			logPrintf ("Error: No search heuristic info in recon config node.\n");
			return false;
		}

		return true;
	}
	return false;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:33,代码来源:ReconHandler.cpp

示例2: Load

bool SupportConfig::Load (CfgList *sidecfg)
{
	CfgList *scfg = dynamic_cast <CfgList*> (sidecfg->GetValue ("supportinfo"));

	if (scfg)
	{
		basecover = dynamic_cast<CfgBuildOptions*> (scfg->GetValue ("basecover"));
		mapcover = dynamic_cast<CfgBuildOptions*> (scfg->GetValue ("mapcover"));

		if (basecover) 
		{
			MapUDefProperties (basecover, basecoverProps);

			if (!basecover->InitIDs ())
				return false;
		}
		if (mapcover)
		{
			MapUDefProperties (mapcover, mapcoverProps);
			
			if (!mapcover->InitIDs ())
				return false;
		}
	}

	return true;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:27,代码来源:SupportHandler.cpp

示例3: fopen

CfgList* CfgValue::LoadFile (std::string name)
{
	InputBuffer buf;

	FILE *f = fopen (name.c_str(), "rb");
	if (!f) 
		throw ContentException(SPrintf("Failed to open file %s\n", name.c_str()));

	fseek (f, 0, SEEK_END);
	buf.len = ftell(f);
	buf.data = new char [buf.len];
	fseek (f, 0, SEEK_SET);
	if (!fread (buf.data, buf.len, 1, f))
	{
		fclose (f);
		delete[] buf.data;
		throw ContentException(SPrintf("Failed to read file %s\n", name.c_str()));
	}
	buf.filename = name.c_str();

	fclose (f);

	CfgList *nlist = new CfgList;
	try {
		nlist->Parse (buf, true);
	}  catch (const ContentException &e) {
		delete[] buf.data;
		delete nlist;
		throw e;
	}
	delete[] buf.data;
    return nlist;
}
开发者ID:jcnossen,项目名称:ncrobot,代码行数:33,代码来源:CfgParser.cpp

示例4: Serialize

void EditorViewWindow::Serialize(CfgList& cfg, bool store)
{
	ViewWindow::Serialize (cfg, store);

	Camera::CtlMode& camCtlMode=cam.ctlmode;
	if (store) {
		CFG_STOREN(cfg,mode);
		CFG_STOREN(cfg,rendermode);
		cfg.AddNumeric ("camCtlMode", (int)camCtlMode);
		CFG_STORE(cfg, bDrawCenters);
		CFG_STORE(cfg, bCullFaces);
		CFG_STORE(cfg, bLighting);
		CFG_STORE(cfg, bHideGrid);
		CFG_STORE(cfg, bDrawRadius);
	} else {
		CFG_LOADN(cfg,mode);
		SetMode(mode);
		CFG_LOADN(cfg,rendermode);
		camCtlMode=(Camera::CtlMode)cfg.GetInt ("camCtlMode",0);
		CFG_LOAD(cfg, bDrawCenters);
		CFG_LOAD(cfg, bCullFaces);
		CFG_LOAD(cfg, bLighting);
		CFG_LOAD(cfg, bHideGrid);
		CFG_LOAD(cfg, bDrawRadius);
	}
}
开发者ID:SpliFF,项目名称:upspring,代码行数:26,代码来源:View.cpp

示例5: CfgList

void CfgList::Add(const char* name, Vector2 v)
{
	CfgList* l = new CfgList();

	l->Add("x", v.x);
	l->Add("y", v.y);

	Add(name, l);
}
开发者ID:jcnossen,项目名称:ncrobot,代码行数:9,代码来源:CfgParser.cpp

示例6: assert

bool BuildHandler::DoInitialBuildOrders ()
{
    // initial build orders completed?
	assert (config.InitialOrders);

	if (initialBuildOrderTask)
		return true;

	for (int a=0;a<initialBuildOrderState.size();a++) {
		int &state = initialBuildOrderState[a];
		if (state < config.InitialOrders->builds[a]->count) {
			int type=-1;
			int id=config.InitialOrders->builds[a]->def;
			BuildTable::UDef *cd = buildTable.GetCachedDef(id);

			CfgList* info = config.InitialOrders->builds[a]->info;
			const char *handler = info ? info->GetLiteral ("Handler") : 0;
			if (handler) {
				for (int h=0;h<NUM_TASK_TYPES;h++) {
					if(!STRCASECMP(handler, handlerStr[h])) {
						type=h;
						break;
					}
				}
				
				if (h == BTF_Force) {
					ChatMsgPrintf (ai->cb, "Error: No force units possible in the initial build orders.\n");
					state=config.InitialOrders->builds[a]->count;
					return false;
				}
			} else {
				if(!cd->IsBuilder())  {
					ChatMsgPrintf (ai->cb, "Error in initial buildorder list: unit %s is not a builder\n", cd->name.c_str());
					state=config.InitialOrders->builds[a]->count;
					return false;
				}
			}

			aiTask *t = initialBuildOrderTask = AddTask (buildTable.GetDef(id), type);
			t->MarkAllocated ();
			state ++;

			return true;
		}
	}

	// all initial build tasks are done
	if (!initialBuildOrdersFinished) {
		ChatDebugPrintf (ai->cb,"Initial build orders finished.");

		DistributeResources ();
		initialBuildOrdersFinished=true;
	}
	return false;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:55,代码来源:BuildHandler.cpp

示例7: writer

void EditorUI::SaveSettings()
{
	string path=applicationPath + ViewSettingsFile;
	CfgWriter writer(path.c_str());
	if (writer.IsFailed ()) {
		fltk::message ("Failed to open %s for writing view settings", path.c_str());
		return;
	}
	CfgList cfg;
	SerializeConfig (cfg, true);
	cfg.Write(writer,true);
}
开发者ID:Neoniet,项目名称:upspring,代码行数:12,代码来源:Editor.cpp

示例8: MakeConfig

CfgList* TextureGroupHandler::MakeConfig (TextureGroup *tg)
{
	CfgList *gc = new CfgList;
	char n [10];

	CfgList *texlist=new CfgList;
	int index=0;
	for (set<Texture*>::iterator t=tg->textures.begin();t!=tg->textures.end();++t) {
		sprintf (n,"tex%d", index++);
		texlist->AddLiteral (n, (*t)->name.c_str());
	}
	gc->AddValue ("textures", texlist);
	gc->AddLiteral ("name", tg->name.c_str());
	return gc;
}
开发者ID:SpliFF,项目名称:upspring,代码行数:15,代码来源:Texture.cpp

示例9: ParseForceGroup

bool ForceConfig::Load (CfgList *cfg)
{
	CfgList *forceinfo = dynamic_cast<CfgList*> (cfg->GetValue ("forceinfo"));

	if (forceinfo)
	{
		defaultSpread = forceinfo->GetNumeric ("defaultspread", 500);

		for (list<CfgListElem>::iterator gr = forceinfo->childs.begin(); gr != forceinfo->childs.end(); ++gr)
		{
			if (dynamic_cast <CfgList*> (gr->value))
				ParseForceGroup ( (CfgList *)gr->value, gr->name );
		}
		return true;
	}
	
	logPrintf ("Error: No force info in config.\n");
	return false;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:19,代码来源:ForceHandler.cpp

示例10: writer

bool TextureGroupHandler::Save(const char *fn)
{
	// open a cfg writer
	CfgWriter writer(fn);
	if (writer.IsFailed()) {
		fltk::message ("Unable to save texture groups to %s\n", fn);
		return false;
	}

	// create a config list and save it
	CfgList cfg;

	for (uint a=0;a<groups.size();a++) {
		CfgList *gc=MakeConfig(groups[a]);

		char n [10];
		sprintf (n, "group%d", a);
		cfg.AddValue (n, gc);
	}

	cfg.Write(writer,true);
	return true;
}
开发者ID:SpliFF,项目名称:upspring,代码行数:23,代码来源:Texture.cpp

示例11: logPrintf

bool ModConfig::UnitTypeInfo::Load (CfgList *root, BuildTable *tbl)
{
	CfgList *sideinfo = dynamic_cast <CfgList*> (root->GetValue ("sideinfo"));

	if (!sideinfo)
	{
		logPrintf ("No sideinfo node found in config file\n");
		return false;
	}

	CfgList *l = dynamic_cast <CfgList*> (sideinfo->GetValue ("aadefense"));

	for (list<CfgListElem>::iterator i=l->childs.begin();i!=l->childs.end();++i)
	{
		UnitDefID id = tbl->GetDefID (i->name.c_str());
		if (id)
		{
			aadefense.push_back (id);
			BuildTable::UDef* cd = tbl->GetCachedDef (id);
			cd->flags |= CUD_AADefense;
		}
	}

	l = dynamic_cast <CfgList*> (sideinfo->GetValue ("gddefense"));

	for (list<CfgListElem>::iterator i=l->childs.begin();i!=l->childs.end();++i)
	{
		UnitDefID id = tbl->GetDefID (i->name.c_str());
		if (id) {
			gddefense.push_back (id);
			BuildTable::UDef* cd = tbl->GetCachedDef (id);
			cd->flags |= CUD_GroundDefense;
		}
	}

	return true;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:37,代码来源:AIConfigLoader.cpp

示例12: fopen

CfgList* CfgValue::LoadFile (const char *name)
{
	InputBuffer buf;

	FILE *f = fopen (name, "rb");
	if (!f) {
		logger.Trace (NL_Debug, "Failed to open file %s\n", name);
		return 0;
	}

	fseek (f, 0, SEEK_END);
	buf.len = ftell(f);
	buf.data = new char [buf.len];
	fseek (f, 0, SEEK_SET);
	if (!fread (buf.data, buf.len, 1, f))
	{
		logger.Trace (NL_Debug, "Failed to read file %s\n", name);
		fclose (f);
		delete[] buf.data;
		return 0;
	}
	buf.filename = name;

	fclose (f);

	CfgList *nlist = new CfgList;
	if (!nlist->Parse (buf,true))
	{
		delete nlist;
		delete[] buf.data;
		return 0;
	}

	delete[] buf.data;
    return nlist;
}
开发者ID:SpliFF,项目名称:upspring,代码行数:36,代码来源:CfgParser.cpp

示例13: CFG_STOREN

void EditorUI::SerializeConfig (CfgList& cfg, bool store)
{
	// Serialize editor window properties
	int x=window->x(), y=window->y(), width=window->w(), height=window->h();
	string& springTexDir = Texture::textureLoadDir;
	if (store) {
		CFG_STOREN(cfg,x);
		CFG_STOREN(cfg,y);
		CFG_STOREN(cfg,width);
		CFG_STOREN(cfg,height);
		CFG_STORE(cfg,springTexDir);
		CFG_STORE(cfg,optimizeOnLoad);
		bool showTimeline=uiTimeline->window->visible();
		CFG_STORE(cfg,showTimeline);
		bool showTrackEdit=uiAnimTrackEditor->window->visible();
		CFG_STORE(cfg,showTrackEdit);
		bool showIK=uiIK->window->visible();
		CFG_STORE(cfg,showIK);
	} else {
		CFG_LOADN(cfg,x);
		CFG_LOADN(cfg,y);
		CFG_LOADN(cfg,width);
		CFG_LOADN(cfg,height);
		CFG_LOAD(cfg,springTexDir);
		CFG_LOAD(cfg,optimizeOnLoad);

		window->resize(x,y,width,height);
	}
	// Serialize views: first match the number of views specified in the config
	int numViews = viewsGroup->children();
	if (store) {
		CFG_STOREN(cfg,numViews);
	} else {
		CFG_LOADN(cfg,numViews);
		int nv=numViews-viewsGroup->children();
		if (nv > 0) {
			viewsGroup->begin();
			for (int a=0;a<nv;a++) {
				EditorViewWindow *wnd = new EditorViewWindow (0,0,0,0,&callback);
				wnd->SetMode(a%4);
			}
			viewsGroup->end();
		} else {
			for (int a=viewsGroup->children()-1;a>=numViews;a--) {
				EditorViewWindow *wnd = (EditorViewWindow *)viewsGroup->child(a);
				viewsGroup->remove (wnd);
				delete wnd;
			}
		}
	}
	// then serialize view settings for each view in the config
	int viewIndex = 0;
	char viewName[16];
	for (int a=0;a<viewsGroup->children();++a) {
		sprintf (viewName, "View%d", viewIndex++);
		CfgList *viewcfg;
		if (store) {
			viewcfg = new CfgList;
			cfg.AddValue (viewName, viewcfg);
		}else viewcfg=dynamic_cast<CfgList*>(cfg.GetValue(viewName));
		if (viewcfg) 
			((EditorViewWindow *)viewsGroup->child(a))->Serialize (*viewcfg,store);
	}
}
开发者ID:Neoniet,项目名称:upspring,代码行数:64,代码来源:Editor.cpp

示例14: Load

bool AIConfig::Load (const char *file, IGlobalAICallback *cb)
{
	CfgList *info = 0;

	root = CfgValue::LoadFile (file);
	if (root)
		info = dynamic_cast<CfgList*> (root->GetValue ("info"));

	if (info) 
	{
		infoblocksize=info->GetInt ("infoblocksize", -1);

		if (infoblocksize < 8)
		{
			ChatMsgPrintf (cb->GetAICallback(), "AIConfig: invalid infoblocksize: %d\n", infoblocksize);
			return false;
		}

		debug = info->GetInt ("debug",0)!=0;
		showDebugWindow = info->GetInt ("showdebugwindow",0) != 0;
		showMetalSpots=info->GetInt ("showmetalspots", 0)!=0;
		safeSectorRadius = info->GetInt ("safesectorradius", 15);
		mexSectorRadius = info->GetInt ("mexsectorradius", 15);
		cacheBuildTable = !!info->GetInt ("cachebuildtable", 1);
		builderMoveTimeout = info->GetInt ("buildermovetimeout", 200);
		builderMoveMinDistance = info->GetNumeric("buildermovemindistance", 100);
		threatDecay = info->GetNumeric ("threatdecay", 0.1f);
	}
	else {
		ChatMsgPrintf (cb->GetAICallback(), "Error: Unable to read configuration file %s. Aborting global AI.\n", file);
		return false;
	}

	return true;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:35,代码来源:AIConfigLoader.cpp

示例15: GetDirPath

Genome::Genome(std::string file)
{
	filename = file;
	CfgList* d = CfgList::LoadFile(file);

	// read sequence data
	const char* seqfile = d->GetLiteral("SequenceFile");
	std::string seqPath = GetDirPath(file) + seqfile;
	sequence = ReadTextFile(seqPath);
	std::transform(sequence.begin(), sequence.end(), sequence.begin(), ::tolower);

	// load global properties

	name = d->GetLiteral("LocusName");
	topology = d->GetLiteral("LocusTopology");
	modificationDate = d->GetLiteral("LocusModificationDate");
	definition = d->GetLiteral("Definition");
	source = d->GetLiteral("Source");

	// load features
	CfgList* features = d->GetList("features");
	mvec<FeatureProtein*> proteins = LoadFeatureList<FeatureProtein>(features->GetList("CDS"));
	members_ptr(proteins, &FeatureProtein::type) |= FeatureProtein::Type_Protein;
	
	mvec<Feature*> tRNA = LoadFeatureList<Feature>(features->GetList("tRNA"));
	members_ptr(tRNA, &Feature::type) |= Feature::Type_tRNA;

	mvec<Feature*> rRNA = LoadFeatureList<Feature>(features->GetList("rRNA"));
	members_ptr(rRNA, &Feature::type) |= Feature::Type_rRNA;

	mvec<Feature*> misc_RNA = LoadFeatureList<Feature>(features->GetList("misc_RNA"));
	members_ptr(misc_RNA, &Feature::type) |= Feature::Type_MiscRNA;

	mvec<Feature*> misc_feature = LoadFeatureList<Feature>(features->GetList("misc_feature"));
	members_ptr(misc_feature, &Feature::type) |= Feature::Type_MiscFeature;

	genes = tRNA & rRNA & misc_RNA & misc_feature & proteins;

	// sort genes
	std::sort(genes.begin(), genes.end(), GeneComparer);

	delete d;
}
开发者ID:jcnossen,项目名称:hmmgenefinder,代码行数:43,代码来源:Genome.cpp


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