This project is hosted at .
Last update: 9 Dec 2001. Latest version: 1.1
What is SXP?
Why XML Persistence, Anyway?
Platform & Performance
Download Latest Version
SXP Manual (not too formal)
Disclaimer and License
Credits & Contacts
SXP stands for Simple XML Persistence, and is a quick-and-dirty C++ library I threw together. It provides a simple (I hope) mechanism for enabling the objects in your application to persist themselves (i.e. read from and write to) to a XML file. It is built as a C++ wrapper around James Clark's excellent expat parser.
SXP's major selling points are:
If you are allergic towards industry buzzwords (like myself), you probably think XML is for consultants and "enterprise developers" (whatever that means), not for Real Programmers (like yourself). Still, I think XML is a Good Thing (TM), and is suitable not only for some multi-million dollar project with 5000 pages of design documents filled with UML and Booch notation, but also for the config files of your little pet project you're developing in your spare time, or for the document format of the application you're working on to in your [non-spare?!?] time. Here are a few reasons why I like XML:
SXP was developed on Win32 with Visual C++ 6.0 and tested with expat 1.95.1. It uses heavily STL for strings and collections. If you have expat and STL on your system, you should be able to compile and use SXP - but I haven't really tried it. There are reports of using expat on the Mac and on Linux.
SXP is meant for fast prototyping; it was easy to write, and it is easy to use. Its performance isn't what it would be if I didn't take the easy shortcut with STL strings and lists. If you decide to use SXP in a production-level application, you should probably rip off STL and replace it with your own custom string and list handling in static arrays. Quick profiling has shown that when handling large multimegabyte XML files SXP spends about 30% of its time in expat, 55-60% in the STL support routines and only 10-15% in the SXP code itself. Moral: you can get it to run much, much faster, if you need.
Still, SXP is not too slow to be unusable: for example, reading a 5 MB XML file describing the structure of a graph with 1000 nodes and 100 000 connections between them (see the second example below) takes less then 4 seconds on my 450 MHz Celeron. This comes to show that, first, with today's CPUs you can get away with being lazy and using STL, and, second, expat is a darn good parser.
The latest version of SXP is 1.1. You can download it from
here (~20 KB).
Sorry, Stallmanheads. Getting GNU autoconf into SXP was a mistake, as was the RPM version. They're not coming back.
You will need to download expat first.
The archive contains the following files:
expat, sadly, has become more difficult to built lately.
What I did with SXP 1.1 was get the expat 1.95.1 archive, open the DSP
in the /lib folder, compile the Debug version, compile the Release version,
find/fix two small annoying bugs in it, rebuild again and copy the following files
over to the folder where SXP is buing built:
expat.lib, expat.h, expat.dll
You will have to redistribute expat.dll with your application if you use SXP, or you can compile and link expat directly with your software (which is a better solution IMHO).
Two stupid bugs fixed related to UTF-8 support, more code moved from the header to the CPP, and changed to compile against newest expat version.
SXP is stable at this point; slight derivations have been successfully used in two projects, and it seems it serves its purposes well. I feel it deserves 1.0 status now.
All in all, from a user class point of view, only one thing has changed: recursive invocation when outputting XML is done with WriteSubElement, not with WriteElement.
Initial public release.
Both sxp.h itself and the samples (config.cpp and graph.cpp) are very heavily commented and will serve the role of a manual. Please first read config.cpp, then the comments for the interfaces in sxp.h. Once you understand that, read graph.cpp. This should be more than enough for you to know how to SXP-enable your own classes. If you think more explanation and instruction is needed, write me and I'll try to find the time for a decent manual.
I will try to find some time for a decent introduction text.
Any suggestions towards more functionality? I'm trying to adhere to the KISS principle in SXP, though; I don't want to fill it with bells and whistles.
Basically, I believe SXP is done, useful and elegantly minimalistic in its present form; don't expect great deeds.
Some things I won't do in SXP:
SXP has not been extensively tested. It worked on all the test examples I wrote, a modification of it works inside a commercial application I'm working on, but I can't guarantee it will work for you. If it crashes your system, deletes or corrupts your data, and destroys your personal life, it's not my fault - you've been warned. Proceed at your own risk.
SXP can be distributed by any of the non-viral public licenses out there. I like the Artistic License; I don't like the GPL. Basically, do whatever you like with it, let me know if you make it better, and don't put it under the GPL. If you badly need it under the GPL (evil! evil!), please contact me and we'll arrange something (e.g. an exception just for your project).
SXP is a tiny layer on top of a much bigger piece of software, the excellent expat XML parser by James Clark. If SXP works, it is James Clark's credit; when SXP doesn't work, it's my fault.
My name is Ivan-Assen Ivanov and I live somewhere in Bulgaria (go fetch a book of maps). Forgive my English. I hope my C++ is better.
I'd be glad to hear complaints, bug reports, praises, suggestions and tales how you used SXP and killed the dragon here.
Big Brother is watching you, number
xml.com - great articles, a lot of
James Clark's page - the author of expat