Shared String Library |
Shared String LibraryAn implementation of shared strings in C++. AuthorDavid C. Haley (david at the-haleys dot com) Release Date2006-mar-04 Version0.9e (PREVIEW) Summary
Compiling the libraryInstructions for Unix and Windows environments. Assumes that you have access to:
Under UnixIn the directory -build_unix- there is a Makefile to build both the library and the test files. It should be sufficient to type: cd build_unix This will compile everything and put the library into -lib- and the test program into -bin-. If you -make clean- after installing, it will clean up the compiled files but will not uninstall the library and test program. Note: The ‘make install’ isn’t what you might expect from a make install. Normally such a process would put the library into e.g. -/usr/local/lib-. But since the majority of target users of this library will not have root access, I made the install process go to a more convenient location. Under WindowsIn the directory -build_win32- you will find a Visual Studio 7 project file. You should be able to open that and select ‘Build | Build Solution’ to compile the library. This will create files ‘sharedstr_win32.lib’ and ‘test-sharedstr.exe’ in the -debug- subdirectory of -build_win32-. You should then copy the library wherever you want e.g. into the -lib- directory. Using the libraryCovers usage and linking of the library. Using the library in your programUsing the library is fairly simple. The basic idea behind the library is that shared string templates are defined using a manager wrapper, and then you use this template definition as your shared string. There is very little for you to do: you only need to call a macro before -typedef-’ing the shared string.
// (in a .h file somewhere)
// (in a .cpp file somewhere)
// (at the global scope)
Linking the library into your projectConsult your compiler’s documentation for more detailed information on how to do this. Here are some brief instructions, but for examples you can look at the makefile or project file for the test code.
At the link phase of your compilation, add the following; -L[dir]/lib -lsharedstr where [dir] is wherever you put the shared string library. The -L command tells g++ where to find the library, and -lsharedstr tells g++ to add the sharedstr library (libsharedstr.a).
Under the project properties, go to the link step and add the library you compiled to the ‘input’ box. Also make sure that the directory it’s in is on the library input path: you can do this in the link step as well, or set it to your global Visual Studio settings under ‘Tools | Options | Projects | VC++ Directories | Library Files’. Design NotesTo do ... For a preview, go through this forum post; http://www.gammon.com.au- /forum- /bbshowpost.php?bbsubject_id=5237 That’s where the project was born and initially discussed. Maybe some of the reasons for my choices will become clear there, but probably not... :-) Known Issues
|