The Micro C++ Library
The Micro C++ Library Documentation

The Micro C++ library (libmicxx) is a small set of portable and easy to use classes providing core features commonly used in modern applications. It is based completely on the Standard C++ Template Library (STL).

The subversion repository hostet at Sourceforge.net can be checked out with the following instruction:

svn co https://libmicxx.svn.sourceforge.net/svnroot/libmicxx/trunk/libmicxx


Portability


The Micro C++ library will compile with and run on a variety of compiler / platform combinations. The following table shows the combinations which have already been tested:

Operating System Compiler

Configurations

32Bit
Windows x86 MS Visual C++ 2010 Express Edition [Release|Debug] Win32 (DLL)
Linux x86 GCC 4.2.3 or later [Release|Debug] [Shared|Static]
Solaris 10 x86 Sun C++ 5.9 (Sun Studio IDE 8.0) or later [Release|Debug] Static
Solaris 10 sparc Sun C++ 5.8 (Sun Studio IDE 7.4) or later [Release|Debug] Static
MinGW32 GCC 3.4.5 or later [Release|Debug] [Shared|Static]
Cygwin32 GCC 3.4.4 or later [Release|Debug] [Shared|Static]
64Bit
Windows x64 MS Visual C++ 2010 Express Edition [Release|Debug] x64 (DLL)
Linux x86_64 GCC 4.2.3 or later [Release|Debug] [Shared|Static]
Solaris 10 x86_64 Sun C++ 5.9 (Sun Studio IDE 8.0) [Release|Debug] Static
Solaris 10 sparc Sun C++ 5.8 (Sun Studio IDE 7.4) [Release|Debug] Static


Build Instructions


  1. Windows XP/Vista/7 (32Bit, 64Bit)

    Get a free copy of Microsoft Visual C++ 2010 Express Edition. Go to the vc subdirectory and either open

    • the provided project file libmicxx.vcxproj, or
    • the solution file libmicxx.sln

    There are build configurations provided for [Release|Debug] [Win32|x64] which build against the DLL versions of the Microsoft C/C++ runtime libraries.

    Note:
    If you want to build a static version of libmicxx add MICXX_STATIC to the C/C++ Preprocessor properties of the libmicxx project and your own projects which you want to build against a static library version.

    OpenSSL support
    If you want to build a Micro C++ library version with SSL socket support provided by OpenSSL, apply the following steps to the libmicxx project and your own projects that depend on libmicxx:

    1. From the View menu, open the Property Manager view
    2. Click on the project node libmicxx
    3. Click the button Add Existing Property Sheet
    4. From the File Open dialog box select the file OpenSSL.Cpp.props from the vc subdirectory.
    5. Double-click the added OpenSSL.Cpp property sheet and edit the VC++ Directories properties to point to your copies of the OpenSSL include and library directories.

    In addition to the list of the OpenSSL include and library directories, this property sheet defines MICXX_WITH_OPENSSL.

    The provided libmicxx.vcxproj file has this property sheet already setup.

  2. Eclipse C/C++

    Either import your workspace directory libmicxx as an "Existing Project into Workspace" or check out libmicxx from the Subversion (SVN) trunk location above.

    The provided Eclipse project already has the following two build configurations setup:

    • Release (Shared)
    • Debug (Static)

    Other build configurations could easily be added (see GNU configure).

  3. GNU configure (e.g. Linux, UNIX, Cygwin etc.)

    Briefly, the shell commands

    $ ./configure
    $ make
    $ make install

    should configure, build, and install this package (see INSTALL.txt for more details).

    The following is a subset of the more frequently used options for configure:

    --enable-debug
    --with-openssl=path

  4. SUN Solaris C++ Compiler from SUN Studio

    Currently only a static library archive version of libmicxx is supported for the SUN Solaris C++ Compiler. To build the release version, just call make like

    $ make -f Makefile.solaris [ all | clean ]

    The provided makefile is very limited. The default is to build a 64Bit static release version of the library.
    If you need to change the default, you have to edit the appropriate settings within the makefile.


Quick Start Guide


