本文整理汇总了C++中Keymap::SaveAsCppHeader方法的典型用法代码示例。如果您正苦于以下问题:C++ Keymap::SaveAsCppHeader方法的具体用法?C++ Keymap::SaveAsCppHeader怎么用?C++ Keymap::SaveAsCppHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Keymap
的用法示例。
在下文中一共展示了Keymap::SaveAsCppHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BApplication
//.........这里部分代码省略.........
mode = kCompile;
input = optarg;
break;
case 'h':
mode = kSaveHeader;
input = optarg;
break;
case 'H':
default:
mode = kUnspecified;
break;
}
}
if (argc > optind && input == NULL)
input = argv[optind];
BApplication* app = new BApplication("application/x-vnd.Haiku-keymap-cli");
Keymap keymap;
switch (mode) {
case kUnspecified:
usage();
break;
case kLoadBinary:
case kLoadText:
{
load_keymap(keymap, input, mode == kLoadText);
status_t status = keymap.SaveAsCurrent();
if (status != B_OK) {
fprintf(stderr, "%s: error when saving as current: %s",
sProgramName, strerror(status));
return 1;
}
printf("Key map loaded.\n");
break;
}
case kSaveText:
{
if (input == NULL) {
status_t status = keymap.SetToCurrent();
if (status != B_OK) {
fprintf(stderr, "%s: error while getting keymap: %s!\n",
sProgramName, keymap_error(status));
return 1;
}
} else
load_keymap(keymap, input, false);
if (output != NULL)
keymap.SaveAsSource(output);
else
keymap.SaveAsSource(stdout);
break;
}
case kRestore:
keymap.RestoreSystemDefault();
break;
case kCompile:
{
load_keymap(keymap, input, true);
if (output == NULL)
output = "keymap.out";
status_t status = keymap.Save(output);
if (status != B_OK) {
fprintf(stderr, "%s: error saving \"%s\": %s\n", sProgramName,
output, strerror(status));
return 1;
}
break;
}
case kSaveHeader:
{
load_keymap(keymap, input, true);
if (output == NULL)
output = "keymap.h";
status_t status = keymap.SaveAsCppHeader(output, input);
if (status != B_OK) {
fprintf(stderr, "%s: error saving \"%s\": %s\n", sProgramName,
output, strerror(status));
return 1;
}
break;
}
}
return 0;
}