本文整理汇总了C++中InputConfig::clear_all_events方法的典型用法代码示例。如果您正苦于以下问题:C++ InputConfig::clear_all_events方法的具体用法?C++ InputConfig::clear_all_events怎么用?C++ InputConfig::clear_all_events使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputConfig
的用法示例。
在下文中一共展示了InputConfig::clear_all_events方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
ParseInputFile(InputConfig &config, TLineReader &reader)
{
// TODO code - Safer sizes, strings etc - use C++ (can scanf restrict length?)
TCHAR *new_label = NULL;
// Init first entry
// Did we find some in the last loop...
bool some_data = false;
// Multiple modes (so large string)
TCHAR d_mode[1024] = _T("");
TCHAR d_type[256] = _T("");
TCHAR d_data[256] = _T("");
unsigned event_id = 0;
TCHAR d_label[256] = _T("");
int d_location = 0;
TCHAR d_event[256] = _T("");
TCHAR d_misc[256] = _T("");
int line = 0;
// Read from the file
// TODO code: What about \r - as in \r\n ?
// TODO code: Note that ^# does not allow # in key - might be required (probably not)
// Better way is to separate the check for # and the scanf
TCHAR *buffer;
while ((buffer = reader.read()) != NULL) {
TrimRight(buffer);
line++;
const TCHAR *key, *value;
// experimental: if the first line is "#CLEAR" then the whole default config is cleared
// and can be overwritten by file
if (line == 1 && _tcscmp(buffer, _T("#CLEAR")) == 0) {
config.clear_all_events();
} else if (buffer[0] == _T('\0')) {
// Check valid line? If not valid, assume next record (primative, but works ok!)
// General checks before continue...
if (some_data && (d_mode != NULL) && (_tcscmp(d_mode, _T("")) != 0)) {
TCHAR *token;
// For each mode
token = _tcstok(d_mode, _T(" "));
// General errors - these should be true
assert(d_location >= 0);
assert(d_location < 1024); // Scott arbitrary limit
assert(d_mode != NULL);
assert(d_type != NULL);
assert(d_label != NULL);
// These could indicate bad data - thus not an ASSERT (debug only)
// assert(_tcslen(d_mode) < 1024);
// assert(_tcslen(d_type) < 1024);
// assert(_tcslen(d_label) < 1024);
while (token != NULL) {
// All modes are valid at this point
int mode_id = config.make_mode(token);
assert(mode_id >= 0);
// Make label event
// TODO code: Consider Reuse existing entries...
if (d_location > 0) {
// Only copy this once per object - save string space
if (!new_label) {
new_label = StringMallocParse(d_label);
}
config.append_menu(mode_id, new_label, d_location, event_id);
}
// Make key (Keyboard input)
// key - Hardware key or keyboard
if (_tcscmp(d_type, _T("key")) == 0) {
// Get the int key (eg: APP1 vs 'a')
unsigned key = InputEvents::findKey(d_data);
if (key > 0)
config.Key2Event[mode_id][key] = event_id;
else
LogStartUp(_T("Invalid key data: %s at %i"), d_data, line);
// Make gce (Glide Computer Event)
// GCE - Glide Computer Event
} else if (_tcscmp(d_type, _T("gce")) == 0) {
// Get the int key (eg: APP1 vs 'a')
int key = InputEvents::findGCE(d_data);
if (key >= 0)
config.GC2Event[mode_id][key] = event_id;
else
LogStartUp(_T("Invalid GCE data: %s at %i"), d_data, line);
// Make ne (NMEA Event)
// NE - NMEA Event
} else if (_tcscmp(d_type, _T("ne")) == 0) {
//.........这里部分代码省略.........