Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Input / Output System

Classes

class  elm::io::BlockInStream
 
class  elm::io::BlockOutStream
 
class  elm::io::InFileStream
 
class  elm::io::Input
 
class  elm::io::InStream
 
class  elm::io::IOException
 
class  elm::io::Output
 
class  elm::io::IntFormat
 
class  elm::io::OutStream
 
class  elm::io::StreamPipe
 

Functions

io::Output elm::cout (io::out)
 
io::Output elm::cerr (io::err)
 
IntFormat elm::io::base (int base, IntFormat fmt)
 
IntFormat elm::io::bin (IntFormat fmt)
 
IntFormat elm::io::hex (IntFormat fmt)
 
IntFormat elm::io::width (int width, IntFormat fmt)
 
IntFormat elm::io::align (alignment_t align, IntFormat fmt)
 
IntFormat elm::io::left (IntFormat fmt)
 
IntFormat elm::io::right (IntFormat fmt)
 
IntFormat elm::io::center (IntFormat fmt)
 
IntFormat elm::io::pad (char pad, IntFormat fmt)
 
IntFormat elm::io::uppercase (IntFormat fmt)
 
IntFormat elm::io::lowercase (IntFormat fmt)
 

Variables

io::Input elm::cin
 
io::Output elm::cout
 
io::Output elm::cerr
 
sys::SystemInStream & elm::io::in = sys::stdin_object
 
sys::SystemOutStream & elm::io::out = sys::stdout_object
 
sys::SystemOutStream & elm::io::err = sys::stderr_object
 

Detailed Description

The input/output of ELM is a merge of the C++ standard library system and of the Java standard library. From the former, it uses the "<<" and ">>" operators overload. From the latter, it implements the two IO access: low-level classes manage streams of bytes and the high-level provides formatting facilities.

High-Level Input / Output

This level provides formatted input/output as in C++ standard library, that is, through the "<<" and ">>" operators. The formatted output class is Output and the formatted input class is Input.

Three global variables give access to the standard input/output:

Most basic types are supported (including String and CString). Some constants are provided for special output:

Unlike the C++ standard library, the output format is managed thrugh special formatting objects. For integer, the work is performed by IntFormat that provides display features like representation base, field width, alignment, uppercase letters for base greater than 10, signess, padding. For float values, it exists the class FloatFormat.

The errors are managed here using exception objects derivated from the IOException class.

Formatting

The class IntFormat embeds the value of an integer and its format configuration. Such is usually passed to Output object and is built from a list of usual inline functions (described below):

void *p;

The basic to display a formatted integer is to use a constructor inline function as io::f(). This builds an IntFormat object to display the passed integer. The format can then be modified by calling specific functions as listed below:

One way to implement the pointer of the above example is to define an inline function as this:

inline IntFormat pointer(void *p) {
return io::f(t::uint64(p)).width(16).pad('0').right().hex();
}

Notice the function io::f() that is a shortcut to create an IntFormat object.

Another way to define this format is to declare an IntFormat variable and to benefit from the overlaod of operator() of this class to pass the actual value to the format:

IntFormat pointer = IntFormat().width(16).pad('0').right().hex();

Byte Streams

The low-level IO system is only responsible for exchanging streams of bytes.

All input streams must inherit from the InStream class and defines the following functions:

The errors are returned by the called functions. Either a positive value, or a value of InStream::FAILED (error on the media), or InStream::ENDED (end of the media reached). Information about the errors may be obtained by the lastErrorMessage() method.

All output streams must inherit from the OutStream class and defines the following functions:

The errors are returned as negative value by this functions. Information about the errors may be obtained by the lastErrorMessage() method.

Function Documentation

IntFormat elm::io::align ( alignment_t  align,
IntFormat  fmt 
)

Used the given alignment to display the integer in its field.

Parameters
alignAlignment.
fmtDisplayed integer.
Deprecated:

References elm::io::IntFormat::align().

Referenced by elm::log::Debug::debugPrefix().

IntFormat elm::io::base ( int  base,
IntFormat  fmt 
)

Format an integer with the given base.

Parameters
baseNumeric base.
fmtDisplayed integer.
Deprecated:

References elm::io::IntFormat::base().

Referenced by elm::io::Input::scanULLong(), and elm::io::Input::scanULong().

IntFormat elm::io::bin ( IntFormat  fmt)

Used a binary base to display an integer.

Parameters
fmtDisplayed integer.
Deprecated:

References elm::io::IntFormat::bin().

IntFormat elm::io::center ( IntFormat  fmt)

Center the integer in its field.

Parameters
fmtDisplayed integer.
Deprecated:

References elm::io::IntFormat::center().

io::Output elm::cerr ( io::err  )

Standard error output.

io::Output elm::cout ( io::out  )

Standard output.

IntFormat elm::io::hex ( IntFormat  fmt)
IntFormat elm::io::left ( IntFormat  fmt)
IntFormat elm::io::lowercase ( IntFormat  fmt)

Select lowercase characters for digits bigger than 10.

Parameters
fmtDisplayed integer.
Deprecated:

References elm::io::IntFormat::lower().

IntFormat elm::io::pad ( char  pad,
IntFormat  fmt 
)

Select the padding character.

Parameters
padPadding character.
fmtDisplayed integer.
Deprecated:

References elm::io::IntFormat::pad().

Referenced by elm::checksum::MD5::print().

IntFormat elm::io::uppercase ( IntFormat  fmt)

Select uppercase characters for digits bigger than 10.

Parameters
fmtDisplayed integer.
Deprecated:

References elm::io::IntFormat::upper().

IntFormat elm::io::width ( int  width,
IntFormat  fmt 
)

Select the width of field where the integer will be displayed to.

Parameters
widthField width.
fmtDisplayed integer.
Deprecated:

References elm::io::IntFormat::width().

Referenced by elm::log::Debug::debugPrefix(), and elm::checksum::MD5::print().

Variable Documentation

io::Input elm::cin

Formatted input.

sys::SystemOutStream & elm::io::err = sys::stderr_object

Standard error stream.

Referenced by elm::sys::ProcessBuilder::run(), and elm::io::WinOutStream::write().