flecxx

Cost-free expressiveness, flexibility and coherence in C++ client code.

Updated: 10th September 2008
 
 
SourceForge.net Logo
What is flecxx?
License
Download
Authors
Installing
Building
Portability and dependencies
Contact

Introduction

flecxx is a simple, efficient, 100% header-only, C++ library that enhances standard and popular third-party libraries by eliminating abstraction dissonance. A classic example of this phenomenon is the case where, in order to initialise an instance of std::fstream with a path name stored in an instance of std::string, a user is forced to invoke the c_str() method: there is dissonance between the unit of currency for string in the client code (std::string) and the string type required by the library (C-style string: char const*):

  std::string     path = . . .
  std::fstream    stm(path.c_str(), ...

flecxx eliminates abstraction dissonance, and does so without incurring costs in performance or coupling. Hence, we can write client code with maximum transparency and expressiveness:

  std::string             path = . . .
  flecxx::std::fstream    stm(path, ...

Because it uses shims to convert the argument's actual types to the underlying types required by the library functions being flecxxed, it means a large (and expandable) set of types may be applied. For example, all of the following statements are possible using flecxx:

  #include <flecxx/std/stdio/puts.hpp>

  using flecxx::std::puts;

  int main()
  {
    std::string               s1("a std::string");
    stlsoft::simple_string    s2("an stlsoft::simple_string");
    time_t                    t;
    struct tm const*          tm = ::localtime((::time(&t), &t));
  #if defined(PLATFORMSTL_OS_IS_UNIX)
    unixstl::readdir_sequence files(".", unixstl::readdir_sequence::files);
  #elif defined(PLATFORMSTL_OS_IS_WINDOWS)
    VARIANT                   var = . . . // some VARIANT value
    LSA_UNICODE_STRING        s3 = { 21, 21, L"an LSA_UNICODE_STRING" };
  #endif /* PLATFORMSTL_OS_IS_WINDOWS */

    puts(s1);
    puts(s2);
    puts(tm);

  #if defined(PLATFORMSTL_OS_IS_UNIX)
    puts("files in local directory:");
    { for(unixstl::readdir_sequence::const_iterator it = files.begin(); it != files.end(); ++it)
    {
      puts(*it);
    }}
  #elif defined(PLATFORMSTL_OS_IS_WINDOWS)
    puts(var);
    puts(s3);
  #endif /* PLATFORMSTL_OS_IS_WINDOWS */

    return 0;
  }

Consider how much code would need to be written to provide the same functionality without flecxx and you would see a large amount of abstraction dissonance in your client code.

flecxx currently introduces such flecxxibility to the C and C++ standard libraries, but this will be expanded to a much wider range of popular proprietary and open-source libraries in future versions.

License

flecxx is released under the simplified BSD license, which basically means its free for any use, but you can't claim it's yours.

Download

flecxx may be downloaded from the SourceForge flecxx project downloads page.

Dependent Libraries

flecxx depends on the STLSoft libraries (version 1.9.51, or later).

Authors

flecxx is written by Matthew Wilson. Matthew is an author and development consultant.

Installing flecxx

The distribution is in the form of a zip file, e.g. flecxx-0.2.4.zip which you should extract (recursively) to a location of your choice, e.g. c:\\opensrc\\flecxx\\0.2, or ~/opensrc/flecxx/0.2, and we recommend that you define the FLECXX environment variable to be this directory.

flecxx depends on one other project, STLSoft, which is also 100% header-only. If you wish to build the example and test programs included in the distribution using the makefiles supplied, you will need to have defined the STLSOFT environment variable to be the root directory of the STLSoft include files.

Building flecxx

flecxx is a 100% header-only library, and therefore there is nothing to build. However, if you want to build and run the example and test programs included in the distribution, you can use the makefile in the compiler-specific sub-directory of the build/ directory.

For example, to build the 64-bit example and test programs with Visual C++ version 9 (aka VC++ 2008), open a command-prompt (with the VC++ environment defined) in build/vc9_x86 and execute the command "nmake build". If you want to run the tests, you can instead (or as well) execute the command "nmake test".

Portability and Dependencies

flecxx is written in standard C++, and should be compilable with any modern C/C++ compiler that provides an implementation of the C & C++ standard libraries.

The implementation of flecxx is dependent on the following open-source libraries:

  • STLSoft, version 1.9.51, or later. STLSoft is used for compiler discrimination, detection of language feature support, contract programming primitives, and an implementation of the shared_ptr class template. STLSoft is a 100% header-only library, so there is no requirement to have STLSoft installed in order to use flecxx.

In addition, the following open-source libraries are required by one the test programs, and are bundled in with the flecxx distribution:

  • xTests, version 0.8.5, or later. xTests is a unit-/component-testing library.
  • shwild, version 0.9.18, or later. shwild is a pattern matching library.

Contact

The flecxx homepage is http://www.flecxx.org/.

The flecxx project is hosted on SourceForge. (Hence, flecxx.org resolves to http://flecxx.sourceforge.net/).

Your questions, criticisms, contributions and requests are welcome at:

News

20080907: flecxx 0.2.4 launched.
20080605: flecxx 0.2.3 launched.
20080602: flecxx 0.2.2 launched.
20080601: flecxx 0.2.1 launched.

* Availability of flecxx has been held up by the world of work, and by the preparation phase of the book Breaking Up The Monolith: Advanced C++ Design Without Compromise, which should be completed before end of Q4 2008. "Monolith" contains a chapter on flecxx, explaining both its motivation and its design & implementation.