本文整理汇总了C++中Section_prop类的典型用法代码示例。如果您正苦于以下问题:C++ Section_prop类的具体用法?C++ Section_prop怎么用?C++ Section_prop使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Section_prop类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CMS
CMS(Section* configuration):Module_base(configuration) {
Section_prop * section = static_cast<Section_prop *>(configuration);
Bitu sample_rate_temp = section->Get_int("oplrate");
sample_rate = static_cast<double>(sample_rate_temp);
base_port = section->Get_hex("sbbase");
WriteHandler.Install(base_port, write_cms, IO_MB,4);
// A standalone Gameblaster has a magic chip on it which is
// sometimes used for detection.
const char * sbtype=section->Get_string("sbtype");
if (!strcasecmp(sbtype,"gb")) {
DetWriteHandler.Install(base_port+4,write_cms_detect,IO_MB,12);
DetReadHandler.Install(base_port,read_cms_detect,IO_MB,16);
}
/* Register the Mixer CallBack */
cms_chan = MixerChan.Install(CMS_CallBack,sample_rate_temp,"CMS");
last_command = PIC_Ticks;
for (int s=0;s<2;s++) {
struct SAA1099 *saa = &saa1099[s];
memset(saa, 0, sizeof(struct SAA1099));
}
}
示例2: MENU_Check_Drive
void MENU_Check_Drive(HMENU handle, int cdrom, int floppy, int local, int image, int automount, int umount, char drive) {
#if !defined(HX_DOS)
std::string full_drive(1, drive);
Section_prop * sec = static_cast<Section_prop *>(control->GetSection("dos"));
full_drive += ":\\";
EnableMenuItem(handle, cdrom, (Drives[drive - 'A'] || menu.boot) ? MF_GRAYED : MF_ENABLED);
EnableMenuItem(handle, floppy, (Drives[drive - 'A'] || menu.boot) ? MF_GRAYED : MF_ENABLED);
EnableMenuItem(handle, local, (Drives[drive - 'A'] || menu.boot) ? MF_GRAYED : MF_ENABLED);
EnableMenuItem(handle, image, (Drives[drive - 'A'] || menu.boot) ? MF_GRAYED : MF_ENABLED);
if(sec) EnableMenuItem(handle, automount, AUTOMOUNT(full_drive.c_str(), drive) && !menu.boot && sec->Get_bool("automount") ? MF_ENABLED : MF_GRAYED);
EnableMenuItem(handle, umount, (!Drives[drive - 'A']) || menu.boot ? MF_GRAYED : MF_ENABLED);
#endif
}
示例3: FIRMWARE_Init
/*
* Initialize config file settings
*/
void FIRMWARE_Init(void)
{
char **list;
std::string config_path, rc_file;
Section_prop *secprop;
Section_line *secline;
Prop_int *Pint;
Prop_hex *Phex;
Prop_string *Pstring;
Prop_bool *Pbool;
Prop_multival *Pmulti;
Prop_multival_remain *Pmulti_remain;
/* Configuration file directory */
Cross::GetPlatformConfigDir(config_path);
// Create list of supported firmware systems
list = initFirmwareList();
// Setup firmware config file options
secprop=control->AddSection_prop("firmware", &FIRMWARE_Config);
// System type to use
Pstring = secprop->Add_string("system", Property::Changeable::OnlyAtStart, list[0]);
Pstring->Set_values(list);
Pstring->Set_help("Select the firmware to use.");
// System configuration file
rc_file = config_path + "sys.rc";
Pstring = secprop->Add_path("sysrc", Property::Changeable::OnlyAtStart, rc_file.c_str());
Pstring->Set_help("Path to the system configuration file.");
// Boot rc file
rc_file = config_path + "boot.rc";
Pstring = secprop->Add_path("bootrc", Property::Changeable::OnlyAtStart, rc_file.c_str());
Pstring->Set_help("Path to the boot configuration file.");
}
示例4: fprintf
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;
}
示例5: while
//.........这里部分代码省略.........
// if it's a section, leave it as one-param
Section* sec = control->GetSection(pvars[0].c_str());
if (!sec) {
// could be a property
sec = control->GetSectionFromProperty(pvars[0].c_str());
if (!sec) {
WriteOut(MSG_Get("PROGRAM_CONFIG_PROPERTY_ERROR"));
return;
}
pvars.insert(pvars.begin(),std::string(sec->GetName()));
}
break;
}
case 2: {
// sanity check
Section* sec = control->GetSection(pvars[0].c_str());
Section* sec2 = control->GetSectionFromProperty(pvars[1].c_str());
if (sec != sec2) {
WriteOut(MSG_Get("PROGRAM_CONFIG_PROPERTY_ERROR"));
}
break;
}
default:
WriteOut(MSG_Get("PROGRAM_CONFIG_USAGE"));
return;
}
// if we have one value in pvars, it's a section
// two values are section + property
Section* sec = control->GetSection(pvars[0].c_str());
if (sec==NULL) {
WriteOut(MSG_Get("PROGRAM_CONFIG_PROPERTY_ERROR"));
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();
示例6: Section_prop
Section_prop* Config::AddSection_prop(char const * const _name,void (*_initfunction)(Section*),bool canchange){
Section_prop* blah = new Section_prop(_name);
blah->AddInitFunction(_initfunction,canchange);
sectionlist.push_back(blah);
return blah;
}
示例7:
/*
* Get a property string
*/
const char *FIRMWARE::propString(const char *prop)
{
Section_prop *section = static_cast<Section_prop *>(m_configuration);
return section->Get_string(prop);
}
示例8: DISNEY_ShouldInit
bool DISNEY_ShouldInit() {
Section_prop *sec = (Section_prop*)control->GetSection("speaker");
return sec->Get_bool("disney");
}
示例9: MENU_SetBool
bool MENU_SetBool(std::string secname, std::string value) {
Section_prop * sec = static_cast<Section_prop *>(control->GetSection(secname));
if(sec) SetVal(secname, value, sec->Get_bool(value) ? "false" : "true");
return sec->Get_bool(value);
}