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


C++ Property::GetValues方法代码示例

本文整理汇总了C++中Property::GetValues方法的典型用法代码示例。如果您正苦于以下问题:C++ Property::GetValues方法的具体用法?C++ Property::GetValues怎么用?C++ Property::GetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Property的用法示例。


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

示例1:

const std::vector<Value>& Prop_multival::GetValues() const 
{
	Property *p = section->Get_prop(0);
	//No properties in this section. do nothing
	if(!p) return suggested_values;
	int i =0;
	while( (p = section->Get_prop(i++)) ) {
		std::vector<Value> v = p->GetValues();
		if(!v.empty()) return p->GetValues();
	}
	return suggested_values;
}
开发者ID:roman-murashov,项目名称:dosbox-x,代码行数:12,代码来源:setup.cpp

示例2: PrintConfig

bool Config::PrintConfig(char const * const configfilename,bool everything) const {
	char temp[50];char helpline[256];
	FILE* outfile=fopen(configfilename,"w+t");
	if(outfile==NULL) return false;

	/* Print start of configfile and add an return to improve readibility. */
	fprintf(outfile,MSG_Get("CONFIGFILE_INTRO"),VERSION);
	fprintf(outfile,"\n");
	for (const_it tel=sectionlist.begin(); tel!=sectionlist.end(); tel++){
		/* Print out the Section header */
		Section_prop *sec = dynamic_cast<Section_prop *>(*tel);
		strcpy(temp,(*tel)->GetName());
		lowcase(temp);

		if (sec) {
			int mods=0;
			Property *p;
			size_t i = 0, maxwidth = 0;
			while ((p = sec->Get_prop(i++))) {
				if (!everything && !p->modified()) continue;

				size_t w = strlen(p->propname.c_str());
				if (w > maxwidth) maxwidth = w;
				mods++;
			}

			if (!everything && mods == 0) {
				/* nothing to print */
				continue;
			}

			fprintf(outfile,"[%s]\n",temp);

			i=0;
			char prefix[80];
			snprintf(prefix,80, "\n# %*s  ", (int)maxwidth, "");
			while ((p = sec->Get_prop(i++))) {
				if (!everything && !p->modified()) continue;

				std::string help = p->Get_help();
				std::string::size_type pos = std::string::npos;
				while ((pos = help.find("\n", pos+1)) != std::string::npos) {
					help.replace(pos, 1, prefix);
				}

				std::vector<Value> values = p->GetValues();

				if (help != "" || !values.empty()) {
					fprintf(outfile, "# %*s: %s", (int)maxwidth, p->propname.c_str(), help.c_str());

					if (!values.empty()) {
						fprintf(outfile, "%s%s:", prefix, MSG_Get("CONFIG_SUGGESTED_VALUES"));
						std::vector<Value>::iterator it = values.begin();
						while (it != values.end()) {
							if((*it).ToString() != "%u") { //Hack hack hack. else we need to modify GetValues, but that one is const...
								if (it != values.begin()) fputs(",", outfile);
								fprintf(outfile, " %s", (*it).ToString().c_str());
							}
							++it;
						}
						fprintf(outfile,".");
					}
					fprintf(outfile, "\n");
				}
			}
		} else {
			fprintf(outfile,"[%s]\n",temp);

			upcase(temp);
			strcat(temp,"_CONFIGFILE_HELP");
			const char * helpstr=MSG_Get(temp);
			char * helpwrite=helpline;
			while (*helpstr) {
				*helpwrite++=*helpstr;
				if (*helpstr == '\n') {
					*helpwrite=0;
					fprintf(outfile,"# %s",helpline);
					helpwrite=helpline;
				}
				helpstr++;
			}
		}
	   
		(*tel)->PrintData(outfile,everything);
		fprintf(outfile,"\n");		/* Always an empty line between sections */
	}
	fclose(outfile);
	return true;
}
开发者ID:roman-murashov,项目名称:dosbox-x,代码行数:89,代码来源:setup.cpp

示例3: Run


//.........这里部分代码省略.........
				return;
			}
			Section_prop* psec = dynamic_cast <Section_prop*>(sec);
			if (psec==NULL) {
				// failed; maybe it's the autoexec section?
				Section_line* pline = dynamic_cast <Section_line*>(sec);
				if (pline==NULL) E_Exit("Section dynamic cast failed.");

				WriteOut(MSG_Get("PROGRAM_CONFIG_HLP_LINEHLP"),
					pline->GetName(),
					// this is 'unclean' but the autoexec section has no help associated
					MSG_Get("AUTOEXEC_CONFIGFILE_HELP"),
					pline->data.c_str() );
				return;
			} 
			if (pvars.size()==1) {
				size_t i = 0;
				WriteOut(MSG_Get("PROGRAM_CONFIG_HLP_SECTHLP"),pvars[0].c_str());
				while(true) {
					// list the properties
					Property* p = psec->Get_prop(i++);
					if (p==NULL) break;
					WriteOut("%s\n", p->propname.c_str());
				}
			} else {
				// find the property by it's name
				size_t i = 0;
				while (true) {
					Property *p = psec->Get_prop(i++);
					if (p==NULL) break;
					if (!strcasecmp(p->propname.c_str(),pvars[1].c_str())) {
						// found it; make the list of possible values
						std::string propvalues;
						std::vector<Value> pv = p->GetValues();
						
						if (p->Get_type()==Value::V_BOOL) {
							// possible values for boolean are true, false
							propvalues += "true, false";
						} else if (p->Get_type()==Value::V_INT) {
							// print min, max for integer values if used
							Prop_int* pint = dynamic_cast <Prop_int*>(p);
							if (pint==NULL) E_Exit("Int property dynamic cast failed.");
							if (pint->getMin() != pint->getMax()) {
								std::ostringstream oss;
								oss << pint->getMin();
								oss << "..";
								oss << pint->getMax();
								propvalues += oss.str();
							}
						}
						for(Bitu k = 0; k < pv.size(); k++) {
							if (pv[k].ToString() =="%u")
								propvalues += MSG_Get("PROGRAM_CONFIG_HLP_POSINT");
							else propvalues += pv[k].ToString();
							if ((k+1) < pv.size()) propvalues += ", ";
						}

						WriteOut(MSG_Get("PROGRAM_CONFIG_HLP_PROPHLP"),
							p->propname.c_str(),
							sec->GetName(),
							p->Get_help(),propvalues.c_str(),
							p->Get_Default_Value().ToString().c_str(),
							p->GetValue().ToString().c_str());
						// print 'changability'
						if (p->getChange()==Property::Changeable::OnlyAtStart) {
							WriteOut(MSG_Get("PROGRAM_CONFIG_HLP_NOCHANGE"));
开发者ID:dborth,项目名称:dosbox-wii,代码行数:67,代码来源:programs.cpp


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