STLSoft

From Wikipedia, the free encyclopedia


STLSoft Libraries
Image:Stlsoft.jpg
Latest release 1.9.44 / 1 June 2008
Written in C/C++
OS MS-Windows, Unix, partially Cross-platform
Genre STL extension, Facades
License BSD-form license
Website http://stlsoft.org/

STLSoft is a collection of open source C++ template libraries that extend the functionality of the Standard Template Library and provide facades that wrap operating-system and technology-specific APIs. STLSoft is licensed under a BSD-form license to allow it to be used with both open and closed source projects.

STLSoft can be characterized as being lightweight and having high portability, high performance, minimal coupling and high cohesion.[1]

STLSoft is not a framework. STLSoft components are meant to be used as building blocks for higher level components such as applications, classes, libraries and servers.

The libraries cover operating systems such as Microsoft Windows, Mac OS-X and Linux/Unix, several of which both in 32-bit and 64-bit versions and work with compilers such as Borland C++, CodePlay VectorC C/C++, Comeau C/C++, Digital Mars C/C++, GNU C, Intel C/C++, Metrowerks C/C++, SunPro C/C++, Visual C++ and Watcom C/C++.

Contents

[edit] History

Over the last half a decade or so,[2][3] Matthew Wilson has been developing the STLSoft open source C++ template libraries to support the creation of both free and commercial software. Many parts of the libraries are derived from proprietary Synesis Software code.[4] In 2008 Wilson still is the main author of the STLSoft libraries.[5]

[edit] Implementation

STLSoft is written in C++, but it also contains parts that can be used with C. The libraries use templates and rely on compile-time polymorphism. The STLSoft libraries are header-only: the library code is included in and compiled with the user's code. This makes installation and usage of the libraries relatively easy.

[edit] Projects and Libraries

STLSoft is organized in two ways:

  1. as projects, for example: COMSTL, PlatformSTL, UnixSTL and WinSTL
  2. as libraries, for example: File System Library, Performance Library, Synchronisation[6] Library

There are 12 projects and 25 libraries.

The main project is also called STLSoft and it contains most platform- and technology-independent code and code that helps to take care of compiler and standard library differences.

The biggest projects are COMSTL, UnixSTL and WinSTL. COMSTL provides utilities to work with the Component Object Model (COM) and provides STL-compatible sequence adapters over the COM enumeration and COM collection concepts. UNIXSTL and WinSTL provide operating-system and technology-specific components for Unix and Windows operating systems. These two projects have a number of structural conformant components, such as environment_variable, path and thread_mutex that are also placed in the PlatformSTL project that facilitates writing platform-agnostic code (see also subsection Techniques).

The other projects address additional technology-specific areas. ACESTL applies STL concepts to some components of the Adaptive Communication Environment (ACE) library. MFCSTL makes using the Microsoft Foundation Classes (MFC) more STL-like. RangeLib is the STLSoft implementation of the range concept. InetSTL, ATLSTL and WTLSTL are smaller projects that apply the STL concepts to Internet programming and to programming with the Active Template Library (ATL) and Windows Template Library (WTL).

[edit] Techniques

Many ideas and techniques that STLSoft uses are described in Imperfect C++[7] and in Extended STL, Volume 1.[8] One such technique is namespace aliasing. It is used to reduce the extent to which namespaces must be specified in the library code itself.[9][10] Other notable techniques are shims and type tunneling which are used to reduce coupling between and to increase cohesion within the library's coponents.[11][12]

With cross-platform libraries, common approaches to provide identical behavior across different platforms or technology areas are 1) to emulate functionality missing from some platforms and 2) to provide only functionality common to all platforms. STLSoft approaches cross-platform support as follows: where similar behavior across platforms is available, structural conformance is employed in its implementation, but where functionality is different structural conformance is avoided. Wilson names this the principle of intersecting conformance. Thus STLSoft provides a common interface for functionality that is available across platforms or technology areas and at the same time does not limit the functionality when programming for the native system only.[13][14]

(Note: address high performance here.)

[edit] Library contents

