Rishka
RISC-V virtual runtime in C/C++ made for ESP32-WROVER
IO Class Referencefinal

Class for handling input/output operations in Rishka applications. More...

#include <io.h>

Static Public Member Functions

static void print (const string text)
 Print text to the output stream. More...
 
static void print (const string text, const string fg, const string bg=TERM_BG_BLACK, const string style=TERM_STYLE_NORMAL)
 Print text to the output stream. More...
 
static void println (const string text)
 Print text to the output stream. More...
 
static void print (i64 number)
 Print an integer number to the output stream. More...
 
static void println (i64 number)
 Print an integer number to the output stream. More...
 
static void print (u64 number)
 Print an unsigned number to the output stream. More...
 
static void println (u64 number)
 Print an unsigned number to the output stream. More...
 
static void print (double number)
 Print a floating-point number to the output stream. More...
 
static void println (double number)
 Print a floating-point number to the output stream. More...
 
static void println ()
 Prints a new line to the output stream. More...
 
static bool printf (string format,...)
 Prints formatted output. More...
 
static i32 available ()
 Check if there is data available to read from the input stream. More...
 
static i32 peek ()
 Peek at the next character in the input stream. More...
 
static bool find (string target, usize size)
 Search for a target string in the input stream. More...
 
static bool find_until (string target, string terminator)
 Search for a target string in the input stream until a terminator is encountered. More...
 
static void set_timeout (u64 timeout)
 Set the timeout for input operations. More...
 
static u64 get_timeout ()
 Get the current timeout for input operations. More...
 
static rune readch ()
 Read a Unicode character from the input stream. More...
 
static string readline ()
 Read a line of text from the input stream. More...
 

Detailed Description

Class for handling input/output operations in Rishka applications.

The IO class provides static methods for performing input/output operations, such as printing text and numbers, reading input, searching for patterns, and setting timeouts for input operations on ESP32-WROVER microcontrollers.

Member Function Documentation

◆ available()

i32 IO::available ( )
static

Check if there is data available to read from the input stream.

This method checks if there is data available to read from the input stream.

Returns
The number of bytes available to read, or 0 if no data is available.

◆ find()

bool IO::find ( string  target,
usize  size 
)
static

Search for a target string in the input stream.

This method searches for the specified target string in the input stream.

Parameters
targetThe target string to search for.
sizeThe size of the target string.
Returns
True if the target string is found, false otherwise.

◆ find_until()

bool IO::find_until ( string  target,
string  terminator 
)
static

Search for a target string in the input stream until a terminator is encountered.

This method searches for the specified target string in the input stream until the specified terminator string is encountered.

Parameters
targetThe target string to search for.
terminatorThe terminator string.
Returns
True if the target string is found before the terminator, false otherwise.

◆ get_timeout()

u64 IO::get_timeout ( )
static

Get the current timeout for input operations.

This method returns the current timeout for input operations in microseconds.

Returns
The current timeout value in microseconds.

◆ peek()

i32 IO::peek ( )
static

Peek at the next character in the input stream.

This method peeks at the next character in the input stream without removing it.

Returns
The next character in the input stream, or -1 if no data is available.

◆ print() [1/5]

void IO::print ( const string  text)
static

Print text to the output stream.

This method prints the specified text to the output stream.

Parameters
textThe text to be printed.

◆ print() [2/5]

void IO::print ( const string  text,
const string  fg,
const string  bg = TERM_BG_BLACK,
const string  style = TERM_STYLE_NORMAL 
)
static

Print text to the output stream.

This method prints the specified text to the output stream with specified foreground color, background color, and style.

Parameters
textThe text to be printed.
fgForeground color of the output text.
bgBackground color of the output text.
styleStyle/format of the output.

◆ print() [3/5]

void IO::print ( double  number)
static

Print a floating-point number to the output stream.

This method prints the specified floating-point number to the output stream.

Parameters
numberThe floating-point number to be printed.

◆ print() [4/5]

void IO::print ( i64  number)
static

Print an integer number to the output stream.

This method prints the specified integer number to the output stream.

Parameters
numberThe integer number to be printed.

◆ print() [5/5]

void IO::print ( u64  number)
static

Print an unsigned number to the output stream.

This method prints the specified unsigned number to the output stream.

Parameters
numberThe unsigned number to be printed.

◆ printf()

bool IO::printf ( string  format,
  ... 
)
static

Prints formatted output.

This method prints formatted output to the standard output stream. It behaves similar to the printf function in C/C++, allowing developers to specify a format string and additional arguments for formatting.

Formatters:

  • {i} — Integer number value
  • {u} — Unsigned number value
  • {d} — Double or floating-point number
  • {s} — String value
Parameters
formatA string specifying the format of the output.
...Additional arguments to be formatted according to the format string.
Returns
True if the output operation is successful, false otherwise.

◆ println() [1/5]

void IO::println ( )
static

Prints a new line to the output stream.

THis method prints a new line to the current output stream.

◆ println() [2/5]

void IO::println ( const string  text)
static

Print text to the output stream.

This method prints the specified text to the output stream followed by a new line.

Parameters
textThe text to be printed.

◆ println() [3/5]

void IO::println ( double  number)
static

Print a floating-point number to the output stream.

This method prints the specified floating-point number to the output stream followed by a new line.

Parameters
numberThe floating-point number to be printed.

◆ println() [4/5]

void IO::println ( i64  number)
static

Print an integer number to the output stream.

This method prints the specified integer number to the output stream followed by a new line.

Parameters
numberThe integer number to be printed.

◆ println() [5/5]

void IO::println ( u64  number)
static

Print an unsigned number to the output stream.

This method prints the specified unsigned number to the output stream followed by a new line.

Parameters
numberThe unsigned number to be printed.

◆ readch()

rune IO::readch ( )
static

Read a Unicode character from the input stream.

This method reads a Unicode character from the input stream.

Returns
The Unicode character read from the input stream.

◆ readline()

string IO::readline ( )
static

Read a line of text from the input stream.

This method reads a line of text from the input stream.

Returns
The line of text read from the input stream.

◆ set_timeout()

void IO::set_timeout ( u64  timeout)
static

Set the timeout for input operations.

This method sets the timeout for input operations in microseconds.

Parameters
timeoutThe timeout value in microseconds.

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