The following few steps will give you a short introduction on how to use Micro C++ library in your own projects.

  1. The micxx::System class

    Before core features of Micro C++ library could be used, the micxx::System class must be initialized. This is done by allocating a single instance that must not be deleted while Micro C++ library is still in use. The safest way to accomplish this is to keep a single instance within the scope of main(int,const char **) like:

     #include <micxx.hxx>
    
     int main(int argc, char ** args)
     {
         micxx::System system(argc, args);
         ...
     }
    

    After a micxx::System instance is instantiated, you could safely access things like micxx::System::getMutex(), system properties offered by micxx::System::getProperties(), the logging facility with its default configuration offered by micxx::Log (see Logging) etc.

    Note:
    You must not allocate more than one instance of micxx::System, although doing so would not cause any harm.
     
  2. System properties micxx::Properties

    are a simple set of keys/value pairs, which could either

    Because the system properties micxx::System::getProperties() are a statically shared instance they could be accessed very easily from almost anywhere within the code.

  3. Logging facility micxx::Log

    A very simple but flexible and easy to use logging facility is provided by micxx::Log. It supports four different logging categories:

    A default configuration, e.g. which of these categories are enabled and where the output is written to, is setup implicitly by micxx::System::System(int,const char*const*). That internally invokes micxx::Log::configure(System::getProperties()), which evaluates specific system properties, that e.g. could be passed on the command line, like

     -Dinfo=true
    

    To issue a log statement to the MICXX_INFO(expression) category, just call

     MICXX_INFO("BUILD ON " << __DATE__ << " " << __TIME__);
    

    The logging expression will only be emitted, if the MICXX_INFO(expression) category is enabled, otherwise the whole expression is completely ignored and won't consume any processing time.

    The debug category MICXX_DEBUG(level,expression) has an addition level argument, so that the logging expression will only be emitted, if the value for the debug.level system property is greater or equal to the intended debug level sepcified within the MICXX_DEBUG(level, expression) statement, e.g. in

     MICXX_DEBUG(MICXX_NORMAL, "BUILD ON " << __DATE__ << " " << __TIME__);
    

    the expression will only be emitted, if you pass

     -Ddebug=true [-Ddebug.level=1]
    

    on the command line. The following levels are already predefined:

    • MICXX_NORMAL is enabled, if the system property debug is true
    • MICXX_VERBOSE is enabled, if the system property debug is true and debug.level is greater 1
    • MICXX_TRACE is enabled, if the system property debug is true and debug.level is greater 2

  4. Sample application

    The following example is available as Sample.cxx

     #include <micxx.hxx>
     #include <iostream>
    
     int main(int argc, const char * args[])
     {
         try
         {
             __MICXXTRY__
             micxx::System system(argc, args);
    
             MICXX_DEBUG(MICXX_NORMAL, "8)");
             MICXX_DEBUG(MICXX_VERBOSE, "8))");
             MICXX_DEBUG(MICXX_TRACE, "8)))");
             MICXX_INFO(":)");
             MICXX_WARN(":|");
             MICXX_ERROR(":(");
             __MICXXEND__
         }
         catch (const micxx::Exception & exception)
         {
             std::cerr << exception << std::endl;
             return EXIT_FAILURE;
         }
         return EXIT_SUCCESS;
     }
    


Features


The following table is a summary of the main features provided by Micro C++ library:

Core Features
micxx::System Access to system properties, command line arguments, system time etc. System properties could be loaded from properties files using the same file format as specified by Java 2 Platform Standard Ed.
micxx::Strings Static string conversions and formatters.
micxx::Exception

A base exception class derived from std::exception that can store a location, a reason and a chain of causes (e.g. from the call hierarchy).

You also find macros to propagate the call heirarchy into a list of nested exception causes:

micxx::Log A simple but easy to use and flexible logging facility configured through specific system properties.
micxx::Buffer A simple generic Buffer that could dynamically grow or shrink. Together with micxx::Buffer you will also find methods to read or write integers in little or big endianess from or to a specific address:
micxx::StreamReader,
micxx::File
Resembles STL streams whereever possible, but may also use platform specifics that may be more suitable or that may also use different devices.
micxx::Filename A platform independent name for a file or directory within a filesystem.
micxx::URL incomplete
micxx::Throttle A micxx::Throttle could either be used to measure or to limit the througput per second. In case the extrapolation of the current throughtput is to high, calls to micxx::Throttle::next() get temporarily suspended, so that the overall throughput per second will stay below the configured maximum throughput.
 micxx::Throttle throttle(1000);
 while (true)
 {
     throttle.next();
     // do something no more that 1000 times per second...
 }
micxx::Wildcard Implementation of UN*X wildcards. Supported wild-characters are *, ?, sets like [a-z] and negation within sets [!abc]
micxx::XMLFormatter The micxx::XMLFormatter provides very simple XML formatting capabilities by implementing the micxx::traits::Formatter interface. The micxx::traits::Formatter class defines an interface to emit potentially nested content.
Multi-Threading Support
micxx::Mutex,
micxx::Condition,
micxx::Semaphore
Basic synchronization objects to protect critical code sections.
micxx::Thread Represents a single thread of execution.
micxx::PCQueue A very powerful Producer-/Consumer-Queue used to exchange data and synchronize between different threads of execution.
Networking Support
micxx::SocketAddress, micxx::InetAddress Generic and IP protocol specific network address abstractions.
micxx::Socket A generic end-point of a bi-directional communication link modeled after the Berkeley sockets API.
micxx::ServerSocket Represents a TCP server connection end-point that is used to listen for and to accept TCP client connections.
micxx::StreamSocket Represents a TCP client connection end-point that is used to connect to listening TCP server connections
micxx::DatagramSocket Represents a UDP packet oriented connection less communication end-point
micxx::MulticastSocket Represents an IP Multicast packet oriented connection less communication end-point that is used to join and to leave specific multicast addresses
SSL Socket support
Requires a SSL implemenation (like OpenSSL) and must be enabled explicitly by defining the pre-processor variable MICXX_WITH_OPENSSL (see Build Instructions).
micxx::SSLProtocol Socket based SSL protocol implementation exposed as a micxx::traits::BiDiConnection.
micxx::SSLClientSocket, micxx::SSLServerSocket The SSL equivalents of micxx::ClientSocket and micxx::ServerSocket.
Protocol support
micxx::HTTPConnection Implementation of RFC2616 Hypertext Transfer Protocol -- HTTP/1.1
Requires the pre-processor variable MICXX_WITH_OPENSSL to be defined during build for HTTPs support (see Build Instructions).
incomplete
Author:
Norbert Klose (norbert.klose@web.de)
Date:
May, 2009
November, 2011