本文整理汇总了C++中Property::Get_help方法的典型用法代码示例。如果您正苦于以下问题:C++ Property::Get_help方法的具体用法?C++ Property::Get_help怎么用?C++ Property::Get_help使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Property
的用法示例。
在下文中一共展示了Property::Get_help方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: Run
//.........这里部分代码省略.........
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"));
}
return;
}
}
break;
}
return;
}
case P_AUTOEXEC_CLEAR: {
Section_line* sec = dynamic_cast <Section_line*>
(control->GetSection(std::string("autoexec")));
sec->data.clear();
break;
}
case P_AUTOEXEC_ADD: {
if (pvars.size() == 0) {
WriteOut(MSG_Get("PROGRAM_CONFIG_MISSINGPARAM"));
return;
}
Section_line* sec = dynamic_cast <Section_line*>
(control->GetSection(std::string("autoexec")));
for(Bitu i = 0; i < pvars.size(); i++) sec->HandleInputline(pvars[i]);
break;
}
case P_AUTOEXEC_TYPE: {
Section_line* sec = dynamic_cast <Section_line*>