ForestHub SDK 0.1.0
C++14 LLM SDK for PC and embedded platforms
Loading...
Searching...
No Matches
foresthub::platform::ConsoleInterface Class Referenceabstract

Abstract interface for console I/O. More...

#include <console.hpp>

Public Member Functions

virtual void Begin ()=0
 Initialize the console for I/O operations.
virtual bool Available () const noexcept=0
 Check if input data is available for reading.
virtual char Read ()=0
 Read a single character.
virtual std::string ReadLine (size_t max_length=256, unsigned long timeout_ms=0, bool echo=true)=0
 Read a line of input with optional timeout.
virtual Optional< std::string > TryReadLine (size_t max_length=256, bool echo=true)=0
 Try to read a line without blocking.
virtual void ClearLineBuffer ()=0
 Clear the internal line buffer, discarding any partially typed input.
virtual void Write (const std::string &data)=0
 Write a string to the console.
virtual void Printf (const char *format,...)=0
 Formatted output (printf-style).
virtual void Flush () noexcept=0
 Flush the output buffer (ensure all pending output is transmitted).

Detailed Description

Abstract interface for console I/O.

Provides character and line-based input/output for user interaction. Platform implementations handle the underlying I/O transport.

Member Function Documentation

◆ Available()

virtual bool foresthub::platform::ConsoleInterface::Available ( ) const
pure virtualnoexcept

Check if input data is available for reading.

Returns
true if at least one character can be read without blocking.

◆ Begin()

virtual void foresthub::platform::ConsoleInterface::Begin ( )
pure virtual

Initialize the console for I/O operations.

Communication speed is configured at construction time via PlatformConfig.

◆ Printf()

virtual void foresthub::platform::ConsoleInterface::Printf ( const char * format,
... )
pure virtual

Formatted output (printf-style).

Parameters
formatPrintf-style format string.
...Variable arguments matching format specifiers.

◆ Read()

virtual char foresthub::platform::ConsoleInterface::Read ( )
pure virtual

Read a single character.

Behavior when no data available is implementation-defined (may block or return -1).

Returns
The character read, or -1 if no data is available (implementation-defined).

◆ ReadLine()

virtual std::string foresthub::platform::ConsoleInterface::ReadLine ( size_t max_length = 256,
unsigned long timeout_ms = 0,
bool echo = true )
pure virtual

Read a line of input with optional timeout.

Parameters
max_lengthMaximum characters to accept (0 = implementation-defined limit).
timeout_msTimeout in milliseconds (0 = wait indefinitely).
echoIf true, echo characters back to output.
Returns
The line read (without line ending), or empty string on timeout.

◆ TryReadLine()

virtual Optional< std::string > foresthub::platform::ConsoleInterface::TryReadLine ( size_t max_length = 256,
bool echo = true )
pure virtual

Try to read a line without blocking.

Characters are accumulated in an internal buffer across calls. Returns the complete line when Enter is pressed, or empty Optional if no complete line yet.

Parameters
max_lengthMaximum characters to accept (0 = implementation-defined limit).
echoIf true, echo characters back to output.

The documentation for this class was generated from the following file: