本文整理汇总了C++中Section::ExecuteDestroy方法的典型用法代码示例。如果您正苦于以下问题:C++ Section::ExecuteDestroy方法的具体用法?C++ Section::ExecuteDestroy怎么用?C++ Section::ExecuteDestroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Section
的用法示例。
在下文中一共展示了Section::ExecuteDestroy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
//.........这里部分代码省略.........
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 =
const char* sign = strchr(temp,'=');
if(!sign) {
sign = strchr(temp,' ');
if(sign) {
copy[sign - copy] = '=';
} else {
//2 items specified (no space nor = between n2 and n3
//assume that they posted: property value
//Try to determine the section.
Section* sec=control->GetSectionFromProperty(copy);
if(!sec){
if(control->GetSectionFromProperty(temp)) return; //Weird situation:ignore
WriteOut(MSG_Get("PROGRAM_CONFIG_PROPERTY_ERROR"),copy);
return;
} //Hack to allow config ems true
char buffer[1024];strcpy(buffer,copy);strcat(buffer,"=");strcat(buffer,temp);
sign = strchr(buffer,' ');
if(sign) buffer[sign - buffer] = '=';
strcpy(copy,sec->GetName());
temp = buffer;
}
}
/* Input processed. Now the real job starts
* copy contains the likely "sectionname"
* temp contains "property=value"
* the section is destroyed and a new input line is given to
* the configuration parser. Then the section is restarted.
*/
char* inputline = const_cast<char*>(temp);
Section* sec = 0;
sec = control->GetSection(copy);
if(!sec) { WriteOut(MSG_Get("PROGRAM_CONFIG_SECTION_ERROR"),copy);return;}
sec->ExecuteDestroy(false);
sec->HandleInputline(inputline);
sec->ExecuteInit(false);
return;
}
示例2: Run
//.........这里部分代码省略.........
// ' ' before a possible '=', split on the ' '
pvars.insert(++pvars.begin(),pvars[0].substr(spcpos+1));
pvars[0].erase(spcpos);
}
// check if the first parameter is a section or property
Section* sec = control->GetSection(pvars[0].c_str());
if (!sec) {
// not a section: little duplicate from above
Section* sec=control->GetSectionFromProperty(pvars[0].c_str());
if (sec) pvars.insert(pvars.begin(),std::string(sec->GetName()));
else {
WriteOut(MSG_Get("PROGRAM_CONFIG_PROPERTY_ERROR"));
return;
}
} else {
// first of pvars is most likely a section, but could still be gus
// have a look at the second parameter
if (pvars.size() < 2) {
WriteOut(MSG_Get("PROGRAM_CONFIG_SET_SYNTAX"));
return;
}
std::string::size_type spcpos2 = pvars[1].find_first_of(' ');
std::string::size_type equpos2 = pvars[1].find_first_of('=');
if ((equpos2 != std::string::npos) &&
((spcpos2 == std::string::npos) || (equpos2 < spcpos2))) {
// split on the =
pvars.insert(pvars.begin()+2,pvars[1].substr(equpos2+1));
pvars[1].erase(equpos2);
} else if ((spcpos2 != std::string::npos) &&
((equpos2 == std::string::npos) || (spcpos2 < equpos2))) {
// split on the ' '
pvars.insert(pvars.begin()+2,pvars[1].substr(spcpos2+1));
pvars[1].erase(spcpos2);
}
// is this a property?
Section* sec2 = control->GetSectionFromProperty(pvars[1].c_str());
if (!sec2) {
// not a property,
Section* sec3 = control->GetSectionFromProperty(pvars[0].c_str());
if (sec3) {
// section and property name are identical
pvars.insert(pvars.begin(),pvars[0]);
} // else has been checked above already
}
}
}
if(pvars.size() < 3) {
WriteOut(MSG_Get("PROGRAM_CONFIG_SET_SYNTAX"));
return;
}
// check if the property actually exists in the section
Section* sec2 = control->GetSectionFromProperty(pvars[1].c_str());
if (!sec2) {
WriteOut(MSG_Get("PROGRAM_CONFIG_NO_PROPERTY"),
pvars[1].c_str(),pvars[0].c_str());
return;
}
// Input has been parsed (pvar[0]=section, [1]=property, [2]=value)
// now execute
Section* tsec = control->GetSection(pvars[0]);
std::string value;
value += pvars[2];
for(Bitu i = 3; i < pvars.size(); i++) value += (std::string(" ") + pvars[i]);
std::string inputline = pvars[1] + "=" + value;
tsec->ExecuteDestroy(false);
bool change_success = tsec->HandleInputline(inputline.c_str());
if (!change_success) WriteOut(MSG_Get("PROGRAM_CONFIG_VALUE_ERROR"),
value.c_str(),pvars[1].c_str());
tsec->ExecuteInit(false);
return;
}
case P_WRITELANG: case P_WRITELANG2:
// In secure mode don't allow a new languagefile to be created
// Who knows which kind of file we would overwrite.
if (securemode_check()) return;
if (pvars.size() < 1) {
WriteOut(MSG_Get("PROGRAM_CONFIG_MISSINGPARAM"));
return;
}
if (!MSG_Write(pvars[0].c_str())) {
WriteOut(MSG_Get("PROGRAM_CONFIG_FILE_ERROR"),pvars[0].c_str());
return;
}
break;
case P_SECURE:
// Code for switching to secure mode
control->SwitchToSecureMode();
WriteOut(MSG_Get("PROGRAM_CONFIG_SECURE_ON"));
return;
default:
E_Exit("bug");
break;
}
first = false;
}
return;
}