Open Lighting Architecture: Stdin Handling

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
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 <ola/io/StdinHandler.h>
  #include <iostream>
  class ExampleStdinHandler {
  public:
  ExampleStdinHandler()
  : m_stdin_handler(&m_ss,
  ola::NewCallback(this, &ExampleStdinHandler::Input)) {
  }
  void Run() { m_ss.Run(); }
  private:
  ola::io::SelectServer m_ss;
  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");
  ExampleStdinHandler handler;
  handler.Run();
  }
  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

  ss | The SelectServer to use
  callback | the callback to run when we get new data on stdin