Projects:

  • ACESTL
  • ATLSTL
  • COMSTL
  • .netSTL
  • InetSTL
  • MFCSTL
  • PlatformSTL
  • RangeLib
  • STLSoft
  • UNIXSTL
  • WinSTL
  • WTLSTL

Libraries:

  • Collections Library
  • Containers Library
  • Conversion Library
  • DL Library
  • Error Library
  • File System Library
  • Functional Library
  • Iterators Library
  • Memory Library
  • Template Meta-programming Library
  • Performance Library
  • Properties Library
  • Security Library
  • Smart Pointers library
  • String Library
  • Synchronisation Library
  • System Library
  • Time Library
  • Utility Library
  • Windows Clipboard Library
  • Windows Control Panel Library
  • Windows Controls Library
  • Windows Registry Library
  • Windows Shell Library
  • Windows ToolHelp Library

[edit] Examples

The following example is adapted from [15]. The program reads and displays the directories present in the root directory whether the program is compiled on Unix or compiled on Windows. It uses the class readdir_sequence from STLSoft's cross-platform project PlatformSTL that adapts the Unix opendir/readdir API and the FindFirstFile/FindNextFile MS-Windows API to an iteratable sequence.

#include <platformstl/filesystem/readdir_sequence.hpp>
 
#include <algorithm>    // std::copy
#include <iterator>     // std::ostream_iterator
#include <iostream>     // std::cout, std::endl
#include <string>       // std::string
 
using platformstl::readdir_sequence;
 
int main()
{
   readdir_sequence dir( "/", readdir_sequence::directories );
 
   std::copy
   ( dir.begin()
   , dir.end()
   , std::ostream_iterator< std::string >( std::cout, "\n" )
   );
}

Using the GNU C compiler, the executable program can be build as follows with both Unix and MS-Windows:

g++ -Wall -I../stlsoft-1.9.42/include program.cpp -o program

Here it is assumed that the STLSoft library (release 1.9.42) is installed in a sibling directory of the directory that contains the program.

[edit] Criticisms

The documentation accompanying the STLSoft libraries consists of Doxygen generated reference documentation that includes a partially completed overview of the library contents and of the concepts, patterns, principles and techniques that it uses. In addition to this, the documentation contains circa twenty example programs that show how to use various components of the library, but that do not contain an explanation of the component's usage.[16] There is no user documentation with a tutorial or a thematic approach (Getting Started guide). The necessity to improve the documentation is recognized though.[17]

[edit] Platforms supported

Architecture--OS--Compiler / 32-bit, 64-bit / Unix, Linux, FreeBSD, Mac OS-X, Sun Solaris?, MS-Windows.

The compilers supported by the STLSoft libraries are:[18]

[edit] Projects that use STLSoft

[edit] See also

  • STL - Standard Template Library

[edit] Notes

  1. ^ STLSoft Documentation.
  2. ^ Wilson 2007, p.xxxiv
  3. ^ This indicates that STLSoft started around the year 2002. HISTORY.txt and other files in the root directory of the STLSoft distribution contain the comment: Created: 29th March 2002, whereas the file stlsoft/stlsoft.h contains: Created: 15th January 2002.
  4. ^ Wilson 2005, p.565.
  5. ^ STLSoft Website.
  6. ^ British English spelling is used as in synchronisation, tokeniser and initialiser.
  7. ^ Wilson 2005.
  8. ^ Wilson 2007.
  9. ^ Wilson 2007, p.xxxv.
  10. ^ C/C++ User's Journal 2003a.
  11. ^ C/C++ User's Journal 2003b.
  12. ^ STLSoft Documentation.
  13. ^ Wilson 2007.
  14. ^ STLSoft Documentation.
  15. ^ The C++ Source 2004, Listing 2.
  16. ^ STLSoft Documentation.
  17. ^ STLSoft newsgroup.
  18. ^ File STLSoft.h.

[edit] References

  • Wilson, Matthew (2005). Imperfect C++: Practical Solutions for Real-Life Programming. Addison-Wesley. ISBN 0-321-22877-4. 
  • Wilson, Matthew (2007). Extended STL, Volume 1: Collections and Iterators. Addison-Wesley. ISBN 0-321-30550-7. 

[edit] Further reading

[edit] External links