hstring

hstring

Synopsis

hstring is a simple "one header" C++ string class which extends the STL std::string class with some usable methods.

The ultimate goal is to make string work as easy in C++ as it is in Python, but until that goal is reached (lets call that version hstring3000) it should just be generally useful for C++ projects.

Reason for existence

In every C++ project that i have worked on, i always end up extending std::string in some way - or adding utility functions to provide some common string operations. Most notably this is printf-like functionality and the common strip/split/join stuff as in Python's string class.

This just won't do, re-use is king!, so i hope to be able to use this class in all the C++ projects i work one - and hopefully some of you will to.

Design principles

  • Require STL and only STL, hstring must only depend on the C and C++ standard libraries, in other words: no Boost.

  • Ease of use over performance, some of it is very inefficiently coded - improvements are welcome as long as it doesn't degrade the interface or makes the code unreadable.

  • No linking or other .cpp code should be required, as long as it is possible hstring should be a "single header, and only a header" project.

License

It is released under the BSD license, so it is usable in commercial projects as well.

Documentation

Doxygen generated documentation available here, hopefully up to date, otherwise the included CMakeFiles.txt can build it for you.

Code / Download

There is no official release, but there may be some time in the distant future, for now the code is available through Bazaar from this place:

http://dev.infonet.dk/~rto/bzr/hstring/ (browse)

TODO

Things that would be nice to include:

  • Some way to make aligning of formatted values possible, ala. printf's %.10i format.

  • The standard definition of whitespace characters should really be handled by a static const, but so far i have not been able to find a way to define a static const std::string or char* without having to define the value of it in a .cpp file - and that kinda defeats one of the design principles. Suggestions are welcome!