Chapter 9. uSTL library overview

Table of Contents
eCos specific changes/enhancements
Using uSTL in eCos applications

The eCos uSTL library is a port of Mike Sharov's uSTL - a size-optimized STL implementation. It has the particular feature of generating small object code sizes - an important requirement for embedded eCos-based applications. The latest version can be found at http://sourceforge.net/projects/ustl.

The library provides a subset of the full C++ Standard Template Library. uSTL is a partial implementation of the STL specification intended to reduce code size of the derivative programs. This allows eCos applications to use well known standard C++ STL library containers, streams, iterators, algorithms and functors.

For changes, see the HISTORY file. A detailed introduction to the uSTL library is available on Mike Sharov's uSTL web page. Additional information on all the classes is available in the header files and in the Doxygen reference.

eCos specific changes/enhancements

All features of the uSTL library are available except for memory mapped files and memory mapped streams.

By default, an eCos image is build without exceptions and without RTTI support (compiler switches -fno-exceptions -fno-rtti). Normally the uSTL library relies on C++ exceptions to propagate errors and exceptions. To build uSTL for eCos, all occurrences of try, catch and throw are replaced by macros USTL_TRY, USTL_CATCH_ALL, and USTL_THROW. Thus the eCos uSTL port compiles without exceptions and without RTTI support but also works if RTTI and exceptions are enabled.

To handle and propagate uSTL exceptions when RTTI und C++ exceptions are not available, the eCos uSTL port was extended by some simple exception handling functions. An application can use the function ustl::set_app_exception_handler() to register an exception handler that is called by the USTL_THROW macro as soon as an exception is thrown by any uSTL function.

void ustl::set_app_exception_handler(app_exception_handler_t func);

If an exception handler is registered by an application then it replaces the default eCos uSTL exception handler. The default exception handler simply prints the error message of an exception to the diagnostic channel by calling void ustl::diag_print_exception(). This function can also be called from an application exception handler as illustrated in the test cases.

void ustl::set_app_exception_handler(app_exception_handler_t func);