Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
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();
}
Functions called during program startup.
The stdin handler.
[Example] NOLINT(whitespace/comments)
Definition stdin_handler.cpp:24
Definition StdinHandler.h:60
bool AppInit(int *argc, char *argv[], const string &first_line, const string &description)
Used to initialize a application. Installs the SEGV handler and initializes the random number generat...
Definition Init.cpp:221
The namespace containing all OLA symbols.
Definition Credentials.cpp:44
When ./stdin_handler is run, it will echo each key pressed except for q which will quit.

Files

file  StdinHandler.h
 The stdin handler.
 

Namespaces

namespace  ola
 The namespace containing all OLA symbols.
 

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.
 

Function Documentation

◆ StdinHandler()

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