本文整理汇总了C++中System::SetBoolOption方法的典型用法代码示例。如果您正苦于以下问题:C++ System::SetBoolOption方法的具体用法?C++ System::SetBoolOption怎么用?C++ System::SetBoolOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System::SetBoolOption方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char *argv[])
{
static struct option long_option[] =
{
{"debug", no_argument, NULL, 'd'},
{"source_start_sector", required_argument, NULL, 's'},
{"destination_start_sector", required_argument, NULL, 't'},
{"source_media_type", required_argument, NULL, 'r'},
{"destination_media_type", required_argument, NULL, 'w'},
{"source_file", required_argument, NULL, 'i'},
{"destination_file", required_argument, NULL, 'o'},
{"verbose", no_argument, NULL, 'v'},
{0, 0, 0, 0}
};
// now define some variables to store user options
unsigned int source_start_sector = 0;
unsigned int destination_start_sector = 0;
// We are ignorering the next two variables because we do not have
// physical disk handling code anyway.
// unsigned int source_media_type = 0;
// unsigned int destination_media_type = 0;
char *source_file = NULL;
char *destination_file = NULL;
int indexptr;
while(1) {
int done=0;
int retval = getopt_long (argc, argv, "ds:t:r:w:i:o:v", long_option, &indexptr);
// cout<<"retval = "<<retval<<endl;
switch (retval) {
case 'd': // this is for debug enable
cout<<"Enabling debug mode "<<endl;
System.SetBoolOption(DEBUG_OPTION); // enable debug mode.
break;
case 's':
cout<<"Source start sector :: "<<optarg<<endl;
source_start_sector = atoi(optarg);
break;
case 't':
cout<<"Destination start sector :: "<<optarg<<endl;
destination_start_sector = atoi(optarg);
break;
case 'r':
cout<<"[IGNORING]Source Media type :: "<<optarg<<endl;
break;
case 'w':
cout<<"[IGNORING]Destination Media type :: "<<optarg<<endl;
break;
case 'i':
cout<<"Source file :: "<<optarg<<endl;
source_file = optarg;
break;
case 'o':
cout<<"Destination file :: "<<optarg<<endl;
destination_file = optarg;
break;
case 'v':
cout<<"Enabling verbose mode"<<endl;
SetBoolOption (VERBOSE_OPTION); // enable verbose mode.
break;
case -1: // getopt_long function's job is over
cout<<"I have exhaused all my options"<<endl;
done = 1;
break;
case 0:
DEBUG("No reason why zero is returned here", FATAL);
break;
case '?': // show no mercy
DEBUG("Invalid option encountered",FATAL);
return -1;
default:
DEBUG("Unrecognized value from getopt_long", NOTE);
break;
}
if (done){
// let check if we have more options
int i;
for(i=optind; i<argc; i++){
cout<<"option "<<i<<" :: "<<argv[i]<<endl;
}
break;
}
}
}