The uSTL LibraryuSTL library overview
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);
Using uSTL in eCos applications
To build an eCos library with uSTL support, you can start from the
default template and then add the uSTL package
CYGPKG_USTL. If you need file streams support or would like
to build all uSTL tests, then you must also add the File I/O package
CYGPKG_IO_FILEIO.
To use uSTL in your eCos application, simply include the file
<ustl.h>. All uSTL classes are in the
ustl namespace. To prevent compiler warnings
when compiling your eCos application with uSTL support, you need to
add the compiler flag .
#include <ustl.h>
using namespace ustl;
int main (int argc, char* argv[])
{
cout << "Hello world!\n";
return EXIT_SUCCESS;
}
If you use cout for printing to the console,
then data will get sent only if you finish the output with
endl or '\n'.
The uSTL library is subject of copyright under MIT license. For
the license text see LICENSE file.