Wednesday 17 October 2001
The expat wrapper is now parameterised on string type and string conversion policy, which isn’t nearly as frightening as it sounds. Basically, you specify what output string type you want, typically std::string and a supply a second type which knows how to convert const char* (expat’s native string type) to std::string. Obviously that’s a pretty trivial example.
It gets more interesting if you’re using some custom string type, or you want a std::wstring containing UTF-16 Unicode instead of expat’s UTF-8 encoded const char*. In cases like this, the string conversion policy class would need to a little more work (although not too much). The big gain is that you can just drop it straight in, and the expat wrapper will hand out what you want. No second conversion layer on top, no further fiddling. Cool.
Andrei Alexandrescu’s fantastic book Modern C++ Design describes this design approach in much more, and more illuminating, detail.
Freelance software grandad
software created
extended or repaired
Freelance software grandad
software created
extended or repaired
Freelance software grandad
software created
extended or repaired
Freelance software grandad
software created
extended or repaired
Freelance software grandad
software created
extended or repaired
Freelance software grandad
software created
extended or repaired