本文整理汇总了C++中Section::GetPropValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Section::GetPropValue方法的具体用法?C++ Section::GetPropValue怎么用?C++ Section::GetPropValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Section
的用法示例。
在下文中一共展示了Section::GetPropValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckConfig
bool DOS_Shell::CheckConfig(char* cmd_in,char*line) {
Section* test = control->GetSectionFromProperty(cmd_in);
if(!test) return false;
if(line && !line[0]) {
std::string val = test->GetPropValue(cmd_in);
if(val != NO_SUCH_PROPERTY) WriteOut("%s\n",val.c_str());
return true;
}
char newcom[1024]; newcom[0] = 0; strcpy(newcom,"z:\\config -set ");
strcat(newcom,test->GetName()); strcat(newcom," ");
strcat(newcom,cmd_in);strcat(newcom,line);
DoCommand(newcom);
return true;
}
示例2: Run
void CONFIG::Run(void) {
FILE * f;
if (cmd->FindString("-writeconf",temp_line,true)
|| cmd->FindString("-wc",temp_line,true)) {
/* In secure mode don't allow a new configfile to be created */
if(control->SecureMode()) {
WriteOut(MSG_Get("PROGRAM_CONFIG_SECURE_DISALLOW"));
return;
}
f=fopen(temp_line.c_str(),"wb+");
if (!f) {
WriteOut(MSG_Get("PROGRAM_CONFIG_FILE_ERROR"),temp_line.c_str());
return;
}
fclose(f);
control->PrintConfig(temp_line.c_str());
return;
}
if (cmd->FindString("-writelang",temp_line,true)
||cmd->FindString("-wl",temp_line,true)) {
/* In secure mode don't allow a new languagefile to be created
* Who knows which kind of file we would overwriting. */
if(control->SecureMode()) {
WriteOut(MSG_Get("PROGRAM_CONFIG_SECURE_DISALLOW"));
return;
}
f=fopen(temp_line.c_str(),"wb+");
if (!f) {
WriteOut(MSG_Get("PROGRAM_CONFIG_FILE_ERROR"),temp_line.c_str());
return;
}
fclose(f);
MSG_Write(temp_line.c_str());
return;
}
/* Code for switching to secure mode */
if(cmd->FindExist("-securemode",true)) {
control->SwitchToSecureMode();
WriteOut(MSG_Get("PROGRAM_CONFIG_SECURE_ON"));
return;
}
/* Code for getting the current configuration. *
* Official format: config -get "section property" *
* As a bonus it will set %CONFIG% to this value as well */
if(cmd->FindString("-get",temp_line,true)) {
std::string temp2 = "";
cmd->GetStringRemain(temp2);//So -get n1 n2= can be used without quotes
if(temp2 != "") temp_line = temp_line + " " + temp2;
std::string::size_type space = temp_line.find(" ");
if(space == std::string::npos) {
WriteOut(MSG_Get("PROGRAM_CONFIG_GET_SYNTAX"));
return;
}
//Copy the found property to a new string and erase from templine (mind the space)
std::string prop = temp_line.substr(space+1); temp_line.erase(space);
Section* sec = control->GetSection(temp_line.c_str());
if(!sec) {
WriteOut(MSG_Get("PROGRAM_CONFIG_SECTION_ERROR"),temp_line.c_str());
return;
}
std::string val = sec->GetPropValue(prop.c_str());
if(val == NO_SUCH_PROPERTY) {
WriteOut(MSG_Get("PROGRAM_CONFIG_NO_PROPERTY"),prop.c_str(),temp_line.c_str());
return;
}
WriteOut("%s",val.c_str());
first_shell->SetEnv("CONFIG",val.c_str());
return;
}
/* Code for the configuration changes *
* Official format: config -set "section property=value" *
* Accepted: without quotes and/or without -set and/or without section *
* and/or the "=" replaced by a " " */
if (cmd->FindString("-set",temp_line,true)) { //get all arguments
std::string temp2 = "";
cmd->GetStringRemain(temp2);//So -set n1 n2=n3 can be used without quotes
if(temp2!="") temp_line = temp_line + " " + temp2;
} else if(!cmd->GetStringRemain(temp_line)) {//no set
WriteOut(MSG_Get("PROGRAM_CONFIG_USAGE")); //and no arguments specified
return;
};
//Wanted input: n1 n2=n3
char copy[1024];
strcpy(copy,temp_line.c_str());
//seperate section from property
const char* temp = strchr(copy,' ');
if((temp && *temp) || (temp=strchr(copy,'=')) ) copy[temp++ - copy]= 0;
else {
WriteOut(MSG_Get("PROGRAM_CONFIG_USAGE"));
return;
}
//if n1 n2 n3 then replace last space with =
//.........这里部分代码省略.........
示例3: Run
//.........这里部分代码省略.........
}
switch(pvars.size()) {
case 1: {
// property/section only
// is it a section?
Section* sec = control->GetSection(pvars[0].c_str());
if (sec) {
// list properties in section
Bitu i = 0;
Section_prop* psec = dynamic_cast <Section_prop*>(sec);
if (psec==NULL) {
// autoexec section
Section_line* pline = dynamic_cast <Section_line*>(sec);
if (pline==NULL) E_Exit("Section dynamic cast failed.");
WriteOut("%s",pline->data.c_str());
break;
}
while(true) {
// list the properties
Property* p = psec->Get_prop(i++);
if (p==NULL) break;
WriteOut("%s=%s\n", p->propname.c_str(),
p->GetValue().ToString().c_str());
}
} else {
// no: maybe it's a property?
sec = control->GetSectionFromProperty(pvars[0].c_str());
if (!sec) {
WriteOut(MSG_Get("PROGRAM_CONFIG_PROPERTY_ERROR"));
return;
}
// it's a property name
std::string val = sec->GetPropValue(pvars[0].c_str());
WriteOut("%s",val.c_str());
}
break;
}
case 2: {
// section + property
Section* sec = control->GetSection(pvars[0].c_str());
if (!sec) {
WriteOut(MSG_Get("PROGRAM_CONFIG_SECTION_ERROR"));
return;
}
std::string val = sec->GetPropValue(pvars[1].c_str());
if (val == NO_SUCH_PROPERTY) {
WriteOut(MSG_Get("PROGRAM_CONFIG_NO_PROPERTY"),
pvars[1].c_str(),pvars[0].c_str());
return;
}
WriteOut("%s",val.c_str());
break;
}
default:
WriteOut(MSG_Get("PROGRAM_CONFIG_GET_SYNTAX"));
return;
}
return;
}
case P_SETPROP: {
// Code for the configuration changes
// Official format: config -set "section property=value"
// Accepted: with or without -set,
// "section property value"
// "section property=value"