Open Lighting Architecture  Latest Git
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Files | Namespaces | Classes | Typedefs | Functions
Stdin Handling

Detailed Description

Standard Input Handling.

Code to read from stdin

Example
#include <ola/base/Init.h>
#include <ola/io/SelectServer.h>
#include <iostream>
public:
: m_stdin_handler(&m_ss,
ola::NewCallback(this, &ExampleStdinHandler::Input)) {
}
void Run() { m_ss.Run(); }
private:
ola::io::StdinHandler m_stdin_handler;
void Input(int c);
};
void ExampleStdinHandler::Input(int c) {
switch (c) {
case 'q':
m_ss.Terminate();
break;
default:
std::cout << "Got " << static_cast<char>(c) << " - " << c << std::endl;
break;
}
}
int main(int argc, char* argv[]) {
ola::AppInit(&argc, argv, "", "Example Stdin Handler");
handler.Run();
}
When ./stdin_handler is run, it will echo each key pressed except for q which will quit.
Collaboration diagram for Stdin Handling:

Files

file  StdinHandler.h
 The stdin handler.
 

Namespaces

 ola
 The namespace containing all OLA symbols.
 
 ola::io
 Classes for general I/O and event handling.
 

Classes

class  ola::io::StdinHandler
 

Typedefs

typedef ola::Callback1< void, int > ola::io::StdinHandler::InputCallback
 

Functions

 ola::io::StdinHandler::StdinHandler (SelectServerInterface *ss, InputCallback *callback)
 Handle data from stdin. More...
 

Function Documentation

ola::io::StdinHandler::StdinHandler ( SelectServerInterface ss,
InputCallback callback 
)
explicit

Handle data from stdin.

Parameters
ssThe SelectServer to use
callbackthe callback to run when we get new data on stdin