SimpleLib

Lightweight C++ Class Library

SimpleLib is a simple but powerful set of C++ template classes designed to be easy to use, easy to read, cross platform compatible, efficient and totally free.

SimpleLib includes classes for strings, vectors, sorted vectors, associative maps (three implementations), linked lists, ring buffers, auto (smart) pointers, auto restore variables, object pools (two implementations), singletons and dynamic types. Stacks and queues are supported through appropriately named operations on the vector class.

Features

  • Easy to use - include one header file - no libraries to link against
  • Easy to read, remember and understand syntax
  • Flexible set of the most common structures/algorithms
  • Well tested
  • Lightweight
  • Efficient
  • Cross platform compatible
  • License and royalty free
  • autoexp.dat definitions for visualization of types in Visual Studio 2005/2008 debugger

Download

SimpleLib is available for download from GitHib - http://github.com/toptensoftware/SimpleLib.

This repository includes the core SimpleLib functionality and many other classes and utility functions (designed for use mainly under Windows). If you're just after the core functionality you just need the two files SimpleLib.h and SimpleLib.cpp.

Supported Platforms

SimpleLib has been known to work with the following compilers and platforms.

Since I primarily use Visual Studio 2008, this is the most supported environment. I just don't have time to test every change on every platform. If you find a problem let me know and I'll fix it.

  • Microsoft Visual Studio 2008 (x86 and x64)
  • Microsoft Visual Studio 2005 (x86 and x64)
  • Microsoft Visual Studio 2003 (x86)
  • Microsoft Visual C++ Express Edition (x86)
  • Microsoft Visual Studio 6.0
  • gcc 4.1.2 on Ubuntu Linux
  • gcc 4.0.1 on MacOS
  • gcc 3.4.4 on Cygwin

SimpleLib file includes SimpleTest.cpp that contains a fairly exhaustive set of unit tests that can be used to verify the compatibility of SimpleLib on other platforms. If you find SimpleLib works or almost works on a platform not mentioned above, please let me know and I'll update the list (and merge in required fixes if you send them...)

Known Issues

  • Unicode version of Format() doesn't work on gcc.
  • gcc requires str.sz() or static_cast<const char*>(str) when passing CString's to vararg functions such as printf, Format etc...
  • CLinkedList only supports a single chain element on Microsoft Visual Studio 6.0 due to lack of support for pointer to member template arguments.
  • CDynamic is not supported on Microsoft Visual Studio 6.0 due unsupported template functionality.
  • CThreadSafeRingBuffer requires a interlocked compare and exchange function and is currently only supported on with 32-bit Windows with the Microsoft Visual Studio 2005 compiler.
  • CList and CHashMap currently don't visualize properly in Visual Studio debugger.

Setting up SimpleLib

To use SimpleLib, simply place it in a local folder and configure your compiler's include path to point to that folder. Alternatively you can just place the SimpleLib files in the same directory as the project that is to use it.

SimpleLib is supplied as two files - SimpleLib.h and SimpleLib.cpp. SimpleLib.h contains the declaration of the supported classes while SimpleLib.cpp contains the implementation of those classes.

Once your compiler's include path is configured simply #include the SimpleLib header file and optionally add a using clause for the SimpleLib namespace:

#include <SimpleLib.h>
using namespace Simple;

That's it! Your now ready to start using SimpleLib.

(Note there is no need to add SimpleLib.cpp to your project - it's included at the end of SimpleLib.h).

Visualizing/Expanding SimpleLib types in Visual Studio's debugger

To improve browsing SimpleLib types in Visual Studio I've authored some autoexp.dat definitions. These are well worth installing as they make viewing SimpleLib's collections in the debugger much easier. To set this up, simply copy the definitions from the bottom of SimpleLib.h into autoexp.dat. See SimpleLib.h for more information.

Documentation

Most of the classes in SimpleLib are fairly self explanatory to use. Rather than provide detailed documentation of every method and parameter, I've just provided a verbal description of how to use each class with a few examples.

If there's something you can't figure out, don't understand or think needs better explanation, please Contact Me.

Licensing SimpleLib

SimpleLib maybe used on following terms and conditions:

  • SimpleLib is completely free for unrestricted use in any commercial, retail, freeware, shareware, open source or other software project.
  • SimpleLib is provided on an as-is basis, with no warranty to suitability or quality.
  • SimpleLib is provided with no support. Topten Software will usually provide some assistance in using SimpleLib but is not obliged to do so.
  • The source code for SimpleLib may not be redistributed in either its original or modified form. Projects using SimpleLib that are distributed with source code should refer to http://www.toptensoftware.com/simplelib as the original source for SimpleLib. This limitation will not apply in the case that Topten Software ceases to exist, or in the case that Topten Software grants written permission.
  • Copyright for SimpleLib remains with Topten Software, except for code contributed by other developers (which is clearly marked in the code base) where copyright remains with the respective contributors.
  • There is no need to acknowledge use of SimpleLib in applications that use it.

Thanks

Thanks to:

  • Nick Maher of GrofSoft for map implementation + gcc testing and fixes.
  • Paul Hsieh of A Zillion Monkeys for Super Fast Hash implementation.