Evo C++ Library v0.5.1
Public Types | Static Public Member Functions | Public Attributes | List of all members
ConsoleMT Struct Reference

#include <evo/iothread.h>

Detailed Description

Multithreaded console I/O.

Example
#include <evo/iothread.h>
using namespace evo;
static ConsoleMT& c = con_mt();
int main() {
// Thread safe console output
EVO_IO_MT(c.out, << "Hello World " << 123 << NL)
// Thread safe console output without macro
{ Mutex::Lock lock(c.out.mutex); c.out.stream << "Hello World " << 123 << NL; }
}

Public Types

typedef PipeOut::Format Format
 Stream output formatter with state. More...
 
typedef StreamExtMT< PipeIn, MutexInT
 Input type. More...
 
typedef Mutex::Lock Lock
 Mutex lock type. More...
 
typedef StreamExtMT< PipeOut, MutexOutT
 Output type. More...
 

Static Public Member Functions

static ConsoleMTget ()
 Get console instance to use. More...
 

Public Attributes

OutT err
 Write to console, error output. More...
 
InT in
 Read console input. More...
 
OutT out
 Write to console, normal output. More...
 

Member Typedef Documentation

◆ Format

Stream output formatter with state.

  • This is associated with a Stream object and supports stateful (i.e. sticky) output formatting with "<<" operator on this object
  • Formatting attributes include:
    • Aligned fields for formatting text "columns"
    • Integer base, prefix, and padding (in addition to field padding)
    • Floating point precision and padding (in additon to field padding)
    • String to use for "null" values (null char*, String, Int, etc)
  • Note: Single character (char) and Newline (NL) values are not formatted as fields (i.e. not padded) since they're usually delimiters
  • See: Stream Formatting
Examples

Example using File:

#include <evo/io.h>
using namespace evo;
int main() {
File file("file.txt", oWRITE_NEW);
// Use a temporary formatter to write line: 7B,1C8
File::Format(file) << fHEX << 123 << ',' << 456 << NL;
// Create a formatter and use to write line: 001,002
out << FmtSetInt(fDEC, 3) << 1 << ',' << 2 << NL;
return 0;
}

Example using Console (stdout):

#include <evo/io.h>
using namespace evo;
int main() {
Console& c = con();
// Use a temporary formatter to write line: 7B,1C8
Console::Format(c.out) << fHEX << 123 << ',' << 456 << NL;
// Create a formatter and use to write line: 001,002
out << FmtSetInt(fDEC, 3) << 1 << ',' << 2 << NL;
return 0;
}

For more examples see: Stream Formatting

◆ InT

Input type.

◆ Lock

typedef Mutex::Lock Lock

Mutex lock type.

◆ OutT

Output type.

Member Function Documentation

◆ get()

static ConsoleMT& get ( )
inlinestatic

Get console instance to use.

Returns
Console instance

Member Data Documentation

◆ err

OutT err

Write to console, error output.

◆ in

InT in

Read console input.

◆ out

OutT out

Write to console, normal output.


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