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

#include <evo/io.h>

Detailed Description

Console I/O.

Example
#include <evo/io.h>
using namespace evo;
static Console& c = con();
int main() {
// Newline (NL) flushes to console
c.out << "testing stdout " << 123 << NL;
c.err << "testing stderr " << 123 << NL;
// Need to FLUSH so prompt appears before input is read
c.out << "Type something: " << fFLUSH;
String str;
c.in.readline(str);
c.out << "You typed: " << str << NL;
return 0;
}

Public Types

typedef PipeOut::Format Format
 Stream output formatter with state. More...
 
typedef PipeIn InT
 Input type. More...
 
typedef PipeOut OutT
 Output type. More...
 

Static Public Member Functions

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

Public Attributes

PipeOut err
 Write to console, error output. More...
 
PipeIn in
 Read console input. More...
 
PipeOut 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

typedef PipeIn InT

Input type.

◆ OutT

typedef PipeOut OutT

Output type.

Member Function Documentation

◆ get()

static Console& get ( )
inlinestatic

Get console instance to use.

Returns
Console instance

Member Data Documentation

◆ err

PipeOut err

Write to console, error output.

◆ in

PipeIn in

Read console input.

◆ out

PipeOut out

Write to console, normal output.


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