Numworks Epsilon  1.4.1
Graphing Calculator Operating System
event_parser.cpp
Go to the documentation of this file.
1 /* This tools read human-readable events on stdin and outputs machine-readable
2  * ones on stdout. */
3 
4 #include <iostream>
5 #include <cassert>
6 #include <ion/events.h>
7 
8 using namespace Ion::Events;
9 
10 int eventIndexFromName(std::string name) {
11  for (int i=0; i<255; i++) {
12  Event e(i);
13  if (e.name() != nullptr && std::string(e.name()) == name) {
14  return i;
15  }
16  }
17  return -1;
18 }
19 
20 int main(int argc, char * argv[]) {
21  std::string eventName;
22  while (std::getline(std::cin, eventName)) {
23  int eventIndex = eventIndexFromName(eventName);
24  if (eventIndex < 0) {
25  std::cerr << "Error: Could not recognize event \"" << eventName << "\"" << std::endl;
26  return -1;
27  }
28  std::cout << (unsigned char)eventIndex;
29  }
30 }
int eventIndexFromName(std::string name)
int main(int argc, char *argv[])