Boost logo

Boost :

From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2005-11-09 04:23:37

Stefan Seefeld <seefeld_at_[hidden]> writes:

> thinking more about the involved issues, and especially taking into account
> one comment regarding the need to pass 'internalized' strings around to avoid
> duplicate conversions, I'm tempted by a radically different option:
> Let the XML API provide a 'string_type' (or may be 'cdata_type'), and exclusively
> operate on that. This type would be self-descriptive such that it could vary with
> the backend, but always provide the same (compile-time) interface to users
> (with tags for encoding, etc.).
> Users then explicitely convert their strings back and forth on each call:
> document_ptr doc(new document());
> element_ptr root = doc->set_root(cdata_type("book"));
> my_unicode_type name = ...;
> root->apped_element(internalize(name));
> Here, 'internalize' is a user-provided converter that generates dom::cdata_type
> from my_unicode_type. Thus you can write as many converters as you have unicode
> types, and have explicit control over when and where to convert. (Well, and if
> you prefer implicit conversion, say, because you want to operate on a lot of
> ASCII data, just add implicit cast and non-explicit constructors to your unicode
> type.)
> What about that ?

Looks good. You get a clean separation between the internal API string type,
and the external string type. I like it.


Anthony Williams
Software Developer
Just Software Solutions Ltd

Boost list run by bdawes at, gregod at, cpdaniel at, john at